@aloudata/aloudata-design 2.15.9 → 2.15.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AldSelect/BaseSelect.js +2 -0
- package/dist/AldSelect/components/Suffix.d.ts +2 -1
- package/dist/AldSelect/components/Suffix.js +3 -2
- package/dist/AldSelect/index.js +7 -2
- package/dist/AldSelect/style/color.less +3 -1
- package/dist/AldSelect/style/index.less +0 -1
- package/dist/Checkbox/style/index.less +1 -4
- package/dist/Input/style/status.less +2 -5
- package/dist/InputNumber/style/index.less +2 -2
- package/dist/InputSearch/index.d.ts +1 -0
- package/dist/InputSearch/index.js +36 -8
- package/dist/Table/hooks/useFixed.d.ts +1 -0
- package/dist/Table/hooks/useFixed.js +2 -1
- package/dist/Table/index.js +189 -38
- package/dist/Table/style/index.less +7 -0
- package/dist/ald.min.css +1 -1
- package/package.json +1 -1
|
@@ -97,6 +97,7 @@ var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
97
97
|
var _useContext = useContext(FormItemInputContext),
|
|
98
98
|
contextStatus = _useContext.status;
|
|
99
99
|
var mergedStatus = customStatus || contextStatus || undefined;
|
|
100
|
+
|
|
100
101
|
// =========================== Imperative ===========================
|
|
101
102
|
React.useImperativeHandle(ref, function () {
|
|
102
103
|
return {
|
|
@@ -246,6 +247,7 @@ var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
246
247
|
})))), /*#__PURE__*/React.createElement(Suffix, {
|
|
247
248
|
showArrow: showArrow,
|
|
248
249
|
allowClear: allowClear,
|
|
250
|
+
disabled: disabled,
|
|
249
251
|
isHover: isHover,
|
|
250
252
|
onClear: function onClear() {
|
|
251
253
|
onToggleOpen(false);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DisplayValueType } from '../interface';
|
|
3
|
-
export default function Suffix({ showArrow, allowClear, isActive, isHover, icon, onClear, displayValues, }: {
|
|
3
|
+
export default function Suffix({ showArrow, allowClear, isActive, isHover, icon, onClear, displayValues, disabled, }: {
|
|
4
4
|
showArrow?: boolean;
|
|
5
5
|
allowClear?: boolean;
|
|
6
6
|
isActive?: boolean;
|
|
7
7
|
isHover?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
icon: React.ReactNode;
|
|
9
10
|
onClear?: () => void;
|
|
10
11
|
displayValues: DisplayValueType[];
|
|
@@ -8,9 +8,10 @@ export default function Suffix(_ref) {
|
|
|
8
8
|
isHover = _ref.isHover,
|
|
9
9
|
icon = _ref.icon,
|
|
10
10
|
onClear = _ref.onClear,
|
|
11
|
-
displayValues = _ref.displayValues
|
|
11
|
+
displayValues = _ref.displayValues,
|
|
12
|
+
disabled = _ref.disabled;
|
|
12
13
|
var classNames = prefixCls('select');
|
|
13
|
-
if ((isActive || isHover) && allowClear && displayValues.length > 0) {
|
|
14
|
+
if ((isActive || isHover) && !disabled && allowClear && displayValues.length > 0) {
|
|
14
15
|
return /*#__PURE__*/React.createElement("div", {
|
|
15
16
|
className: classNames('suffix', 'clear'),
|
|
16
17
|
onClick: function onClick(event) {
|
package/dist/AldSelect/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
15
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
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
18
|
+
import React, { forwardRef, useCallback, useContext, useMemo } from 'react';
|
|
19
19
|
import useOptions, { isRawValue } from "./hooks/useOptions";
|
|
20
20
|
import useMergedState from 'rc-util/lib/hooks/useMergedState';
|
|
21
21
|
import { toArray } from "./utils/commonUtil";
|
|
@@ -24,6 +24,7 @@ import BaseSelect, { isMultiple } from "./BaseSelect";
|
|
|
24
24
|
import { injectPropsWithOption } from "./utils/valueUtil";
|
|
25
25
|
import useDisplayMenu from "./hooks/useDisplayMenu";
|
|
26
26
|
import { toString } from "./utils/commonUtil";
|
|
27
|
+
import DisabledContext from 'antd/lib/config-provider/DisabledContext';
|
|
27
28
|
export default /*#__PURE__*/forwardRef(function AldSelect(props, ref) {
|
|
28
29
|
var value = props.value,
|
|
29
30
|
defaultValue = props.defaultValue,
|
|
@@ -37,7 +38,8 @@ export default /*#__PURE__*/forwardRef(function AldSelect(props, ref) {
|
|
|
37
38
|
filterOption = props.filterOption,
|
|
38
39
|
searchValue = props.searchValue,
|
|
39
40
|
optionLabelProp = props.optionLabelProp,
|
|
40
|
-
listHeight = props.listHeight
|
|
41
|
+
listHeight = props.listHeight,
|
|
42
|
+
customDisabled = props.disabled;
|
|
41
43
|
|
|
42
44
|
// =========================== Values ===========================
|
|
43
45
|
var _useMergedState = useMergedState(defaultValue, {
|
|
@@ -46,6 +48,8 @@ export default /*#__PURE__*/forwardRef(function AldSelect(props, ref) {
|
|
|
46
48
|
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
47
49
|
internalValue = _useMergedState2[0],
|
|
48
50
|
setInternalValue = _useMergedState2[1];
|
|
51
|
+
var disabled = useContext(DisabledContext);
|
|
52
|
+
var mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
|
|
49
53
|
var parsedOptions = useOptions({
|
|
50
54
|
menu: menu,
|
|
51
55
|
options: options,
|
|
@@ -228,6 +232,7 @@ export default /*#__PURE__*/forwardRef(function AldSelect(props, ref) {
|
|
|
228
232
|
var displayMenu = useDisplayMenu(selectMenu, filterOption, innerSearchValue);
|
|
229
233
|
return /*#__PURE__*/React.createElement(BaseSelect, _extends({}, props, {
|
|
230
234
|
ref: ref,
|
|
235
|
+
disabled: mergedDisabled,
|
|
231
236
|
displayValues: displayValues,
|
|
232
237
|
onDisplayValuesChange: onDisplayValuesChange,
|
|
233
238
|
setInnerSearchValue: setInnerSearchValue,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
.beta-ald-select {
|
|
2
2
|
border-color: #d1d5db;
|
|
3
3
|
color: #1f2937;
|
|
4
|
+
background-color: #fff;
|
|
4
5
|
|
|
5
6
|
&-active {
|
|
6
7
|
border-color: #007bff;
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
|
|
18
19
|
&-borderless {
|
|
19
20
|
border-color: transparent;
|
|
21
|
+
background-color: transparent;
|
|
20
22
|
color: #111827;
|
|
21
23
|
|
|
22
24
|
&:hover {
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
|
|
33
35
|
&-disabled {
|
|
34
36
|
border: 1px solid #d1d5db;
|
|
35
|
-
background: #
|
|
37
|
+
background: #f3f4f6;
|
|
36
38
|
|
|
37
39
|
&.beta-ald-select-borderless {
|
|
38
40
|
border-color: transparent;
|
|
@@ -31,10 +31,7 @@
|
|
|
31
31
|
--alias-colors-bg-selected-strong-press,
|
|
32
32
|
#0b4385
|
|
33
33
|
);
|
|
34
|
-
@checkbox-checked-inner-bgc-disabled:
|
|
35
|
-
--alias-colors-bg-disabled,
|
|
36
|
-
rgba(0, 0, 0, 0.05)
|
|
37
|
-
);
|
|
34
|
+
@checkbox-checked-inner-bgc-disabled: #f3f4f6;
|
|
38
35
|
|
|
39
36
|
@checkout-border-radius: var(--alias-radius-25);
|
|
40
37
|
|
|
@@ -27,11 +27,8 @@
|
|
|
27
27
|
@input-focus-placeholder-color: var(--alias-colors-text-subtlest, #9ca3af);
|
|
28
28
|
|
|
29
29
|
//color disabled
|
|
30
|
-
@input-disabled-border-color:
|
|
31
|
-
|
|
32
|
-
rgba(0, 0, 0, 0.1)
|
|
33
|
-
);
|
|
34
|
-
@input-disabled-bg-color: var(--alias-colors-bg-transp, rgba(0, 0, 0, 0));
|
|
30
|
+
@input-disabled-border-color: #d1d5db;
|
|
31
|
+
@input-disabled-bg-color: #f3f4f6;
|
|
35
32
|
@input-disabled-text-color: var(
|
|
36
33
|
--alias-colors-text-disabled,
|
|
37
34
|
rgba(0, 0, 0, 0.25)
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
@inputNumber-active-border-color: var(--alias-colors-border-selected, #126fdd);
|
|
30
30
|
|
|
31
31
|
//disable
|
|
32
|
-
@inputNumber-disabled-bg-color:
|
|
33
|
-
@inputNumber-disabled-border-color:
|
|
32
|
+
@inputNumber-disabled-bg-color: #f3f4f6;
|
|
33
|
+
@inputNumber-disabled-border-color: #d1d5db;
|
|
34
34
|
@inputNumber-disabled-color: @NL40;
|
|
35
35
|
//光标颜色
|
|
36
36
|
@inputNumber-cursor-color: @B60;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
export default function InputSearch(props: IProps): React.JSX.Element;
|
|
3
3
|
interface IProps {
|
|
4
4
|
onSearch: (value: string) => void;
|
|
5
|
+
onBlur?: (value: string, e: React.FocusEvent<HTMLInputElement>) => void;
|
|
5
6
|
className?: string;
|
|
6
7
|
debounce?: boolean;
|
|
7
8
|
placeholder?: string;
|
|
@@ -13,7 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import { useDebounceFn } from 'ahooks';
|
|
14
14
|
import classnames from 'classnames';
|
|
15
15
|
import _ from 'lodash';
|
|
16
|
-
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
16
|
+
import React, { useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
17
17
|
import { SearchLine } from "../Icon";
|
|
18
18
|
import Input from "../Input";
|
|
19
19
|
import { ELangType, LocaleContext, getTranslator } from "../locale/default";
|
|
@@ -38,7 +38,8 @@ export default function InputSearch(props) {
|
|
|
38
38
|
defaultValue = props.defaultValue,
|
|
39
39
|
_props$inputMode = props.inputMode,
|
|
40
40
|
inputMode = _props$inputMode === void 0 ? false : _props$inputMode,
|
|
41
|
-
style = props.style
|
|
41
|
+
style = props.style,
|
|
42
|
+
_onBlur = props.onBlur;
|
|
42
43
|
var defaultWidth = useMemo(function () {
|
|
43
44
|
if (size === 'small') {
|
|
44
45
|
if (locale === ELangType.EN) {
|
|
@@ -61,24 +62,44 @@ export default function InputSearch(props) {
|
|
|
61
62
|
_useState2 = _slicedToArray(_useState, 2),
|
|
62
63
|
searchValue = _useState2[0],
|
|
63
64
|
setSearchValue = _useState2[1];
|
|
65
|
+
var isComposing = useRef(false);
|
|
64
66
|
var onPressEnter = useCallback(function (e) {
|
|
65
|
-
|
|
67
|
+
if (!isComposing.current) {
|
|
68
|
+
onSearch(_.trim(e.target.value));
|
|
69
|
+
}
|
|
66
70
|
}, [onSearch]);
|
|
67
71
|
var DEFAULT_DEBOUNCE_TIME = 500;
|
|
68
72
|
var _useDebounceFn = useDebounceFn(function (val) {
|
|
69
|
-
|
|
73
|
+
if (!isComposing.current) {
|
|
74
|
+
onSearch(val);
|
|
75
|
+
}
|
|
70
76
|
}, {
|
|
71
77
|
wait: DEFAULT_DEBOUNCE_TIME
|
|
72
78
|
}),
|
|
73
79
|
debounceSearch = _useDebounceFn.run;
|
|
74
80
|
var onChangeValue = useCallback(function (e) {
|
|
75
81
|
var newValue = e.target.value;
|
|
82
|
+
setSearchValue(newValue);
|
|
83
|
+
if (!isComposing.current) {
|
|
84
|
+
if (debounce) {
|
|
85
|
+
debounceSearch(newValue);
|
|
86
|
+
} else {
|
|
87
|
+
onSearch(newValue);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [debounce, debounceSearch, onSearch]);
|
|
91
|
+
var handleCompositionStart = useCallback(function () {
|
|
92
|
+
isComposing.current = true;
|
|
93
|
+
}, []);
|
|
94
|
+
var handleCompositionEnd = useCallback(function (e) {
|
|
95
|
+
isComposing.current = false;
|
|
96
|
+
// 在输入法结束后触发一次搜索
|
|
97
|
+
var value = e.target.value;
|
|
76
98
|
if (debounce) {
|
|
77
|
-
debounceSearch(
|
|
99
|
+
debounceSearch(value);
|
|
78
100
|
} else {
|
|
79
|
-
onSearch(
|
|
101
|
+
onSearch(value);
|
|
80
102
|
}
|
|
81
|
-
setSearchValue(newValue);
|
|
82
103
|
}, [debounce, debounceSearch, onSearch]);
|
|
83
104
|
var iconSize = useMemo(function () {
|
|
84
105
|
if (size === 'middle' || size === 'large') {
|
|
@@ -99,11 +120,18 @@ export default function InputSearch(props) {
|
|
|
99
120
|
status: 'success',
|
|
100
121
|
onChange: onChangeValue,
|
|
101
122
|
onPressEnter: onPressEnter,
|
|
123
|
+
onCompositionStart: handleCompositionStart,
|
|
124
|
+
onCompositionEnd: handleCompositionEnd,
|
|
102
125
|
prefix: /*#__PURE__*/React.createElement(SearchLine, {
|
|
103
126
|
size: iconSize
|
|
104
127
|
}),
|
|
105
128
|
placeholder: placeholder || t.InputSearch.search,
|
|
106
129
|
allowClear: true,
|
|
107
|
-
defaultValue: defaultValue
|
|
130
|
+
defaultValue: defaultValue,
|
|
131
|
+
onBlur: function onBlur(e) {
|
|
132
|
+
if (_onBlur) {
|
|
133
|
+
_onBlur(searchValue, e);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
108
136
|
}));
|
|
109
137
|
}
|
|
@@ -30,7 +30,8 @@ export default function useFixed(_ref) {
|
|
|
30
30
|
}
|
|
31
31
|
return {
|
|
32
32
|
className: classnames((_classnames = {}, _defineProperty(_classnames, prefixCls('fixed-left'), fixed === 'left'), _defineProperty(_classnames, prefixCls('fixed-right'), fixed === 'right'), _classnames)),
|
|
33
|
-
style: style
|
|
33
|
+
style: style,
|
|
34
|
+
fixed: fixed
|
|
34
35
|
};
|
|
35
36
|
}, [tableColumns, y, scrollbarWidth, columnWidths]);
|
|
36
37
|
}
|
package/dist/Table/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import useScroll from "./hooks/useScroll";
|
|
|
27
27
|
var HEADER_HEIGHT = 41;
|
|
28
28
|
var FOOTER_HEIGHT = 52;
|
|
29
29
|
function Table(props, ref) {
|
|
30
|
-
var
|
|
30
|
+
var _classnames2, _classnames5, _classnames7;
|
|
31
31
|
var data = props.data,
|
|
32
32
|
bordered = props.bordered,
|
|
33
33
|
rowKey = props.rowKey,
|
|
@@ -129,35 +129,121 @@ function Table(props, ref) {
|
|
|
129
129
|
// 总列宽改变时,重新计算是否需要显示固定列的阴影
|
|
130
130
|
changeIsPing();
|
|
131
131
|
}, [changeIsPing, totalColumnsWidth]);
|
|
132
|
+
var renderHeaderCell = useCallback(function (header, index) {
|
|
133
|
+
// 选择行的列不能拖动宽度
|
|
134
|
+
var showResizer = columnSizing && !(!!rowSelectionInfo.isRowSelectionEnabled && index === 0);
|
|
135
|
+
var _getColumnFixedInfo = getColumnFixedInfo(index, true),
|
|
136
|
+
fixedClassName = _getColumnFixedInfo.className,
|
|
137
|
+
fixedStyle = _getColumnFixedInfo.style;
|
|
138
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: classnames(prefixCls('th'), fixedClassName),
|
|
140
|
+
style: _objectSpread({
|
|
141
|
+
width: header.getSize()
|
|
142
|
+
}, fixedStyle),
|
|
143
|
+
key: header.id
|
|
144
|
+
}, flexRender(header.column.columnDef.header, header.getContext()), showResizer && /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
onMouseDown: header.getResizeHandler(),
|
|
146
|
+
onTouchStart: header.getResizeHandler(),
|
|
147
|
+
className: classnames(prefixCls('resizer'), _defineProperty({}, prefixCls('self-resizing'), header.column.getIsResizing()))
|
|
148
|
+
}));
|
|
149
|
+
}, [columnSizing, rowSelectionInfo, getColumnFixedInfo]);
|
|
150
|
+
var visibleColumns = tableInstance.getVisibleLeafColumns();
|
|
151
|
+
var columnVirtualizer = useVirtualizer({
|
|
152
|
+
count: tableColumns.length,
|
|
153
|
+
estimateSize: function estimateSize(index) {
|
|
154
|
+
return visibleColumns[index].getSize();
|
|
155
|
+
},
|
|
156
|
+
getScrollElement: function getScrollElement() {
|
|
157
|
+
return bodyRef.current;
|
|
158
|
+
},
|
|
159
|
+
horizontal: true,
|
|
160
|
+
overscan: 5
|
|
161
|
+
});
|
|
162
|
+
var virtualColumns = columnVirtualizer.getVirtualItems();
|
|
163
|
+
|
|
164
|
+
//different virtualization strategy for columns - instead of absolute and translateY, we add empty columns to the left and right
|
|
165
|
+
var virtualPaddingLeft;
|
|
166
|
+
var virtualPaddingRight;
|
|
167
|
+
if (columnVirtualizer && virtualColumns !== null && virtualColumns !== void 0 && virtualColumns.length) {
|
|
168
|
+
var _virtualColumns$0$sta, _virtualColumns$, _virtualColumns$end, _virtualColumns;
|
|
169
|
+
virtualPaddingLeft = (_virtualColumns$0$sta = (_virtualColumns$ = virtualColumns[0]) === null || _virtualColumns$ === void 0 ? void 0 : _virtualColumns$.start) !== null && _virtualColumns$0$sta !== void 0 ? _virtualColumns$0$sta : 0;
|
|
170
|
+
virtualPaddingRight = columnVirtualizer.getTotalSize() - ((_virtualColumns$end = (_virtualColumns = virtualColumns[virtualColumns.length - 1]) === null || _virtualColumns === void 0 ? void 0 : _virtualColumns.end) !== null && _virtualColumns$end !== void 0 ? _virtualColumns$end : 0);
|
|
171
|
+
}
|
|
132
172
|
var headerContent = /*#__PURE__*/React.createElement("div", {
|
|
133
|
-
className: classnames(prefixCls('header'), (
|
|
173
|
+
className: classnames(prefixCls('header'), (_classnames2 = {}, _defineProperty(_classnames2, prefixCls('overflow-x'), true), _defineProperty(_classnames2, prefixCls('sticky'), isStickyWork), _defineProperty(_classnames2, prefixCls('resizing'), tableInstance.getState().columnSizingInfo.isResizingColumn), _classnames2)),
|
|
134
174
|
ref: headerRef,
|
|
135
175
|
style: headerStyle
|
|
136
176
|
}, _.map(headerGroups, function (headerGroup) {
|
|
177
|
+
var allHeaderCells = headerGroup.headers;
|
|
178
|
+
var virtualColumns = columnVirtualizer.getVirtualItems();
|
|
179
|
+
var middleVirtualColumns = [];
|
|
180
|
+
// 将固定列单独拎出来,固定列不受列虚拟化影响,必须要渲染
|
|
181
|
+
var leftFixedColumns = [];
|
|
182
|
+
var rightFixedColumns = [];
|
|
183
|
+
var content = null;
|
|
184
|
+
if (virtual) {
|
|
185
|
+
_.forEach(allHeaderCells, function (header, index) {
|
|
186
|
+
var fixedInfo = getColumnFixedInfo(index);
|
|
187
|
+
if (fixedInfo.fixed === 'left') {
|
|
188
|
+
leftFixedColumns.push({
|
|
189
|
+
header: header,
|
|
190
|
+
index: index
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (fixedInfo.fixed === 'right') {
|
|
194
|
+
rightFixedColumns.push({
|
|
195
|
+
header: header,
|
|
196
|
+
index: index
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
_.forEach(virtualColumns, function (virtualColumn) {
|
|
201
|
+
var colIndex = virtualColumn.index;
|
|
202
|
+
var fixedInfo = getColumnFixedInfo(colIndex);
|
|
203
|
+
if (fixedInfo.fixed !== 'left' && fixedInfo.fixed !== 'right') {
|
|
204
|
+
middleVirtualColumns.push(virtualColumn);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
content = /*#__PURE__*/React.createElement(React.Fragment, null, virtualPaddingLeft ?
|
|
208
|
+
/*#__PURE__*/
|
|
209
|
+
//fake empty column to the left for virtualization scroll padding
|
|
210
|
+
React.createElement("div", {
|
|
211
|
+
className: prefixCls('virtual-padding-left'),
|
|
212
|
+
style: {
|
|
213
|
+
width: virtualPaddingLeft
|
|
214
|
+
}
|
|
215
|
+
}) : null, leftFixedColumns.map(function (_ref) {
|
|
216
|
+
var header = _ref.header,
|
|
217
|
+
index = _ref.index;
|
|
218
|
+
return renderHeaderCell(header, index);
|
|
219
|
+
}), _.map(middleVirtualColumns, function (virtualColumn) {
|
|
220
|
+
var header = allHeaderCells[virtualColumn.index];
|
|
221
|
+
return renderHeaderCell(header, virtualColumn.index);
|
|
222
|
+
}), rightFixedColumns.map(function (_ref2) {
|
|
223
|
+
var header = _ref2.header,
|
|
224
|
+
index = _ref2.index;
|
|
225
|
+
return renderHeaderCell(header, index);
|
|
226
|
+
}), virtualPaddingRight ?
|
|
227
|
+
/*#__PURE__*/
|
|
228
|
+
//fake empty column to the right for virtualization scroll padding
|
|
229
|
+
React.createElement("div", {
|
|
230
|
+
className: prefixCls('virtual-padding-right'),
|
|
231
|
+
style: {
|
|
232
|
+
width: virtualPaddingRight
|
|
233
|
+
}
|
|
234
|
+
}) : null);
|
|
235
|
+
} else {
|
|
236
|
+
content = _.map(allHeaderCells, function (header, index) {
|
|
237
|
+
return renderHeaderCell(header, index);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
137
240
|
return /*#__PURE__*/React.createElement("div", {
|
|
138
241
|
className: prefixCls('tr'),
|
|
139
242
|
key: headerGroup.id,
|
|
140
243
|
style: {
|
|
141
244
|
width: totalColumnsWidth
|
|
142
245
|
}
|
|
143
|
-
},
|
|
144
|
-
// 选择行的列不能拖动宽度
|
|
145
|
-
var showResizer = columnSizing && !(!!rowSelectionInfo.isRowSelectionEnabled && index === 0);
|
|
146
|
-
var _getColumnFixedInfo = getColumnFixedInfo(index, true),
|
|
147
|
-
fixedClassName = _getColumnFixedInfo.className,
|
|
148
|
-
fixedStyle = _getColumnFixedInfo.style;
|
|
149
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
150
|
-
className: classnames(prefixCls('th'), fixedClassName),
|
|
151
|
-
style: _objectSpread({
|
|
152
|
-
width: header.getSize()
|
|
153
|
-
}, fixedStyle),
|
|
154
|
-
key: header.id
|
|
155
|
-
}, flexRender(header.column.columnDef.header, header.getContext()), showResizer && /*#__PURE__*/React.createElement("div", {
|
|
156
|
-
onMouseDown: header.getResizeHandler(),
|
|
157
|
-
onTouchStart: header.getResizeHandler(),
|
|
158
|
-
className: classnames(prefixCls('resizer'), _defineProperty({}, prefixCls('self-resizing'), header.column.getIsResizing()))
|
|
159
|
-
}));
|
|
160
|
-
}), y !== undefined && /*#__PURE__*/React.createElement("div", {
|
|
246
|
+
}, content, y !== undefined && /*#__PURE__*/React.createElement("div", {
|
|
161
247
|
className: prefixCls('header-scroll-placeholder'),
|
|
162
248
|
style: {
|
|
163
249
|
flexBasis: scrollbarWidth
|
|
@@ -201,6 +287,24 @@ function Table(props, ref) {
|
|
|
201
287
|
overscan: 5
|
|
202
288
|
});
|
|
203
289
|
var tableRows = virtual ? rowVirtualizer.getVirtualItems() : rows;
|
|
290
|
+
var renderBodyCell = useCallback(function (row, cell, colIndex) {
|
|
291
|
+
var _getColumnFixedInfo2 = getColumnFixedInfo(colIndex),
|
|
292
|
+
fixedClassName = _getColumnFixedInfo2.className,
|
|
293
|
+
fixedStyle = _getColumnFixedInfo2.style;
|
|
294
|
+
var tdContent = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
295
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
296
|
+
className: classnames(prefixCls('td'), fixedClassName),
|
|
297
|
+
key: cell.id,
|
|
298
|
+
style: _objectSpread({
|
|
299
|
+
width: cell.column.getSize()
|
|
300
|
+
}, fixedStyle)
|
|
301
|
+
}, expandableInfo.isExpandable && colIndex === 0 ? /*#__PURE__*/React.createElement(ExpandCell, {
|
|
302
|
+
expandableInfo: expandableInfo,
|
|
303
|
+
expandable: expandable,
|
|
304
|
+
data: row.original,
|
|
305
|
+
rowKey: rowKey
|
|
306
|
+
}, tdContent) : tdContent);
|
|
307
|
+
}, [expandableInfo, expandable, rowKey, getColumnFixedInfo]);
|
|
204
308
|
|
|
205
309
|
// 渲染 body
|
|
206
310
|
var bodyContent = /*#__PURE__*/React.createElement("div", {
|
|
@@ -221,6 +325,70 @@ function Table(props, ref) {
|
|
|
221
325
|
}))) : _.reduce(tableRows, function (rowList, rowData, rowIndex) {
|
|
222
326
|
var _classnames4;
|
|
223
327
|
var row = virtual ? rows[rowData.index] : rowData;
|
|
328
|
+
var allRowCells = row.getVisibleCells();
|
|
329
|
+
var content = null;
|
|
330
|
+
// 将固定列单独拎出来,固定列不受列虚拟化影响,必须要渲染
|
|
331
|
+
var leftFixedColumns = [];
|
|
332
|
+
var rightFixedColumns = [];
|
|
333
|
+
if (virtual) {
|
|
334
|
+
var _virtualColumns2 = columnVirtualizer.getVirtualItems();
|
|
335
|
+
var middleVirtualColumns = [];
|
|
336
|
+
_.forEach(allRowCells, function (cell, index) {
|
|
337
|
+
var fixedInfo = getColumnFixedInfo(index);
|
|
338
|
+
if (fixedInfo.fixed === 'left') {
|
|
339
|
+
leftFixedColumns.push({
|
|
340
|
+
cell: cell,
|
|
341
|
+
index: index
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
if (fixedInfo.fixed === 'right') {
|
|
345
|
+
rightFixedColumns.push({
|
|
346
|
+
cell: cell,
|
|
347
|
+
index: index
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
_.forEach(_virtualColumns2, function (virtualColumn) {
|
|
352
|
+
var colIndex = virtualColumn.index;
|
|
353
|
+
var fixedInfo = getColumnFixedInfo(colIndex);
|
|
354
|
+
if (fixedInfo.fixed !== 'left' && fixedInfo.fixed !== 'right') {
|
|
355
|
+
middleVirtualColumns.push(virtualColumn);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
content = /*#__PURE__*/React.createElement(React.Fragment, null, virtualPaddingLeft ?
|
|
359
|
+
/*#__PURE__*/
|
|
360
|
+
//fake empty column to the left for virtualization scroll padding
|
|
361
|
+
React.createElement("div", {
|
|
362
|
+
className: prefixCls('virtual-padding-left'),
|
|
363
|
+
style: {
|
|
364
|
+
width: virtualPaddingLeft
|
|
365
|
+
}
|
|
366
|
+
}) : null, leftFixedColumns.map(function (_ref3) {
|
|
367
|
+
var cell = _ref3.cell,
|
|
368
|
+
index = _ref3.index;
|
|
369
|
+
return renderBodyCell(row, cell, index);
|
|
370
|
+
}), middleVirtualColumns.map(function (virtualColumn) {
|
|
371
|
+
var colIndex = virtualColumn.index;
|
|
372
|
+
var cell = allRowCells[colIndex];
|
|
373
|
+
return renderBodyCell(row, cell, colIndex);
|
|
374
|
+
}), rightFixedColumns.map(function (_ref4) {
|
|
375
|
+
var cell = _ref4.cell,
|
|
376
|
+
index = _ref4.index;
|
|
377
|
+
return renderBodyCell(row, cell, index);
|
|
378
|
+
}), virtualPaddingRight ?
|
|
379
|
+
/*#__PURE__*/
|
|
380
|
+
//fake empty column to the right for virtualization scroll padding
|
|
381
|
+
React.createElement("div", {
|
|
382
|
+
className: prefixCls('virtual-padding-right'),
|
|
383
|
+
style: {
|
|
384
|
+
width: virtualPaddingRight
|
|
385
|
+
}
|
|
386
|
+
}) : null);
|
|
387
|
+
} else {
|
|
388
|
+
content = allRowCells.map(function (cell, index) {
|
|
389
|
+
return renderBodyCell(row, cell, index);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
224
392
|
var rowId = row.id;
|
|
225
393
|
var rowNode = /*#__PURE__*/React.createElement("div", {
|
|
226
394
|
key: rowId,
|
|
@@ -240,24 +408,7 @@ function Table(props, ref) {
|
|
|
240
408
|
position: 'absolute',
|
|
241
409
|
transform: "translateY(".concat(rowData.start, "px)")
|
|
242
410
|
} : {}
|
|
243
|
-
},
|
|
244
|
-
var _getColumnFixedInfo2 = getColumnFixedInfo(colIndex),
|
|
245
|
-
fixedClassName = _getColumnFixedInfo2.className,
|
|
246
|
-
fixedStyle = _getColumnFixedInfo2.style;
|
|
247
|
-
var tdContent = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
248
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
249
|
-
className: classnames(prefixCls('td'), fixedClassName),
|
|
250
|
-
key: cell.id,
|
|
251
|
-
style: _objectSpread({
|
|
252
|
-
width: cell.column.getSize()
|
|
253
|
-
}, fixedStyle)
|
|
254
|
-
}, expandableInfo.isExpandable && colIndex === 0 ? /*#__PURE__*/React.createElement(ExpandCell, {
|
|
255
|
-
expandableInfo: expandableInfo,
|
|
256
|
-
expandable: expandable,
|
|
257
|
-
data: row.original,
|
|
258
|
-
rowKey: rowKey
|
|
259
|
-
}, tdContent) : tdContent);
|
|
260
|
-
}));
|
|
411
|
+
}, content);
|
|
261
412
|
rowList.push(rowNode);
|
|
262
413
|
|
|
263
414
|
// 渲染额外展开的行
|