linkmore-design 1.1.27-alpha.0 → 1.1.27-alpha.2

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 (63) hide show
  1. package/dist/LmEditTable/EditTable.d.ts +4 -0
  2. package/dist/LmEditTable/components/customRenderEmpty.d.ts +2 -0
  3. package/dist/LmEditTable/components/index.d.ts +2 -1
  4. package/dist/LmEditTable/util.d.ts +3 -0
  5. package/{lib/LmEditTable/virtual/VirtualRowBack.d.ts → dist/LmEditTable/virtual/VirtualRow2.d.ts} +7 -6
  6. package/dist/LmTable/virTual/VirtualRow.d.ts +1 -1
  7. package/dist/index.umd.js +398 -111
  8. package/dist/index.umd.min.js +21 -21
  9. package/dist/variables.css +41 -0
  10. package/es/LmEditTable/EditTable.d.ts +4 -0
  11. package/es/LmEditTable/EditTable.js +68 -11
  12. package/es/LmEditTable/components/customRenderEmpty.d.ts +2 -0
  13. package/es/LmEditTable/components/customRenderEmpty.js +20 -0
  14. package/es/LmEditTable/components/index.d.ts +2 -1
  15. package/es/LmEditTable/components/index.js +2 -1
  16. package/es/LmEditTable/rowSort/DndContainerRow.js +6 -3
  17. package/es/LmEditTable/style/index.css +41 -0
  18. package/es/LmEditTable/style/variables.css +41 -0
  19. package/es/LmEditTable/util.d.ts +3 -0
  20. package/es/LmEditTable/util.js +61 -1
  21. package/es/LmEditTable/virtual/VirtualRow.js +94 -16
  22. package/{dist/LmEditTable/virtual/VirtualRowBack.d.ts → es/LmEditTable/virtual/VirtualRow2.d.ts} +7 -6
  23. package/es/LmEditTable/virtual/VirtualRow2.js +62 -0
  24. package/es/LmEditTable/virtual/VirtualTable.js +17 -9
  25. package/es/LmEditTable/virtual/context.js +14 -2
  26. package/es/LmFilter/baseFilter/index.js +3 -2
  27. package/es/LmFilter/filterFns/index.js +4 -2
  28. package/es/LmTable/virTual/VirtualRow.d.ts +1 -1
  29. package/es/LmTable/virTual/VirtualRow.js +80 -44
  30. package/es/LmTable/virTual/VirtualTable.js +17 -9
  31. package/es/LmTable/virTual/context.js +14 -2
  32. package/es/LmUpload/body/UploadCore.js +1 -1
  33. package/es/Radio/index.js +9 -1
  34. package/es/Switch/index.js +7 -2
  35. package/es/styles/variables.css +41 -0
  36. package/lib/LmEditTable/EditTable.d.ts +4 -0
  37. package/lib/LmEditTable/EditTable.js +67 -9
  38. package/lib/LmEditTable/components/customRenderEmpty.d.ts +2 -0
  39. package/lib/LmEditTable/components/customRenderEmpty.js +32 -0
  40. package/lib/LmEditTable/components/index.d.ts +2 -1
  41. package/lib/LmEditTable/components/index.js +8 -0
  42. package/lib/LmEditTable/rowSort/DndContainerRow.js +5 -3
  43. package/lib/LmEditTable/style/index.css +41 -0
  44. package/lib/LmEditTable/style/variables.css +41 -0
  45. package/lib/LmEditTable/util.d.ts +3 -0
  46. package/lib/LmEditTable/util.js +64 -0
  47. package/lib/LmEditTable/virtual/VirtualRow.js +93 -16
  48. package/{es/LmEditTable/virtual/VirtualRowBack.d.ts → lib/LmEditTable/virtual/VirtualRow2.d.ts} +1 -0
  49. package/lib/LmEditTable/virtual/{VirtualRowBack.js → VirtualRow2.js} +13 -48
  50. package/lib/LmEditTable/virtual/VirtualTable.js +16 -8
  51. package/lib/LmEditTable/virtual/context.js +14 -2
  52. package/lib/LmFilter/baseFilter/index.js +3 -2
  53. package/lib/LmFilter/filterFns/index.js +4 -2
  54. package/lib/LmTable/virTual/VirtualRow.d.ts +1 -1
  55. package/lib/LmTable/virTual/VirtualRow.js +79 -44
  56. package/lib/LmTable/virTual/VirtualTable.js +16 -8
  57. package/lib/LmTable/virTual/context.js +14 -2
  58. package/lib/LmUpload/body/UploadCore.js +1 -1
  59. package/lib/Radio/index.js +9 -1
  60. package/lib/Switch/index.js +9 -2
  61. package/lib/styles/variables.css +41 -0
  62. package/package.json +1 -1
  63. package/es/LmEditTable/virtual/VirtualRowBack.js +0 -100
