@kdcloudjs/table 1.2.2-canary.11 → 1.2.2-canary.11-hotfix.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/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +3305 -3340
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +11 -13
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/kd-ui-complete.less +777 -777
- package/es/_utils/formatUtil.js +5 -1
- package/es/_utils/hooks.js +3 -3
- package/es/_utils/usePopper.js +13 -13
- package/es/locale/locale.js +7 -6
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/BlankComponent.d.ts +11 -0
- package/es/table/base/BlankComponent.js +61 -0
- package/es/table/base/calculations.js +3 -3
- package/es/table/base/empty.js +2 -2
- package/es/table/base/globalStyleComponent.js +8 -6
- package/es/table/base/header.js +7 -5
- package/es/table/base/helpers/FastScrollManager.d.ts +96 -0
- package/es/table/base/helpers/FastScrollManager.js +167 -0
- package/es/table/base/helpers/SpanManager.js +2 -1
- package/es/table/base/helpers/TableDOMUtils.js +6 -5
- package/es/table/base/html-table.js +4 -3
- package/es/table/base/loading.js +2 -2
- package/es/table/base/renderTemplates.js +16 -16
- package/es/table/base/table.d.ts +13 -0
- package/es/table/base/table.js +141 -84
- package/es/table/base/utils.js +3 -3
- package/es/table/pipeline/features/columnDrag.js +1 -0
- package/es/table/pipeline/features/columnFilter.js +3 -1
- package/es/table/pipeline/features/columnResizeWidth.js +2 -2
- package/es/table/pipeline/features/contextMenu.js +6 -4
- package/es/table/pipeline/features/featureApi/RowDragApi.js +2 -1
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +5 -4
- package/es/table/pipeline/features/filter/Filter.js +3 -2
- package/es/table/pipeline/features/rangeSelection.js +10 -10
- package/es/table/pipeline/features/rowDetail.js +2 -2
- package/es/table/pipeline/features/rowDrag.js +2 -1
- package/es/table/pipeline/features/rowGrouping.js +2 -2
- package/es/table/pipeline/features/sort.js +7 -6
- package/es/table/pipeline/features/tips.js +4 -4
- package/es/table/pipeline/features/treeMode.js +5 -5
- package/es/table/pipeline/features/treeSelect.js +2 -2
- package/es/table/pipeline/pipeline.js +2 -1
- package/es/table/pivot/cross-table/buildCrossTable.js +8 -6
- package/es/table/pivot/cross-table/cross-table.js +3 -1
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +10 -8
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +11 -8
- package/es/table/pivot/pivot-utils/builders.js +3 -3
- package/es/table/pivot/pivot-utils/convert-utils.js +3 -3
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoWidth.js +3 -3
- package/es/table/transforms/columnResize.js +5 -3
- package/es/table/transforms/sort.js +8 -6
- package/es/table/transforms/tips.js +4 -4
- package/es/table/transforms/treeMode.js +8 -6
- package/es/table/utils/buildTree.js +3 -3
- package/es/table/utils/collectNodes.js +3 -3
- package/es/table/utils/exportTableAsExcel.js +3 -3
- package/es/table/utils/getTreeDepth.js +3 -3
- package/es/table/utils/groupBy.js +3 -3
- package/es/table/utils/makeRecursiveMapper.js +3 -3
- package/es/table/utils/mergeCellProps.js +1 -0
- package/es/table/utils/others.js +3 -3
- package/es/table/utils/traverseColumn.js +3 -3
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +8 -7
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +5 -4
- package/lib/_utils/arrayUtil.js +3 -2
- package/lib/_utils/formatUtil.js +5 -1
- package/lib/_utils/hooks.js +3 -3
- package/lib/_utils/index.js +3 -2
- package/lib/_utils/type.js +5 -3
- package/lib/_utils/usePopper.js +21 -18
- package/lib/config-provider/ConfigContext.js +2 -1
- package/lib/config-provider/compDefaultProps.js +2 -1
- package/lib/config-provider/configProvider.js +4 -3
- package/lib/config-provider/defaultConfig.js +2 -1
- package/lib/config-provider/index.js +2 -1
- package/lib/locale/index.js +4 -3
- package/lib/locale/locale.js +14 -10
- package/lib/locale/zh-CN.js +2 -1
- package/lib/style/color/colors.less +1 -1
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +1 -1
- package/lib/style/core/motion/other.less +27 -27
- package/lib/style/core/motion/slide.less +53 -53
- package/lib/style/core/motion.less +1 -1
- package/lib/style/core/reset.less +185 -185
- package/lib/style/index.less +1 -1
- package/lib/style/mixins/index.less +18 -18
- package/lib/style/mixins/overlay.less +21 -21
- package/lib/style/mixins/reset.less +12 -12
- package/lib/style/themes/default.less +445 -445
- package/lib/table/base/BlankComponent.d.ts +11 -0
- package/lib/table/base/BlankComponent.js +75 -0
- package/lib/table/base/calculations.js +3 -3
- package/lib/table/base/empty.js +4 -4
- package/lib/table/base/globalStyleComponent.js +13 -10
- package/lib/table/base/header.js +7 -5
- package/lib/table/base/helpers/FastScrollManager.d.ts +96 -0
- package/lib/table/base/helpers/FastScrollManager.js +175 -0
- package/lib/table/base/helpers/SpanManager.js +5 -3
- package/lib/table/base/helpers/TableDOMUtils.js +9 -7
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +2 -2
- package/lib/table/base/html-table.js +4 -3
- package/lib/table/base/loading.js +2 -2
- package/lib/table/base/renderTemplates.js +18 -18
- package/lib/table/base/styles.js +18 -10
- package/lib/table/base/table.d.ts +13 -0
- package/lib/table/base/table.js +152 -96
- package/lib/table/base/utils.js +20 -13
- package/lib/table/common-views.js +8 -4
- package/lib/table/internals.js +3 -2
- package/lib/table/pipeline/const.js +3 -2
- package/lib/table/pipeline/features/autoFill.js +6 -3
- package/lib/table/pipeline/features/colGroupExtendable.js +3 -2
- package/lib/table/pipeline/features/columnDrag.js +1 -0
- package/lib/table/pipeline/features/columnFilter.js +3 -1
- package/lib/table/pipeline/features/columnResizeWidth.js +10 -7
- package/lib/table/pipeline/features/contextMenu.js +8 -6
- package/lib/table/pipeline/features/featureApi/RowDragApi.js +5 -3
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +9 -7
- package/lib/table/pipeline/features/filter/Filter.js +7 -5
- package/lib/table/pipeline/features/filter/FilterPanel.js +4 -3
- package/lib/table/pipeline/features/filter/util.js +3 -2
- package/lib/table/pipeline/features/footerDataSource.js +2 -1
- package/lib/table/pipeline/features/rangeSelection.js +14 -12
- package/lib/table/pipeline/features/rowDetail.js +2 -2
- package/lib/table/pipeline/features/rowDrag.js +8 -4
- package/lib/table/pipeline/features/rowGrouping.js +2 -2
- package/lib/table/pipeline/features/sort.js +7 -6
- package/lib/table/pipeline/features/tips.js +4 -4
- package/lib/table/pipeline/features/treeMode.js +9 -7
- package/lib/table/pipeline/features/treeSelect.js +2 -2
- package/lib/table/pipeline/index.js +2 -2
- package/lib/table/pipeline/pipeline.js +4 -2
- package/lib/table/pivot/cross-table/buildCrossTable.js +8 -6
- package/lib/table/pivot/cross-table/constants.js +2 -1
- package/lib/table/pivot/cross-table/cross-table.js +6 -3
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +10 -8
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +13 -9
- package/lib/table/pivot/pivot-utils/builders.js +3 -3
- package/lib/table/pivot/pivot-utils/convert-utils.js +3 -3
- package/lib/table/style/index.less +1 -1
- package/lib/table/transforms/autoWidth.js +5 -5
- package/lib/table/transforms/columnResize.js +7 -5
- package/lib/table/transforms/sort.js +10 -8
- package/lib/table/transforms/tips.js +4 -4
- package/lib/table/transforms/treeMode.js +10 -8
- package/lib/table/use/useResizeObserver.js +2 -1
- package/lib/table/utils/browserType.js +4 -2
- package/lib/table/utils/buildTree.js +3 -3
- package/lib/table/utils/collectNodes.js +3 -3
- package/lib/table/utils/console.js +3 -2
- package/lib/table/utils/copyToClipboard.js +2 -1
- package/lib/table/utils/exportTableAsExcel.js +3 -3
- package/lib/table/utils/getTreeDepth.js +3 -3
- package/lib/table/utils/groupBy.js +3 -3
- package/lib/table/utils/keyCode.js +2 -1
- package/lib/table/utils/makeRecursiveMapper.js +3 -3
- package/lib/table/utils/mergeCellProps.js +1 -0
- package/lib/table/utils/others.js +5 -4
- package/lib/table/utils/proto.js +2 -1
- package/lib/table/utils/selectColumn.js +4 -2
- package/lib/table/utils/traverseColumn.js +3 -3
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +11 -9
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +8 -6
- package/package.json +218 -218
|
@@ -49,7 +49,7 @@ function renderTableHeaderInIE(info, props, extra) {
|
|
|
49
49
|
style: typeof (extra === null || extra === void 0 ? void 0 : extra.stickyRightOffset) === 'number' ? {
|
|
50
50
|
width: extra === null || extra === void 0 ? void 0 : extra.stickyRightOffset
|
|
51
51
|
} : undefined
|
|
52
|
-
})), left.length > 0 ?
|
|
52
|
+
})), left.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
53
53
|
className: Classes.fixedLeft
|
|
54
54
|
}, /*#__PURE__*/React.createElement(TableHeader, {
|
|
55
55
|
info: _extends(_extends({}, info), {
|
|
@@ -75,7 +75,7 @@ function renderTableHeaderInIE(info, props, extra) {
|
|
|
75
75
|
}),
|
|
76
76
|
theaderPosition: "left",
|
|
77
77
|
rowCount: rowCount
|
|
78
|
-
}))
|
|
78
|
+
})) : null, right.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
79
79
|
className: Classes.fixedRight,
|
|
80
80
|
style: fixedRightTableStyle
|
|
81
81
|
}, /*#__PURE__*/React.createElement(TableHeader, {
|
|
@@ -102,7 +102,7 @@ function renderTableHeaderInIE(info, props, extra) {
|
|
|
102
102
|
}),
|
|
103
103
|
theaderPosition: 'right',
|
|
104
104
|
rowCount: rowCount
|
|
105
|
-
}))
|
|
105
|
+
})) : null);
|
|
106
106
|
}
|
|
107
107
|
function renderTableBodyInIE(info, props, extra) {
|
|
108
108
|
var dataSource = props.dataSource,
|
|
@@ -134,33 +134,33 @@ function renderTableBodyInIE(info, props, extra) {
|
|
|
134
134
|
}, /*#__PURE__*/React.createElement("div", {
|
|
135
135
|
className: Classes.virtual,
|
|
136
136
|
tabIndex: -1
|
|
137
|
-
}, topBlank > 0 &&
|
|
137
|
+
}, topBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
138
138
|
key: "top-blank",
|
|
139
139
|
className: cx(Classes.virtualBlank, 'top'),
|
|
140
140
|
style: {
|
|
141
141
|
height: topBlank
|
|
142
142
|
}
|
|
143
|
-
})
|
|
143
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
144
144
|
tbodyHtmlTag: "tbody"
|
|
145
145
|
}, commonProps, {
|
|
146
146
|
tbodyPosition: hasLockColumn ? 'center' : undefined,
|
|
147
147
|
horizontalRenderInfo: info,
|
|
148
148
|
verticalRenderInfo: verticalRenderInfo
|
|
149
|
-
})), bottomBlank > 0 &&
|
|
149
|
+
})), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
150
150
|
key: "bottom-blank",
|
|
151
151
|
className: cx(Classes.virtualBlank, 'bottom'),
|
|
152
152
|
style: {
|
|
153
153
|
height: bottomBlank
|
|
154
154
|
}
|
|
155
|
-
}))
|
|
155
|
+
})), left.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
156
156
|
className: Classes.fixedLeft
|
|
157
|
-
}, topBlank > 0 &&
|
|
157
|
+
}, topBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
158
158
|
key: "top-blank",
|
|
159
159
|
className: cx(Classes.virtualBlank, 'top'),
|
|
160
160
|
style: {
|
|
161
161
|
height: topBlank
|
|
162
162
|
}
|
|
163
|
-
})
|
|
163
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
164
164
|
tbodyHtmlTag: "tbody"
|
|
165
165
|
}, commonProps, {
|
|
166
166
|
tbodyPosition: "left",
|
|
@@ -174,21 +174,21 @@ function renderTableBodyInIE(info, props, extra) {
|
|
|
174
174
|
visible: _sliceInstanceProperty(visible).call(visible, 0, left.length)
|
|
175
175
|
}),
|
|
176
176
|
verticalRenderInfo: verticalRenderInfo
|
|
177
|
-
})), bottomBlank > 0 &&
|
|
177
|
+
})), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
178
178
|
key: "bottom-blank",
|
|
179
179
|
className: cx(Classes.virtualBlank, 'bottom'),
|
|
180
180
|
style: {
|
|
181
181
|
height: bottomBlank
|
|
182
182
|
}
|
|
183
|
-
}))
|
|
183
|
+
})) : null, right.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
184
184
|
className: Classes.fixedRight
|
|
185
|
-
}, topBlank > 0 &&
|
|
185
|
+
}, topBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
186
186
|
key: "top-blank",
|
|
187
187
|
className: cx(Classes.virtualBlank, 'top'),
|
|
188
188
|
style: {
|
|
189
189
|
height: topBlank
|
|
190
190
|
}
|
|
191
|
-
})
|
|
191
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, _extends({
|
|
192
192
|
tbodyHtmlTag: "tbody"
|
|
193
193
|
}, commonProps, {
|
|
194
194
|
tbodyPosition: "right",
|
|
@@ -202,13 +202,13 @@ function renderTableBodyInIE(info, props, extra) {
|
|
|
202
202
|
visible: _sliceInstanceProperty(visible).call(visible, visible.length - right.length)
|
|
203
203
|
}),
|
|
204
204
|
verticalRenderInfo: verticalRenderInfo
|
|
205
|
-
})), bottomBlank > 0 &&
|
|
205
|
+
})), bottomBlank > 0 && /*#__PURE__*/React.createElement("div", {
|
|
206
206
|
key: "bottom-blank",
|
|
207
207
|
className: cx(Classes.virtualBlank, 'bottom'),
|
|
208
208
|
style: {
|
|
209
209
|
height: bottomBlank
|
|
210
210
|
}
|
|
211
|
-
}))
|
|
211
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
212
212
|
className: Classes.rowDetailContainer
|
|
213
213
|
}));
|
|
214
214
|
}
|
|
@@ -295,7 +295,7 @@ function renderRowDetailInIE(params) {
|
|
|
295
295
|
if (!domHelper) return;
|
|
296
296
|
var artTable = domHelper.artTable;
|
|
297
297
|
var rowDetailContainer = artTable && artTable.querySelector(".".concat(Classes.rowDetailContainer));
|
|
298
|
-
return /*#__PURE__*/ReactDom.createPortal(/*#__PURE__*/React.createElement(RowDetail, _extends({}, params)), rowDetailContainer);
|
|
298
|
+
return /*#__PURE__*/ReactDom.createPortal( /*#__PURE__*/React.createElement(RowDetail, _extends({}, params)), rowDetailContainer);
|
|
299
299
|
}
|
|
300
300
|
function RowDetail(props) {
|
|
301
301
|
var detailRef = useRef(null);
|
package/es/table/base/table.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface BaseTableProps {
|
|
|
23
23
|
};
|
|
24
24
|
/** 虚拟滚动开启情况下,表格中每一行的预估高度 */
|
|
25
25
|
estimatedRowHeight?: number;
|
|
26
|
+
/** 性能差浏览器和处理器,性能差则启动快速滚动优化,默认为 false */
|
|
27
|
+
isLowPerformance?: boolean;
|
|
26
28
|
/** @deprecated 表格头部是否置顶,默认为 true。请使用 isStickyHeader 代替 */
|
|
27
29
|
isStickyHead?: boolean;
|
|
28
30
|
/** 表格头部是否置顶,默认为 true */
|
|
@@ -106,6 +108,13 @@ export interface BaseTableState {
|
|
|
106
108
|
offsetX: number;
|
|
107
109
|
/** 横向虚拟滚动 最大渲染尺寸 */
|
|
108
110
|
maxRenderWidth: number;
|
|
111
|
+
/** 快速滚动时保留的上一次渲染数据 */
|
|
112
|
+
previousRenderData?: {
|
|
113
|
+
offsetY: number;
|
|
114
|
+
maxRenderHeight: number;
|
|
115
|
+
maxRenderWidth: number;
|
|
116
|
+
verticalRenderRange: VerticalRenderRange;
|
|
117
|
+
};
|
|
109
118
|
}
|
|
110
119
|
export declare class BaseTable extends React.Component<BaseTableProps, BaseTableState> {
|
|
111
120
|
static defaultProps: {
|
|
@@ -119,6 +128,7 @@ export declare class BaseTable extends React.Component<BaseTableProps, BaseTable
|
|
|
119
128
|
stickyScrollHeight: string;
|
|
120
129
|
useVirtual: string;
|
|
121
130
|
estimatedRowHeight: number;
|
|
131
|
+
isLowPerformance: boolean;
|
|
122
132
|
isLoading: boolean;
|
|
123
133
|
components: {};
|
|
124
134
|
getTableProps: typeof noop;
|
|
@@ -136,6 +146,9 @@ export declare class BaseTable extends React.Component<BaseTableProps, BaseTable
|
|
|
136
146
|
private hasScrollY;
|
|
137
147
|
private resizeObserver?;
|
|
138
148
|
private offsetY;
|
|
149
|
+
private fastScrollManager;
|
|
150
|
+
private topBlankRef;
|
|
151
|
+
private bottomBlankRef;
|
|
139
152
|
/** @deprecated BaseTable.getDoms() 已经过时,请勿调用 */
|
|
140
153
|
getDoms(): TableDOMHelper;
|
|
141
154
|
constructor(props: Readonly<BaseTableProps>);
|
package/es/table/base/table.js
CHANGED
|
@@ -7,17 +7,17 @@ import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
|
7
7
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
8
8
|
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
9
9
|
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
10
|
+
import _inherits from "@babel/runtime-corejs3/helpers/inherits";
|
|
10
11
|
import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
|
|
11
12
|
import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
16
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
17
17
|
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
18
18
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
19
|
-
function
|
|
20
|
-
function _isNativeReflectConstruct() {
|
|
19
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
21
|
import cx from 'classnames';
|
|
22
22
|
import React from 'react';
|
|
23
23
|
import { BehaviorSubject, combineLatest, noop, Subscription, Subject, from } from 'rxjs';
|
|
@@ -28,6 +28,7 @@ import TableHeader from './header';
|
|
|
28
28
|
import { getRichVisibleRectsStream } from './helpers/getRichVisibleRectsStream';
|
|
29
29
|
import { getFullRenderRange, makeRowHeightManager } from './helpers/rowHeightManager';
|
|
30
30
|
import { TableDOMHelper } from './helpers/TableDOMUtils';
|
|
31
|
+
import { FastScrollManager } from './helpers/FastScrollManager';
|
|
31
32
|
import { HtmlTable } from './html-table';
|
|
32
33
|
import Loading from './loading';
|
|
33
34
|
import { Classes, LOCK_SHADOW_PADDING, StyledArtTableWrapper } from './styles';
|
|
@@ -35,6 +36,7 @@ import GlobalStyleComponent from './globalStyleComponent';
|
|
|
35
36
|
import { addResizeObserver, getScrollbarSize, OVERSCAN_SIZE, shallowEqual, STYLED_REF_PROP, sum, syncScrollLeft, throttledWindowResize$, getTableScrollFooterDOM, getTableScrollHeaderDOM, cssPolifill } from './utils';
|
|
36
37
|
import { console, browserType, isStickyUIDegrade } from '../utils';
|
|
37
38
|
import getTableRenderTemplate from './renderTemplates';
|
|
39
|
+
import { TopBlank, BottomBlank } from './BlankComponent';
|
|
38
40
|
var propsDotEmptyContentDeprecatedWarned = false;
|
|
39
41
|
function warnPropsDotEmptyContentIsDeprecated() {
|
|
40
42
|
if (!propsDotEmptyContentDeprecatedWarned) {
|
|
@@ -43,14 +45,19 @@ function warnPropsDotEmptyContentIsDeprecated() {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
48
|
+
_inherits(BaseTable, _React$Component);
|
|
49
|
+
var _super = _createSuper(BaseTable);
|
|
46
50
|
function BaseTable(props) {
|
|
47
51
|
var _this;
|
|
48
52
|
_classCallCheck(this, BaseTable);
|
|
49
|
-
_this =
|
|
53
|
+
_this = _super.call(this, props);
|
|
50
54
|
_this.rowHeightManager = makeRowHeightManager(_this.props.dataSource.length, _this.props.estimatedRowHeight);
|
|
51
55
|
_this.artTableWrapperRef = /*#__PURE__*/React.createRef();
|
|
52
56
|
_this.hasScrollY = false;
|
|
53
57
|
_this.offsetY = 0;
|
|
58
|
+
// Blank组件的引用,用于快速滚动时直接更新
|
|
59
|
+
_this.topBlankRef = /*#__PURE__*/React.createRef();
|
|
60
|
+
_this.bottomBlankRef = /*#__PURE__*/React.createRef();
|
|
54
61
|
_this.handleRowMouseEnter = function (e) {
|
|
55
62
|
var nodeList = _this.domHelper.getRowNodeListByEvent(e);
|
|
56
63
|
nodeList && nodeList.forEach(function (node) {
|
|
@@ -70,8 +77,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
70
77
|
getRowProps = _this$props.getRowProps,
|
|
71
78
|
primaryKey = _this$props.primaryKey,
|
|
72
79
|
isLoading = _this$props.isLoading,
|
|
73
|
-
emptyCellHeight = _this$props.emptyCellHeight
|
|
74
|
-
footerDataSource = _this$props.footerDataSource;
|
|
80
|
+
emptyCellHeight = _this$props.emptyCellHeight;
|
|
75
81
|
var tableBodyClassName = cx(Classes.tableBody, Classes.horizontalScrollContainer);
|
|
76
82
|
// 低版本Edge浏览器下也会出现双滚动条,这里设置overflow: 'hidden',先去掉edge的方向键控制滚动条的功能
|
|
77
83
|
var virtualStyle = browserType.isIE || browserType.isEdge ? {
|
|
@@ -121,13 +127,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
121
127
|
className: Classes.virtual,
|
|
122
128
|
tabIndex: -1,
|
|
123
129
|
style: virtualStyle
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
height: topBlank
|
|
129
|
-
}
|
|
130
|
-
})), /*#__PURE__*/React.createElement(HtmlTable, {
|
|
130
|
+
}, /*#__PURE__*/React.createElement(TopBlank, {
|
|
131
|
+
ref: _this.topBlankRef,
|
|
132
|
+
height: topBlank
|
|
133
|
+
}), /*#__PURE__*/React.createElement(HtmlTable, {
|
|
131
134
|
tbodyHtmlTag: "tbody",
|
|
132
135
|
getRowProps: getRowProps,
|
|
133
136
|
primaryKey: primaryKey,
|
|
@@ -139,13 +142,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
139
142
|
limit: bottomIndex,
|
|
140
143
|
last: dataSource.length - 1
|
|
141
144
|
}
|
|
142
|
-
}),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
height: bottomBlank
|
|
147
|
-
}
|
|
148
|
-
}))));
|
|
145
|
+
}), /*#__PURE__*/React.createElement(BottomBlank, {
|
|
146
|
+
ref: _this.bottomBlankRef,
|
|
147
|
+
height: bottomBlank
|
|
148
|
+
})));
|
|
149
149
|
};
|
|
150
150
|
_this.state = {
|
|
151
151
|
hasScroll: true,
|
|
@@ -159,11 +159,30 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
159
159
|
maxRenderHeight: 600,
|
|
160
160
|
maxRenderWidth: 800
|
|
161
161
|
};
|
|
162
|
+
// 初始化快速滚动管理器
|
|
163
|
+
var fastScrollCallbacks = {
|
|
164
|
+
onFastScrollStart: function onFastScrollStart(renderData) {
|
|
165
|
+
_this.setState({
|
|
166
|
+
previousRenderData: renderData
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
onFastScrollEnd: function onFastScrollEnd(scrollData) {
|
|
170
|
+
_this.setState({
|
|
171
|
+
previousRenderData: undefined,
|
|
172
|
+
offsetY: scrollData.offsetY,
|
|
173
|
+
maxRenderHeight: scrollData.maxRenderHeight,
|
|
174
|
+
maxRenderWidth: scrollData.maxRenderWidth
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
getCurrentRenderRange: function getCurrentRenderRange(offsetY, maxRenderHeight, dataLength) {
|
|
178
|
+
return _this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, dataLength);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
_this.fastScrollManager = new FastScrollManager(fastScrollCallbacks);
|
|
162
182
|
return _this;
|
|
163
183
|
}
|
|
164
184
|
/** @deprecated BaseTable.getDoms() 已经过时,请勿调用 */
|
|
165
|
-
|
|
166
|
-
return _createClass(BaseTable, [{
|
|
185
|
+
_createClass(BaseTable, [{
|
|
167
186
|
key: "getDoms",
|
|
168
187
|
value: function getDoms() {
|
|
169
188
|
console.warn('[kd-table] BaseTable.getDoms() 已经过时');
|
|
@@ -305,11 +324,18 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
305
324
|
}, {
|
|
306
325
|
key: "getVerticalRenderRange",
|
|
307
326
|
value: function getVerticalRenderRange(useVirtual) {
|
|
308
|
-
var
|
|
327
|
+
var _this$props4 = this.props,
|
|
328
|
+
dataSource = _this$props4.dataSource,
|
|
329
|
+
isLowPerformance = _this$props4.isLowPerformance;
|
|
309
330
|
var _this$state = this.state,
|
|
310
331
|
offsetY = _this$state.offsetY,
|
|
311
|
-
maxRenderHeight = _this$state.maxRenderHeight
|
|
332
|
+
maxRenderHeight = _this$state.maxRenderHeight,
|
|
333
|
+
previousRenderData = _this$state.previousRenderData;
|
|
312
334
|
var rowCount = dataSource.length;
|
|
335
|
+
// 只有在启用快速滚动时才使用 FastScrollManager 的判断
|
|
336
|
+
if (isLowPerformance && this.fastScrollManager.getIsFastScrolling() && (previousRenderData === null || previousRenderData === void 0 ? void 0 : previousRenderData.verticalRenderRange)) {
|
|
337
|
+
return previousRenderData.verticalRenderRange;
|
|
338
|
+
}
|
|
313
339
|
if (useVirtual.vertical) {
|
|
314
340
|
return this.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
315
341
|
} else {
|
|
@@ -320,12 +346,12 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
320
346
|
key: "renderTableFooter",
|
|
321
347
|
value: function renderTableFooter(info) {
|
|
322
348
|
// console.log('render footer')
|
|
323
|
-
var _this$
|
|
324
|
-
_this$
|
|
325
|
-
footerDataSource = _this$
|
|
326
|
-
getRowProps = _this$
|
|
327
|
-
primaryKey = _this$
|
|
328
|
-
stickyBottom = _this$
|
|
349
|
+
var _this$props5 = this.props,
|
|
350
|
+
_this$props5$footerDa = _this$props5.footerDataSource,
|
|
351
|
+
footerDataSource = _this$props5$footerDa === void 0 ? [] : _this$props5$footerDa,
|
|
352
|
+
getRowProps = _this$props5.getRowProps,
|
|
353
|
+
primaryKey = _this$props5.primaryKey,
|
|
354
|
+
stickyBottom = _this$props5.stickyBottom;
|
|
329
355
|
var stickyRightOffset = this.hasScrollY ? this.getScrollBarWidth() : 0;
|
|
330
356
|
var renderFooter = getTableRenderTemplate('footer');
|
|
331
357
|
if (typeof renderFooter === 'function') {
|
|
@@ -390,9 +416,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
390
416
|
key: "renderStickyScroll",
|
|
391
417
|
value: function renderStickyScroll(info) {
|
|
392
418
|
// console.log('render stickyscroll')
|
|
393
|
-
var _this$
|
|
394
|
-
hasStickyScroll = _this$
|
|
395
|
-
stickyBottom = _this$
|
|
419
|
+
var _this$props6 = this.props,
|
|
420
|
+
hasStickyScroll = _this$props6.hasStickyScroll,
|
|
421
|
+
stickyBottom = _this$props6.stickyBottom;
|
|
396
422
|
var hasScroll = this.state.hasScroll;
|
|
397
423
|
var isScroll = hasStickyScroll && hasScroll;
|
|
398
424
|
var stickyScrollContainerStyle = this.getStickyScrollContainerStyle();
|
|
@@ -429,9 +455,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
429
455
|
}, {
|
|
430
456
|
key: "getStickyScrollContainerStyle",
|
|
431
457
|
value: function getStickyScrollContainerStyle() {
|
|
432
|
-
var _this$
|
|
433
|
-
hasStickyScroll = _this$
|
|
434
|
-
stickyScrollHeight = _this$
|
|
458
|
+
var _this$props7 = this.props,
|
|
459
|
+
hasStickyScroll = _this$props7.hasStickyScroll,
|
|
460
|
+
stickyScrollHeight = _this$props7.stickyScrollHeight;
|
|
435
461
|
var hasScroll = this.state.hasScroll;
|
|
436
462
|
var isScroll = hasStickyScroll && hasScroll;
|
|
437
463
|
var height = stickyScrollHeight === 'auto' ? this.getScrollBarWidth() : stickyScrollHeight;
|
|
@@ -445,24 +471,25 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
445
471
|
}, {
|
|
446
472
|
key: "render",
|
|
447
473
|
value: function render() {
|
|
474
|
+
var _cx;
|
|
448
475
|
// console.log('render table')
|
|
449
476
|
var info = calculateRenderInfo(this);
|
|
450
477
|
this.lastInfo = info;
|
|
451
|
-
var _this$
|
|
452
|
-
dataSource = _this$
|
|
453
|
-
className = _this$
|
|
454
|
-
style = _this$
|
|
455
|
-
hasHeader = _this$
|
|
456
|
-
useOuterBorder = _this$
|
|
457
|
-
isStickyHead = _this$
|
|
458
|
-
isStickyHeader = _this$
|
|
459
|
-
isStickyFooter = _this$
|
|
460
|
-
isLoading = _this$
|
|
461
|
-
getTableProps = _this$
|
|
462
|
-
footerDataSource = _this$
|
|
463
|
-
components = _this$
|
|
464
|
-
bordered = _this$
|
|
465
|
-
var artTableWrapperClassName = cx(Classes.artTableWrapper,
|
|
478
|
+
var _this$props8 = this.props,
|
|
479
|
+
dataSource = _this$props8.dataSource,
|
|
480
|
+
className = _this$props8.className,
|
|
481
|
+
style = _this$props8.style,
|
|
482
|
+
hasHeader = _this$props8.hasHeader,
|
|
483
|
+
useOuterBorder = _this$props8.useOuterBorder,
|
|
484
|
+
isStickyHead = _this$props8.isStickyHead,
|
|
485
|
+
isStickyHeader = _this$props8.isStickyHeader,
|
|
486
|
+
isStickyFooter = _this$props8.isStickyFooter,
|
|
487
|
+
isLoading = _this$props8.isLoading,
|
|
488
|
+
getTableProps = _this$props8.getTableProps,
|
|
489
|
+
footerDataSource = _this$props8.footerDataSource,
|
|
490
|
+
components = _this$props8.components,
|
|
491
|
+
bordered = _this$props8.bordered;
|
|
492
|
+
var artTableWrapperClassName = cx(Classes.artTableWrapper, (_cx = {
|
|
466
493
|
'use-outer-border': useOuterBorder,
|
|
467
494
|
empty: dataSource.length === 0,
|
|
468
495
|
lock: info.hasLockColumn,
|
|
@@ -470,7 +497,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
470
497
|
'sticky-header': isStickyHeader !== null && isStickyHeader !== void 0 ? isStickyHeader : isStickyHead,
|
|
471
498
|
'has-footer': footerDataSource.length > 0,
|
|
472
499
|
'sticky-footer': isStickyFooter
|
|
473
|
-
}, Classes.artTableBordered, bordered), 'ie-polyfill-wrapper', browserType.isIE), 'sticky-polyfill-wrapper', isStickyUIDegrade()), className);
|
|
500
|
+
}, _defineProperty(_cx, Classes.artTableBordered, bordered), _defineProperty(_cx, 'ie-polyfill-wrapper', browserType.isIE), _defineProperty(_cx, 'sticky-polyfill-wrapper', isStickyUIDegrade()), _cx), className);
|
|
474
501
|
var artTableWrapperProps = _defineProperty({
|
|
475
502
|
className: artTableWrapperClassName,
|
|
476
503
|
style: style
|
|
@@ -495,10 +522,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
495
522
|
this.initSubscriptions();
|
|
496
523
|
this.didMountOrUpdate();
|
|
497
524
|
// console.log('did mount end')
|
|
498
|
-
var _this$
|
|
499
|
-
cssVariables = _this$
|
|
500
|
-
enableCSSVariables = _this$
|
|
501
|
-
bordered = _this$
|
|
525
|
+
var _this$props9 = this.props,
|
|
526
|
+
cssVariables = _this$props9.cssVariables,
|
|
527
|
+
enableCSSVariables = _this$props9.enableCSSVariables,
|
|
528
|
+
bordered = _this$props9.bordered;
|
|
502
529
|
cssPolifill({
|
|
503
530
|
variables: cssVariables || {},
|
|
504
531
|
enableCSSVariables: enableCSSVariables,
|
|
@@ -513,10 +540,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
513
540
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
514
541
|
var _a;
|
|
515
542
|
// console.log('did update start')
|
|
516
|
-
var _this$
|
|
517
|
-
cssVariables = _this$
|
|
518
|
-
enableCSSVariables = _this$
|
|
519
|
-
bordered = _this$
|
|
543
|
+
var _this$props10 = this.props,
|
|
544
|
+
cssVariables = _this$props10.cssVariables,
|
|
545
|
+
enableCSSVariables = _this$props10.enableCSSVariables,
|
|
546
|
+
bordered = _this$props10.bordered;
|
|
520
547
|
if (!shallowEqual(prevProps === null || prevProps === void 0 ? void 0 : prevProps.cssVariables, (_a = this.props) === null || _a === void 0 ? void 0 : _a.cssVariables)) {
|
|
521
548
|
cssPolifill({
|
|
522
549
|
variables: cssVariables || {},
|
|
@@ -532,10 +559,13 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
532
559
|
}, {
|
|
533
560
|
key: "didMountOrUpdate",
|
|
534
561
|
value: function didMountOrUpdate(prevProps, prevState) {
|
|
535
|
-
this
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
562
|
+
var _this2 = this;
|
|
563
|
+
window.requestAnimationFrame(function () {
|
|
564
|
+
_this2.syncHorizontalScrollFromTableBody();
|
|
565
|
+
_this2.updateStickyScroll();
|
|
566
|
+
_this2.adjustNeedRenderLock();
|
|
567
|
+
_this2.updateRowHeightManager();
|
|
568
|
+
});
|
|
539
569
|
this.updateScrollLeftWhenLayoutChanged(prevProps, prevState);
|
|
540
570
|
}
|
|
541
571
|
}, {
|
|
@@ -557,25 +587,25 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
557
587
|
}, {
|
|
558
588
|
key: "initSubscriptions",
|
|
559
589
|
value: function initSubscriptions() {
|
|
560
|
-
var
|
|
590
|
+
var _this3 = this;
|
|
561
591
|
var _this$domHelper2 = this.domHelper,
|
|
562
592
|
virtual = _this$domHelper2.virtual,
|
|
563
593
|
stickyScroll = _this$domHelper2.stickyScroll;
|
|
564
594
|
this.rootSubscription.add(throttledWindowResize$.subscribe(function () {
|
|
565
|
-
|
|
566
|
-
|
|
595
|
+
_this3.updateStickyScroll();
|
|
596
|
+
_this3.adjustNeedRenderLock();
|
|
567
597
|
}));
|
|
568
598
|
this.resizeSubject.pipe(op.debounceTime(100)).subscribe(function () {
|
|
569
599
|
var _a, _b;
|
|
570
|
-
(_b = (_a =
|
|
600
|
+
(_b = (_a = _this3.props).setTableWidth) === null || _b === void 0 ? void 0 : _b.call(_a, _this3.domHelper.tableBody.clientWidth);
|
|
571
601
|
});
|
|
572
602
|
var handleTableWrapperResize = function handleTableWrapperResize() {
|
|
573
|
-
|
|
603
|
+
_this3.resizeSubject.next();
|
|
574
604
|
};
|
|
575
605
|
this.resizeObserver = addResizeObserver(this.domHelper.artTableWrapper, handleTableWrapperResize);
|
|
576
606
|
// 滚动同步
|
|
577
607
|
this.rootSubscription.add(syncScrollLeft([getTableScrollHeaderDOM(this.domHelper), virtual, getTableScrollFooterDOM(this.domHelper), stickyScroll], function (scrollLeft) {
|
|
578
|
-
|
|
608
|
+
_this3.syncHorizontalScroll(scrollLeft);
|
|
579
609
|
}));
|
|
580
610
|
var richVisibleRects$ = getRichVisibleRectsStream(this.domHelper.virtual, this.props$.pipe(op.skip(1), op.mapTo('structure-may-change')), this.props.virtualDebugLabel).pipe(op.shareReplay());
|
|
581
611
|
// 每当可见部分发生变化的时候,调整 loading icon 的未知(如果 loading icon 存在的话)
|
|
@@ -589,7 +619,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
589
619
|
}))]).subscribe(function (_ref3) {
|
|
590
620
|
var _ref4 = _slicedToArray(_ref3, 1),
|
|
591
621
|
clipRect = _ref4[0];
|
|
592
|
-
var loadingIndicator =
|
|
622
|
+
var loadingIndicator = _this3.domHelper.getLoadingIndicator();
|
|
593
623
|
if (!loadingIndicator) {
|
|
594
624
|
return;
|
|
595
625
|
}
|
|
@@ -600,9 +630,9 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
600
630
|
}));
|
|
601
631
|
// 每当可见部分发生变化的时候,如果开启了虚拟滚动,则重新触发 render
|
|
602
632
|
this.rootSubscription.add(richVisibleRects$.pipe(op.filter(function () {
|
|
603
|
-
var
|
|
604
|
-
horizontal =
|
|
605
|
-
vertical =
|
|
633
|
+
var _this3$lastInfo$useVi = _this3.lastInfo.useVirtual,
|
|
634
|
+
horizontal = _this3$lastInfo$useVi.horizontal,
|
|
635
|
+
vertical = _this3$lastInfo$useVi.vertical;
|
|
606
636
|
return horizontal || vertical;
|
|
607
637
|
}), op.map(function (_ref5) {
|
|
608
638
|
var clipRect = _ref5.clipRect,
|
|
@@ -619,8 +649,29 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
619
649
|
}
|
|
620
650
|
// 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
|
|
621
651
|
return Math.abs(x.maxRenderWidth - y.maxRenderWidth) < OVERSCAN_SIZE / 2 && Math.abs(x.maxRenderHeight - y.maxRenderHeight) < OVERSCAN_SIZE / 2 && Math.abs(x.offsetY - y.offsetY) < OVERSCAN_SIZE / 2;
|
|
652
|
+
}),
|
|
653
|
+
// 快速滚动检测和处理
|
|
654
|
+
op.tap(function (sizeAndOffset) {
|
|
655
|
+
// 只有在启用快速滚动时才使用 FastScrollManager 处理滚动事件
|
|
656
|
+
if (_this3.props.isLowPerformance) {
|
|
657
|
+
_this3.fastScrollManager.handleScrollEvent(sizeAndOffset, {
|
|
658
|
+
offsetY: _this3.state.offsetY,
|
|
659
|
+
maxRenderHeight: _this3.state.maxRenderHeight,
|
|
660
|
+
maxRenderWidth: _this3.state.maxRenderWidth
|
|
661
|
+
}, _this3.props.dataSource.length, _this3.domHelper.virtual.scrollHeight);
|
|
662
|
+
}
|
|
622
663
|
})).subscribe(function (sizeAndOffset) {
|
|
623
|
-
|
|
664
|
+
var _a, _b;
|
|
665
|
+
// 正常滚动时也需要实时更新 blank 高度,确保缓慢滚动时的视觉连续性
|
|
666
|
+
var currentRange = _this3.rowHeightManager.getRenderRange(sizeAndOffset.offsetY, sizeAndOffset.maxRenderHeight, _this3.props.dataSource.length);
|
|
667
|
+
// 直接更新 DOM,避免等待下次渲染
|
|
668
|
+
(_a = _this3.topBlankRef.current) === null || _a === void 0 ? void 0 : _a.updateHeight(currentRange.topBlank);
|
|
669
|
+
(_b = _this3.bottomBlankRef.current) === null || _b === void 0 ? void 0 : _b.updateHeight(currentRange.bottomBlank);
|
|
670
|
+
// 只有在启用快速滚动时才检查快速滚动状态
|
|
671
|
+
if (_this3.props.isLowPerformance && _this3.fastScrollManager.getIsFastScrolling()) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
_this3.setState(sizeAndOffset);
|
|
624
675
|
}));
|
|
625
676
|
this.rootSubscription.add(richVisibleRects$.pipe(op.map(function (_ref6) {
|
|
626
677
|
var clipRect = _ref6.clipRect,
|
|
@@ -638,13 +689,13 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
638
689
|
var _a;
|
|
639
690
|
var offsetY = sizeAndOffset.offsetY,
|
|
640
691
|
maxRenderHeight = sizeAndOffset.maxRenderHeight;
|
|
641
|
-
var scrollDirection = offsetY -
|
|
642
|
-
|
|
643
|
-
var rowCount =
|
|
644
|
-
var vertical =
|
|
692
|
+
var scrollDirection = offsetY - _this3.offsetY >= 0 ? 'down' : 'up';
|
|
693
|
+
_this3.offsetY = offsetY;
|
|
694
|
+
var rowCount = _this3.props.dataSource.length;
|
|
695
|
+
var vertical = _this3.rowHeightManager.getRenderRange(offsetY, maxRenderHeight, rowCount);
|
|
645
696
|
var topIndex = vertical.topIndex,
|
|
646
697
|
bottomIndex = vertical.bottomIndex;
|
|
647
|
-
var blockSize = ((_a =
|
|
698
|
+
var blockSize = ((_a = _this3.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.blockSize) || 200;
|
|
648
699
|
var topBlockStartIndex = Math.floor(Math.max(topIndex - 1, 0) / blockSize) * blockSize;
|
|
649
700
|
var bottomBlockStartIndex = Math.floor((bottomIndex + 1) / blockSize) * blockSize;
|
|
650
701
|
return scrollDirection === 'down' ? [topBlockStartIndex, bottomBlockStartIndex] : [bottomBlockStartIndex, topBlockStartIndex];
|
|
@@ -659,7 +710,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
659
710
|
// 过滤掉重复掉值
|
|
660
711
|
op.distinctUntilChanged()).subscribe(function (startIndex) {
|
|
661
712
|
var _a;
|
|
662
|
-
(_a =
|
|
713
|
+
(_a = _this3.props.scrollLoad) === null || _a === void 0 ? void 0 : _a.callback(startIndex);
|
|
663
714
|
}));
|
|
664
715
|
}
|
|
665
716
|
}, {
|
|
@@ -669,6 +720,10 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
669
720
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
670
721
|
this.rootSubscription.unsubscribe();
|
|
671
722
|
this.resizeSubject.unsubscribe();
|
|
723
|
+
// 只有在启用快速滚动时才清理快速滚动管理器
|
|
724
|
+
if (this.props.isLowPerformance) {
|
|
725
|
+
this.fastScrollManager.cleanup();
|
|
726
|
+
}
|
|
672
727
|
}
|
|
673
728
|
/** 更新 DOM 节点的引用,方便其他方法直接操作 DOM */
|
|
674
729
|
}, {
|
|
@@ -750,6 +805,7 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
|
|
|
750
805
|
}
|
|
751
806
|
}
|
|
752
807
|
}]);
|
|
808
|
+
return BaseTable;
|
|
753
809
|
}(React.Component);
|
|
754
810
|
BaseTable.defaultProps = {
|
|
755
811
|
hasHeader: true,
|
|
@@ -762,6 +818,7 @@ BaseTable.defaultProps = {
|
|
|
762
818
|
stickyScrollHeight: 'auto',
|
|
763
819
|
useVirtual: 'auto',
|
|
764
820
|
estimatedRowHeight: 48,
|
|
821
|
+
isLowPerformance: false,
|
|
765
822
|
isLoading: false,
|
|
766
823
|
components: {},
|
|
767
824
|
getTableProps: noop,
|
package/es/table/base/utils.js
CHANGED
|
@@ -4,9 +4,9 @@ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
|
4
4
|
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
5
|
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
6
6
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
7
|
-
function _createForOfIteratorHelper(
|
|
8
|
-
function _unsupportedIterableToArray(
|
|
9
|
-
function _arrayLikeToArray(
|
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
10
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
11
11
|
import _Object$is from "@babel/runtime-corejs3/core-js-stable/object/is";
|
|
12
12
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
@@ -216,6 +216,7 @@ export function columnDrag() {
|
|
|
216
216
|
e.stopPropagation(); // 存在移动就阻止冒泡
|
|
217
217
|
currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
|
|
218
218
|
}
|
|
219
|
+
|
|
219
220
|
window.requestAnimationFrame(function () {
|
|
220
221
|
// 取消阻止列头点击事件
|
|
221
222
|
currentTarget.removeEventListener('click', stopClickPropagation);
|