@aloudata/aloudata-design 2.13.0 → 2.13.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.
- package/dist/Table/helper.d.ts +1 -1
- package/dist/Table/index.js +37 -4
- package/dist/Table/types.d.ts +1 -0
- package/dist/Tag/index.d.ts +4 -0
- package/dist/Tag/index.js +4 -1
- package/dist/Tag/style/index.less +0 -1
- package/dist/ald.min.css +1 -1
- package/package.json +1 -1
package/dist/Table/helper.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare function getTableColumns<TDataItem extends object>({ columns, con
|
|
|
23
23
|
render?: ((text: any, record: TDataItem, rowIndex: number) => import("react").ReactNode) | undefined;
|
|
24
24
|
ellipsis?: boolean | undefined;
|
|
25
25
|
noPadding?: boolean | undefined;
|
|
26
|
-
align?: "left" | "
|
|
26
|
+
align?: "left" | "center" | "right" | undefined;
|
|
27
27
|
fixed?: "left" | "right" | undefined;
|
|
28
28
|
sortOrder?: "ascend" | "descend" | null | undefined;
|
|
29
29
|
};
|
package/dist/Table/index.js
CHANGED
|
@@ -11,6 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
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; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table';
|
|
14
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
14
15
|
import classnames from 'classnames';
|
|
15
16
|
import _ from 'lodash';
|
|
16
17
|
import ResizeObserver from 'rc-resize-observer';
|
|
@@ -37,6 +38,8 @@ function Table(props, ref) {
|
|
|
37
38
|
_props$scroll = props.scroll,
|
|
38
39
|
scroll = _props$scroll === void 0 ? {} : _props$scroll,
|
|
39
40
|
emptyComponent = props.empty,
|
|
41
|
+
_props$virtual = props.virtual,
|
|
42
|
+
virtual = _props$virtual === void 0 ? false : _props$virtual,
|
|
40
43
|
_props$rowClassName = props.rowClassName,
|
|
41
44
|
rowClassName = _props$rowClassName === void 0 ? function () {
|
|
42
45
|
return '';
|
|
@@ -178,12 +181,29 @@ function Table(props, ref) {
|
|
|
178
181
|
var EMPTY_SMALL_SIZE_HEIGHT = 436;
|
|
179
182
|
var isSmallEmpty = totalSize && totalSize.height < EMPTY_SMALL_SIZE_HEIGHT;
|
|
180
183
|
var isEmpty = rows.length === 0 && !loading;
|
|
184
|
+
var rowVirtualizer = useVirtualizer({
|
|
185
|
+
count: rows.length,
|
|
186
|
+
estimateSize: function estimateSize() {
|
|
187
|
+
return 48;
|
|
188
|
+
},
|
|
189
|
+
// estimate row height for accurate scrollbar dragging
|
|
190
|
+
getScrollElement: function getScrollElement() {
|
|
191
|
+
return bodyRef.current;
|
|
192
|
+
},
|
|
193
|
+
// measure dynamic row height, except in firefox because it measures table border height incorrectly
|
|
194
|
+
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? function (element) {
|
|
195
|
+
return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height;
|
|
196
|
+
} : undefined,
|
|
197
|
+
overscan: 5
|
|
198
|
+
});
|
|
199
|
+
var tableRows = virtual ? rowVirtualizer.getVirtualItems() : rows;
|
|
181
200
|
|
|
182
201
|
// 渲染 body
|
|
183
202
|
var bodyContent = /*#__PURE__*/React.createElement("div", {
|
|
184
203
|
className: prefixCls('body'),
|
|
185
204
|
style: {
|
|
186
|
-
width: totalColumnsWidth
|
|
205
|
+
width: totalColumnsWidth,
|
|
206
|
+
height: virtual ? rowVirtualizer.getTotalSize() : 'auto'
|
|
187
207
|
}
|
|
188
208
|
}, isEmpty ? /*#__PURE__*/React.createElement("div", {
|
|
189
209
|
style: {
|
|
@@ -194,13 +214,22 @@ function Table(props, ref) {
|
|
|
194
214
|
}, /*#__PURE__*/React.createElement(Empty, {
|
|
195
215
|
image: isSmallEmpty ? null : Empty.PRESENTED_IMAGE_SEARCH,
|
|
196
216
|
size: isSmallEmpty ? 'small' : undefined
|
|
197
|
-
}))) : _.reduce(
|
|
217
|
+
}))) : _.reduce(tableRows, function (rowList, rowData, rowIndex) {
|
|
198
218
|
var _classnames4;
|
|
219
|
+
var row = virtual ? rows[rowData.index] : rowData;
|
|
199
220
|
var rowId = row.id;
|
|
200
221
|
var rowNode = /*#__PURE__*/React.createElement("div", {
|
|
201
222
|
key: rowId,
|
|
223
|
+
"data-index": virtual ? rowData.index : rowIndex,
|
|
202
224
|
className: classnames(prefixCls('tr'), (_classnames4 = {}, _defineProperty(_classnames4, prefixCls('row-hover'), typeof onRowClick === 'function'), _defineProperty(_classnames4, prefixCls('no-border-tr'), isShowPagination && rowIndex === rows.length - 1), _classnames4), rowClassName(row.original, rowIndex)),
|
|
203
|
-
|
|
225
|
+
ref: function ref(node) {
|
|
226
|
+
return rowVirtualizer.measureElement(node);
|
|
227
|
+
},
|
|
228
|
+
onClick: onClickRow(row.original, rowIndex),
|
|
229
|
+
style: virtual ? {
|
|
230
|
+
position: 'absolute',
|
|
231
|
+
transform: "translateY(".concat(rowData.start, "px)")
|
|
232
|
+
} : {}
|
|
204
233
|
}, _.map(row.getVisibleCells(), function (cell, colIndex) {
|
|
205
234
|
var _getColumnFixedInfo2 = getColumnFixedInfo(colIndex),
|
|
206
235
|
fixedClassName = _getColumnFixedInfo2.className,
|
|
@@ -244,13 +273,17 @@ function Table(props, ref) {
|
|
|
244
273
|
}
|
|
245
274
|
return rowList;
|
|
246
275
|
}, []));
|
|
276
|
+
var tableContentHeight = useMemo(function () {
|
|
277
|
+
return y && totalSize ? totalSize.height - HEADER_HEIGHT - (isShowFooter ? FOOTER_HEIGHT : 0) : 'auto';
|
|
278
|
+
}, [y, totalSize, isShowFooter]);
|
|
247
279
|
var tableContent = /*#__PURE__*/React.createElement(Spin, {
|
|
248
280
|
spinning: !!loading
|
|
249
281
|
}, /*#__PURE__*/React.createElement("div", {
|
|
250
282
|
className: prefixCls('content')
|
|
251
283
|
}, headerContent, /*#__PURE__*/React.createElement("div", {
|
|
252
284
|
style: {
|
|
253
|
-
height:
|
|
285
|
+
height: tableContentHeight,
|
|
286
|
+
position: virtual ? 'relative' : undefined
|
|
254
287
|
},
|
|
255
288
|
className: classnames(prefixCls('body-scroll'), (_classnames5 = {}, _defineProperty(_classnames5, prefixCls('scroll-y'), y !== undefined), _defineProperty(_classnames5, prefixCls('scroll-hidden'), isEmpty), _classnames5)),
|
|
256
289
|
ref: bodyRef,
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface ITableProps<TDataItem extends object> {
|
|
|
20
20
|
onSort?: (columnKey: string, order: 'ascend' | 'descend' | null) => void;
|
|
21
21
|
rowSelection?: IRowSelection<TDataItem>;
|
|
22
22
|
bordered?: boolean;
|
|
23
|
+
virtual?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export type TRowKey<TDataItem extends object> = string | ((record: TDataItem) => string | number);
|
|
25
26
|
export interface ITableCellErrorInfo {
|
package/dist/Tag/index.d.ts
CHANGED
package/dist/Tag/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export default function Tag(props) {
|
|
|
18
18
|
status = props.status,
|
|
19
19
|
mode = props.mode,
|
|
20
20
|
disabled = props.disabled,
|
|
21
|
+
maxWidth = props.maxWidth,
|
|
21
22
|
className = props.className;
|
|
22
23
|
var tagColor = getColor(color, status);
|
|
23
24
|
var bgColor = mode === 'border' ? '#fff' : convertHexToRGBA(tagColor, mode === 'fill' ? 0.16 : 0.06);
|
|
@@ -33,12 +34,14 @@ export default function Tag(props) {
|
|
|
33
34
|
}
|
|
34
35
|
onClose === null || onClose === void 0 ? void 0 : onClose(e);
|
|
35
36
|
}, [disabled, onClose]);
|
|
37
|
+
var DEFAULT_MAX_WIDTH = 160;
|
|
36
38
|
return /*#__PURE__*/React.createElement("span", {
|
|
37
39
|
className: classNames(prefixCls('container'), (_classNames = {}, _defineProperty(_classNames, prefixCls('small'), size === 'small'), _defineProperty(_classNames, prefixCls('large'), size === 'large'), _defineProperty(_classNames, prefixCls('clickable'), typeof onClick === 'function'), _defineProperty(_classNames, prefixCls('disabled'), disabled), _classNames), className || ''),
|
|
38
40
|
style: {
|
|
39
41
|
backgroundColor: bgColor,
|
|
40
42
|
color: convertHexToRGBA(tagColor, 1),
|
|
41
|
-
borderColor: mode === 'fill' ? 'transparent' : convertHexToRGBA(tagColor, 0.32)
|
|
43
|
+
borderColor: mode === 'fill' ? 'transparent' : convertHexToRGBA(tagColor, 0.32),
|
|
44
|
+
maxWidth: maxWidth || DEFAULT_MAX_WIDTH
|
|
42
45
|
},
|
|
43
46
|
onClick: onTagClick
|
|
44
47
|
}, icon && /*#__PURE__*/React.createElement("span", {
|