@@ -14,32 +14,63 @@ var __rest = this && this.__rest || function (s, e) {
14
14
  import React, { useRef, useMemo, useEffect } from 'react';
15
15
  import { useStore } from './context';
16
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"]);
17
+
18
+ var useOptions = function useOptions(_ref) {
19
+ var children = _ref.children,
20
+ ref = _ref.ref,
21
+ trRef = _ref.trRef;
21
22
 
22
23
  var _useStore = useStore(),
23
24
  state = _useStore.state,
24
- dispatch = _useStore.dispatch;
25
+ dispatch = _useStore.dispatch,
26
+ instance = _useStore.instance;
25
27
 
28
+ var virtualItems = instance.columnVirtual.virtualItems;
26
29
  var rowHeight = state.rowHeight,
27
30
  totalLen = state.totalLen;
28
- var trRef = useRef(null); // 列长度
31
+ var sliceColumns = useMemo(function () {
32
+ return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
33
+ var _a, _b;
29
34
 
30
- var columnsLen = useMemo(function () {
31
- var _a;
35
+ if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
36
+ pre.leftColumns.push(cur);
37
+ return pre;
38
+ }
32
39
 
33
- return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
40
+ if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
41
+ pre.rightColumns.push(cur);
42
+ return pre;
43
+ }
44
+
45
+ pre.centerColumns.push(cur);
46
+ return pre;
47
+ }, {
48
+ leftColumns: [],
49
+ rightColumns: [],
50
+ centerColumns: []
51
+ });
34
52
  }, [children]);
35
53
  useEffect(function () {
36
- if (state.columnsLen !== columnsLen) {
54
+ dispatch({
55
+ type: 'changeSliceColumns',
56
+ sliceColumns: sliceColumns
57
+ });
58
+ }, [sliceColumns]); // 非固定列长度
59
+
60
+ var centerColumnsLen = useMemo(function () {
61
+ var _a;
62
+
63
+ return (_a = sliceColumns.centerColumns.length) !== null && _a !== void 0 ? _a : 0;
64
+ }, [sliceColumns]);
65
+ useEffect(function () {
66
+ if (state.columnsLen !== centerColumnsLen) {
37
67
  dispatch({
38
68
  type: 'changeColumnsLen',
39
- columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
69
+ columnsLen: centerColumnsLen !== null && centerColumnsLen !== void 0 ? centerColumnsLen : 0
40
70
  });
41
71
  }
42
- }, [columnsLen, dispatch, state.columnsLen]);
72
+ }, [centerColumnsLen, dispatch, state.columnsLen]); // 获取行的高度
73
+
43
74
  useEffect(function () {
44
75
  var initHeight = function initHeight(tempRef) {
45
76
  var _a, _b, _c;
@@ -48,15 +79,62 @@ var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
48
79
  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
80
  dispatch({
50
81
  type: 'initHeight',
51
- rowHeight: tempRowHeight
82
+ rowHeight: tempRowHeight + 1
52
83
  });
53
84
  }
54
85
  };
55
86
 
56
- initHeight(trRef);
57
- }, [trRef, dispatch, rowHeight, totalLen, ref]);
87
+ initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
88
+ }, [trRef, dispatch, rowHeight, totalLen, ref]); // 横向单元格合并
89
+
90
+ var leftColSpan = useMemo(function () {
91
+ var _a;
92
+
93
+ return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
94
+ }, [virtualItems]); // 右侧隐藏数量
95
+
96
+ var rightColSpan = useMemo(function () {
97
+ return sliceColumns.centerColumns.length - virtualItems.length - leftColSpan || 0;
98
+ }, [sliceColumns.centerColumns.length, virtualItems.length, leftColSpan]);
99
+ return Object.assign(Object.assign({
100
+ virtualItems: virtualItems
101
+ }, sliceColumns), {
102
+ leftColSpan: leftColSpan,
103
+ rightColSpan: rightColSpan
104
+ });
105
+ };
106
+
107
+ var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
108
+ var children = _a.children,
109
+ pref = _a.pref,
110
+ resetProps = __rest(_a, ["children", "pref"]);
111
+
112
+ var trRef = useRef(null);
113
+
114
+ var _useOptions = useOptions({
115
+ children: children,
116
+ ref: ref,
117
+ trRef: trRef
118
+ }),
119
+ virtualItems = _useOptions.virtualItems,
120
+ leftColumns = _useOptions.leftColumns,
121
+ centerColumns = _useOptions.centerColumns,
122
+ rightColumns = _useOptions.rightColumns,
123
+ leftColSpan = _useOptions.leftColSpan,
124
+ rightColSpan = _useOptions.rightColSpan;
125
+
58
126
  return /*#__PURE__*/React.createElement("tr", Object.assign({}, resetProps, {
59
127
  ref: useForkRef(pref, trRef)
60
- }), children);
128
+ }), leftColumns, !!leftColSpan && /*#__PURE__*/React.createElement("td", {
129
+ key: "leftColSpan",
130
+ colSpan: leftColSpan
131
+ }), virtualItems.map(function (virtualCol) {
132
+ return /*#__PURE__*/React.cloneElement(centerColumns[virtualCol.index], {
133
+ ref: virtualCol.measureRef
134
+ });
135
+ }), !!rightColSpan && /*#__PURE__*/React.createElement("td", {
136
+ key: "rightColSpan",
137
+ colSpan: rightColSpan
138
+ }), rightColumns);
61
139
  });
62
140
  export default VirtualRow;
@@ -1,6 +1,7 @@
1
- import React from 'react';
2
- interface rowProps {
3
- children?: any;
4
- }
5
- declare const VirtualRow: React.NamedExoticComponent<rowProps>;
6
- export default VirtualRow;
1
+ import React from 'react';
2
+ interface rowProps {
3
+ children?: any;
4
+ pref?: any;
5
+ }
6
+ declare const VirtualRow: React.NamedExoticComponent<rowProps>;
7
+ export default VirtualRow;
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import React, { useRef } from 'react';
2
+ import React, { useCallback, useRef } from 'react';
3
3
  import { useVirtual } from 'react-virtual';
4
4
  import { TableContext, useRealive } from './context';
5
5
  var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
@@ -10,7 +10,7 @@ var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
10
10
  var _useRealive = useRealive(),
11
11
  _useRealive2 = _slicedToArray(_useRealive, 2),
12
12
  state = _useRealive2[0],
13
- dispatch = _useRealive2[1]; // { totalSize, virtualItems }
13
+ dispatch = _useRealive2[1]; // 行虚拟化 { totalSize, virtualItems }
14
14
 
15
15
 
16
16
  var rowVirtual = useVirtual({
@@ -23,18 +23,26 @@ var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
23
23
  return state.rowHeight;
24
24
  }, [state.rowHeight]),
25
25
  overscan: 5
26
- });
26
+ }); // 列动态宽度
27
+
28
+ var columnEstimateSize = useCallback(function (i) {
29
+ var _a, _b;
30
+
31
+ 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;
32
+ var leftColumnsLen = state.sliceColumns.leftColumns.length;
33
+ var centerColumnsLen = state.sliceColumns.centerColumns.length; // 获取非固定列
34
+
35
+ var virList = colWidths.slice(leftColumnsLen, leftColumnsLen + centerColumnsLen);
36
+ return virList[i] || 0;
37
+ }, [(_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]); // 列虚拟化
38
+
27
39
  var columnVirtual = useVirtual({
28
40
  horizontal: true,
29
41
  size: state.columnsLen,
30
42
  parentRef: {
31
- current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
43
+ current: (_d = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _d === void 0 ? void 0 : _d.parentNode
32
44
  },
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]),
45
+ estimateSize: columnEstimateSize,
38
46
  overscan: 5
39
47
  });
40
48
  var instance = {
@@ -15,13 +15,20 @@ var initialState = {
15
15
  rowHeight: 0,
16
16
  columnsLen: 0,
17
17
  // 总行数
18
- totalLen: 0
18
+ totalLen: 0,
19
+ // 分割后的列数组
20
+ sliceColumns: {
21
+ leftColumns: [],
22
+ centerColumns: [],
23
+ rightColumns: []
24
+ }
19
25
  };
20
26
 
21
27
  var reducer = function reducer(state, action) {
22
28
  var totalLen = action.totalLen,
23
29
  columnsLen = action.columnsLen,
24
- rowHeight = action.rowHeight;
30
+ rowHeight = action.rowHeight,
31
+ sliceColumns = action.sliceColumns;
25
32
 
26
33
  switch (action.type) {
27
34
  // 数据数量
@@ -42,6 +49,11 @@ var reducer = function reducer(state, action) {
42
49
  rowHeight: rowHeight
43
50
  });
44
51
 
52
+ case 'changeSliceColumns':
53
+ return Object.assign(Object.assign({}, state), {
54
+ sliceColumns: sliceColumns
55
+ });
56
+
45
57
  default:
46
58
  throw new Error();
47
59
  }
@@ -16,8 +16,9 @@ var _components = _interopRequireDefault(require("../components"));
16
16
  // 二级过滤 => 基础过滤组件
17
17
  var LmFilterBase = /*#__PURE__*/_react.default.memo(function (_ref) {
18
18
  var instance = _ref.instance;
19
- var dataSource = instance.dataSource;
20
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_fuzzySearch.default, {
19
+ var dataSource = instance.dataSource,
20
+ enableSearch = instance.enableSearch;
21
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, enableSearch && /*#__PURE__*/_react.default.createElement(_fuzzySearch.default, {
21
22
  instance: instance
22
23
  }), dataSource.map(function (v, index) {
23
24
  var isHidden = !v.show && typeof v.show === 'boolean';
@@ -168,6 +168,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
168
168
 
169
169
  if (getIsHas(itemValue) && !!item) {
170
170
  return [].concat(_toConsumableArray(pre), [{
171
+ relation: obj[cur].mode || 'and',
171
172
  fieldName: cur,
172
173
  fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
173
174
  type: item.type,
@@ -177,7 +178,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
177
178
  * and 等同于逻辑关系contains: 选中的值包含所有值
178
179
  * or 等同于逻辑关系in: 选中的值存在于所有值之中
179
180
  */
180
- operator: obj[cur].mode === 'and' ? 'contains' : 'in'
181
+ operator: 'in'
181
182
  }]);
182
183
  }
183
184
 
@@ -344,11 +345,12 @@ var useCoreOptions = function useCoreOptions(_ref) {
344
345
  if (getIsHas(itemValue) && !!item) {
345
346
  // eslint-disable-next-line no-param-reassign
346
347
  pre[cur] = {
348
+ relation: complexFilter[cur].mode || 'and',
347
349
  fieldName: cur,
348
350
  fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
349
351
  type: item.type,
350
352
  value: Array.isArray(itemValue) ? itemValue : [itemValue],
351
- operator: complexFilter[cur].mode === 'and' ? 'contains' : 'in'
353
+ operator: 'in'
352
354
  };
353
355
  }
354
356
 
@@ -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;
@@ -13,37 +13,63 @@ var __rest = this && this.__rest || function (s, e) {
13
13
 
14
14
  import React, { useRef, useMemo, useEffect } from 'react';
15
15
  import { useStore } from './context';
16
- var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
17
- var children = _a.children,
18
- resetProps = __rest(_a, ["children"]);
16
+
17
+ var useOptions = function useOptions(_ref) {
18
+ var children = _ref.children,
19
+ ref = _ref.ref,
20
+ trRef = _ref.trRef;
19
21
 
20
22
  var _useStore = useStore(),
21
23
  state = _useStore.state,
22
24
  dispatch = _useStore.dispatch,
23
25
  instance = _useStore.instance;
24
26
 
27
+ var virtualItems = instance.columnVirtual.virtualItems;
25
28
  var rowHeight = state.rowHeight,
26
29
  totalLen = state.totalLen;
27
- var virtualItems = instance.columnVirtual.virtualItems;
28
- var trRef = useRef(null); // 非固定列长度
30
+ var sliceColumns = useMemo(function () {
31
+ return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
32
+ var _a, _b;
29
33
 
30
- var columnsLen = useMemo(function () {
31
- var _a;
34
+ if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
35
+ pre.leftColumns.push(cur);
36
+ return pre;
37
+ }
32
38
 
33
- return (_a = children === null || children === void 0 ? void 0 : children.filter(function (v) {
34
- var _a, _b;
39
+ if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
40
+ pre.rightColumns.push(cur);
41
+ return pre;
42
+ }
35
43
 
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
44
+ pre.centerColumns.push(cur);
45
+ return pre;
46
+ }, {
47
+ leftColumns: [],
48
+ rightColumns: [],
49
+ centerColumns: []
50
+ });
38
51
  }, [children]);
39
52
  useEffect(function () {
40
- if (state.columnsLen !== columnsLen) {
53
+ dispatch({
54
+ type: 'changeSliceColumns',
55
+ sliceColumns: sliceColumns
56
+ });
57
+ }, [sliceColumns]); // 非固定列长度
58
+
59
+ var centerColumnsLen = useMemo(function () {
60
+ var _a;
61
+
62
+ return (_a = sliceColumns.centerColumns.length) !== null && _a !== void 0 ? _a : 0;
63
+ }, [sliceColumns]);
64
+ useEffect(function () {
65
+ if (state.columnsLen !== centerColumnsLen) {
41
66
  dispatch({
42
67
  type: 'changeColumnsLen',
43
- columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
68
+ columnsLen: centerColumnsLen !== null && centerColumnsLen !== void 0 ? centerColumnsLen : 0
44
69
  });
45
70
  }
46
- }, [columnsLen, dispatch, state.columnsLen]);
71
+ }, [centerColumnsLen, dispatch, state.columnsLen]); // 获取行的高度
72
+
47
73
  useEffect(function () {
48
74
  var initHeight = function initHeight(tempRef) {
49
75
  var _a, _b, _c;
@@ -52,49 +78,59 @@ var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
52
78
  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
79
  dispatch({
54
80
  type: 'initHeight',
55
- rowHeight: tempRowHeight
81
+ rowHeight: tempRowHeight + 1
56
82
  });
57
83
  }
58
84
  };
59
85
 
60
86
  initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
61
- }, [trRef, dispatch, rowHeight, totalLen, ref]); // return {fixedLeft: [], fixedRight: [], columns: []}
87
+ }, [trRef, dispatch, rowHeight, totalLen, ref]); // 横向单元格合并
62
88
 
63
- var fixedColumns = useMemo(function () {
64
- return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
65
- var _a, _b;
89
+ var leftColSpan = useMemo(function () {
90
+ var _a;
66
91
 
67
- if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
68
- pre.fixedLeft.push(cur);
69
- return pre;
70
- }
92
+ return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
93
+ }, [virtualItems]); // 右侧隐藏数量
94
+
95
+ var rightColSpan = useMemo(function () {
96
+ return sliceColumns.centerColumns.length - virtualItems.length - leftColSpan || 0;
97
+ }, [sliceColumns.centerColumns.length, virtualItems.length, leftColSpan]);
98
+ return Object.assign(Object.assign({
99
+ virtualItems: virtualItems
100
+ }, sliceColumns), {
101
+ leftColSpan: leftColSpan,
102
+ rightColSpan: rightColSpan
103
+ });
104
+ };
71
105
 
72
- if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
73
- pre.fixedRight.push(cur);
74
- return pre;
75
- }
106
+ var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
107
+ var children = _a.children,
108
+ resetProps = __rest(_a, ["children"]);
76
109
 
77
- pre.columns.push(cur);
78
- return pre;
79
- }, {
80
- fixedLeft: [],
81
- fixedRight: [],
82
- columns: []
83
- });
84
- }, [children]); // 横线单元格合并
110
+ var trRef = useRef(null);
85
111
 
86
- var colSpan = useMemo(function () {
87
- var _a;
112
+ var _useOptions = useOptions({
113
+ children: children,
114
+ ref: ref,
115
+ trRef: trRef
116
+ }),
117
+ virtualItems = _useOptions.virtualItems,
118
+ leftColumns = _useOptions.leftColumns,
119
+ centerColumns = _useOptions.centerColumns,
120
+ rightColumns = _useOptions.rightColumns,
121
+ leftColSpan = _useOptions.leftColSpan,
122
+ rightColSpan = _useOptions.rightColSpan;
88
123
 
89
- return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
90
- }, [virtualItems]);
91
- console.log('virtualItems', virtualItems);
92
124
  return /*#__PURE__*/React.createElement("tr", Object.assign({}, resetProps, {
93
125
  ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
94
- }), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/React.createElement("td", {
95
- colSpan: colSpan
126
+ }), leftColumns, !!leftColSpan && /*#__PURE__*/React.createElement("td", {
127
+ key: "leftColSpan",
128
+ colSpan: leftColSpan
96
129
  }), virtualItems.map(function (virtualCol) {
97
- return fixedColumns.columns[virtualCol.index];
98
- }), fixedColumns.fixedRight);
130
+ return centerColumns[virtualCol.index];
131
+ }), !!rightColSpan && /*#__PURE__*/React.createElement("td", {
132
+ key: "rightColSpan",
133
+ colSpan: rightColSpan
134
+ }), rightColumns);
99
135
  });
100
136
  export default VirtualRow;
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import React, { useRef } from 'react';
2
+ import React, { useCallback, useRef } from 'react';
3
3
  import { useVirtual } from 'react-virtual';
4
4
  import { TableContext, useRealive } from './context';
5
5
  var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
@@ -10,7 +10,7 @@ var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
10
10
  var _useRealive = useRealive(),
11
11
  _useRealive2 = _slicedToArray(_useRealive, 2),
12
12
  state = _useRealive2[0],
13
- dispatch = _useRealive2[1]; // { totalSize, virtualItems }
13
+ dispatch = _useRealive2[1]; // 行虚拟化 { totalSize, virtualItems }
14
14
 
15
15
 
16
16
  var rowVirtual = useVirtual({
@@ -23,18 +23,26 @@ var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
23
23
  return state.rowHeight;
24
24
  }, [state.rowHeight]),
25
25
  overscan: 5
26
- });
26
+ }); // 列动态宽度
27
+
28
+ var columnEstimateSize = useCallback(function (i) {
29
+ var _a, _b;
30
+
31
+ 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;
32
+ var leftColumnsLen = state.sliceColumns.leftColumns.length;
33
+ var centerColumnsLen = state.sliceColumns.centerColumns.length; // 获取非固定列
34
+
35
+ var virList = colWidths.slice(leftColumnsLen, leftColumnsLen + centerColumnsLen);
36
+ return virList[i] || 0;
37
+ }, [(_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]); // 列虚拟化
38
+
27
39
  var columnVirtual = useVirtual({
28
40
  horizontal: true,
29
41
  size: state.columnsLen,
30
42
  parentRef: {
31
- current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
43
+ current: (_d = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _d === void 0 ? void 0 : _d.parentNode
32
44
  },
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]),
45
+ estimateSize: columnEstimateSize,
38
46
  overscan: 5
39
47
  });
40
48
  var instance = {
@@ -15,13 +15,20 @@ var initialState = {
15
15
  rowHeight: 0,
16
16
  columnsLen: 0,
17
17
  // 总行数
18
- totalLen: 0
18
+ totalLen: 0,
19
+ // 分割后的列数组
20
+ sliceColumns: {
21
+ leftColumns: [],
22
+ centerColumns: [],
23
+ rightColumns: []
24
+ }
19
25
  };
20
26
 
21
27
  var reducer = function reducer(state, action) {
22
28
  var totalLen = action.totalLen,
23
29
  columnsLen = action.columnsLen,
24
- rowHeight = action.rowHeight;
30
+ rowHeight = action.rowHeight,
31
+ sliceColumns = action.sliceColumns;
25
32
 
26
33
  switch (action.type) {
27
34
  // 数据数量
@@ -42,6 +49,11 @@ var reducer = function reducer(state, action) {
42
49
  rowHeight: rowHeight
43
50
  });
44
51
 
52
+ case 'changeSliceColumns':
53
+ return Object.assign(Object.assign({}, state), {
54
+ sliceColumns: sliceColumns
55
+ });
56
+
45
57
  default:
46
58
  throw new Error();
47
59
  }
@@ -24,7 +24,7 @@ var UploadCore = function UploadCore(_ref) {
24
24
  var isUploading = getUploadStatus().uploading;
25
25
  if (isUploading) return;
26
26
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
27
- }, [getUploadStatus]); // 上传触发事件
27
+ }, [disabled, getUploadStatus]); // 上传触发事件
28
28
 
29
29
  var uploadChange = useCallback(function (e) {
30
30
  var _a;
package/es/Radio/index.js CHANGED
@@ -19,13 +19,21 @@ var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
20
  var _react = _interopRequireDefault(require("react"));
21
21
 
22
- var _excluded = ["children"],
22
+ var _DisabledContext = _interopRequireDefault(require("../ConfigProvider/DisabledContext"));
23
+
24
+ var _excluded = ["children", "disabled"],
23
25
  _excluded2 = ["children", "size", "buttonStyle", "direction", "className"];
24
26
 
25
27
  var LMRadio = function LMRadio(props) {
26
28
  var children = props.children,
29
+ customDisabled = props.disabled,
27
30
  restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
31
+
32
+ var disabled = _react.default.useContext(_DisabledContext.default);
33
+
34
+ var mergedDisabled = customDisabled || disabled;
28
35
  return /*#__PURE__*/_react.default.createElement(_radio.default, (0, _extends2.default)({
36
+ disabled: mergedDisabled,
29
37
  className: "lm-radio"
30
38
  }, restProps), children);
31
39
  };