@aloudata/aloudata-design 2.5.0 → 2.5.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/DataPreviewTable/components/Body/Error.d.ts +1 -2
- package/dist/DataPreviewTable/components/Body/Error.js +5 -7
- package/dist/DataPreviewTable/components/Header/index.d.ts +1 -0
- package/dist/DataPreviewTable/components/Header/index.js +3 -4
- package/dist/DataPreviewTable/index.js +16 -15
- package/dist/DataPreviewTable/interface.d.ts +2 -2
- package/dist/DataPreviewTable/style/index.less +6 -0
- package/dist/Dropdown/index.js +3 -0
- package/dist/Menu/index.d.ts +1 -0
- package/dist/Table/helper.d.ts +6 -4
- package/dist/Table/helper.js +20 -5
- package/dist/Table/hooks/useFixed.d.ts +10 -0
- package/dist/Table/hooks/useFixed.js +56 -0
- package/dist/Table/hooks/useScroll.d.ts +5 -1
- package/dist/Table/hooks/useScroll.js +79 -11
- package/dist/Table/index.js +56 -51
- package/dist/Table/style/index.less +70 -4
- package/dist/Table/types.d.ts +4 -0
- package/dist/ald.min.css +1 -1
- package/package.json +2 -1
package/dist/Table/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -12,15 +14,15 @@ import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-tabl
|
|
|
12
14
|
import classnames from 'classnames';
|
|
13
15
|
import _ from 'lodash';
|
|
14
16
|
import ResizeObserver from 'rc-resize-observer';
|
|
15
|
-
import React, { forwardRef, useCallback, useImperativeHandle, useMemo,
|
|
16
|
-
import { Empty,
|
|
17
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react';
|
|
18
|
+
import { Empty, Spin } from '..';
|
|
17
19
|
import Pagination from "./components/Pagination";
|
|
18
20
|
import { getTableColumns, prefixCls } from "./helper";
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
+
import useFixed from "./hooks/useFixed";
|
|
22
|
+
import useScroll from "./hooks/useScroll";
|
|
21
23
|
var HEADER_HEIGHT = 41;
|
|
22
24
|
function Table(props, ref) {
|
|
23
|
-
var _classnames;
|
|
25
|
+
var _classnames, _classnames5;
|
|
24
26
|
var columns = props.columns,
|
|
25
27
|
data = props.data,
|
|
26
28
|
rowKey = props.rowKey,
|
|
@@ -41,21 +43,24 @@ function Table(props, ref) {
|
|
|
41
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
42
44
|
totalSize = _useState2[0],
|
|
43
45
|
setTotalSize = _useState2[1];
|
|
44
|
-
var tableBodyRef = useRef(null);
|
|
45
46
|
var y = scroll.y;
|
|
46
|
-
var
|
|
47
|
+
var _useScroll = useScroll({
|
|
47
48
|
totalSize: totalSize,
|
|
48
49
|
scroll: scroll
|
|
49
50
|
}),
|
|
50
|
-
realWidth =
|
|
51
|
-
onBodyScroll =
|
|
52
|
-
headerRef =
|
|
51
|
+
realWidth = _useScroll.realWidth,
|
|
52
|
+
onBodyScroll = _useScroll.onBodyScroll,
|
|
53
|
+
headerRef = _useScroll.headerRef,
|
|
54
|
+
bodyRef = _useScroll.bodyRef,
|
|
55
|
+
isPingLeft = _useScroll.isPingLeft,
|
|
56
|
+
isPingRight = _useScroll.isPingRight,
|
|
57
|
+
scrollbarWidth = _useScroll.scrollbarWidth;
|
|
53
58
|
var scrollToFirstRow = useCallback(function () {
|
|
54
|
-
if (!
|
|
59
|
+
if (!bodyRef.current) {
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
}, []);
|
|
62
|
+
bodyRef.current.scrollTop = 0;
|
|
63
|
+
}, [bodyRef]);
|
|
59
64
|
useImperativeHandle(ref, function () {
|
|
60
65
|
return {
|
|
61
66
|
scrollToFirstRow: scrollToFirstRow
|
|
@@ -67,11 +72,15 @@ function Table(props, ref) {
|
|
|
67
72
|
}
|
|
68
73
|
return getTableColumns({
|
|
69
74
|
columns: columns,
|
|
70
|
-
columnSizing: !!columnSizing,
|
|
71
75
|
totalWidth: realWidth,
|
|
72
76
|
onError: onError
|
|
73
77
|
});
|
|
74
|
-
}, [columns, totalSize,
|
|
78
|
+
}, [columns, totalSize, realWidth, onError]);
|
|
79
|
+
var getColumnFixedInfo = useFixed({
|
|
80
|
+
tableColumns: tableColumns,
|
|
81
|
+
y: y,
|
|
82
|
+
scrollbarWidth: scrollbarWidth
|
|
83
|
+
});
|
|
75
84
|
var tableInstance = useReactTable({
|
|
76
85
|
columns: tableColumns,
|
|
77
86
|
data: data,
|
|
@@ -98,26 +107,37 @@ function Table(props, ref) {
|
|
|
98
107
|
headerStyle.top = _.get(sticky, 'offsetHeader', 0);
|
|
99
108
|
}
|
|
100
109
|
var headerContent = /*#__PURE__*/React.createElement("div", {
|
|
101
|
-
className: classnames(prefixCls('header'), (_classnames = {}, _defineProperty(_classnames, prefixCls('
|
|
110
|
+
className: classnames(prefixCls('header'), (_classnames = {}, _defineProperty(_classnames, prefixCls('overflow-x'), true), _defineProperty(_classnames, prefixCls('sticky'), isStickyWork), _classnames)),
|
|
102
111
|
ref: headerRef,
|
|
103
112
|
style: headerStyle
|
|
104
113
|
}, _.map(headerGroups, function (headerGroup) {
|
|
105
114
|
return /*#__PURE__*/React.createElement("div", {
|
|
106
115
|
className: prefixCls('tr'),
|
|
107
|
-
key: headerGroup.id
|
|
108
|
-
|
|
116
|
+
key: headerGroup.id,
|
|
117
|
+
style: {
|
|
118
|
+
width: realWidth
|
|
119
|
+
}
|
|
120
|
+
}, _.map(headerGroup.headers, function (header, index) {
|
|
109
121
|
var _classnames2;
|
|
122
|
+
var _getColumnFixedInfo = getColumnFixedInfo(index, true),
|
|
123
|
+
fixedClassName = _getColumnFixedInfo.className,
|
|
124
|
+
fixedStyle = _getColumnFixedInfo.style;
|
|
110
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: prefixCls('th'),
|
|
112
|
-
style: {
|
|
126
|
+
className: classnames(prefixCls('th'), fixedClassName),
|
|
127
|
+
style: _objectSpread({
|
|
113
128
|
width: header.getSize()
|
|
114
|
-
},
|
|
129
|
+
}, fixedStyle),
|
|
115
130
|
key: header.id
|
|
116
131
|
}, flexRender(header.column.columnDef.header, header.getContext()), columnSizing && /*#__PURE__*/React.createElement("div", {
|
|
117
132
|
onMouseDown: header.getResizeHandler(),
|
|
118
133
|
onTouchStart: header.getResizeHandler(),
|
|
119
134
|
className: classnames(prefixCls('resizer'), (_classnames2 = {}, _defineProperty(_classnames2, prefixCls('self-resizing'), header.column.getIsResizing()), _defineProperty(_classnames2, prefixCls('resizing'), tableInstance.getState().columnSizingInfo.isResizingColumn), _classnames2))
|
|
120
135
|
}));
|
|
136
|
+
}), y !== undefined && /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
className: prefixCls('header-scroll-placeholder'),
|
|
138
|
+
style: {
|
|
139
|
+
flexBasis: scrollbarWidth
|
|
140
|
+
}
|
|
121
141
|
}));
|
|
122
142
|
}));
|
|
123
143
|
var onClickRow = useCallback(function (rowData, rowIndex) {
|
|
@@ -138,7 +158,7 @@ function Table(props, ref) {
|
|
|
138
158
|
var bodyContent = /*#__PURE__*/React.createElement("div", {
|
|
139
159
|
className: prefixCls('body'),
|
|
140
160
|
style: {
|
|
141
|
-
width:
|
|
161
|
+
width: realWidth
|
|
142
162
|
}
|
|
143
163
|
}, rows.length === 0 && !loading ? emptyComponent || /*#__PURE__*/React.createElement("div", {
|
|
144
164
|
className: prefixCls('empty')
|
|
@@ -149,45 +169,30 @@ function Table(props, ref) {
|
|
|
149
169
|
key: row.id,
|
|
150
170
|
className: classnames(prefixCls('tr'), _defineProperty({}, prefixCls('row-hover'), typeof onRowClick === 'function'), rowClassName(row.original, rowIndex)),
|
|
151
171
|
onClick: onClickRow(row.original, rowIndex)
|
|
152
|
-
}, _.map(row.getVisibleCells(), function (cell) {
|
|
172
|
+
}, _.map(row.getVisibleCells(), function (cell, colIndex) {
|
|
173
|
+
var _getColumnFixedInfo2 = getColumnFixedInfo(colIndex),
|
|
174
|
+
fixedClassName = _getColumnFixedInfo2.className,
|
|
175
|
+
fixedStyle = _getColumnFixedInfo2.style;
|
|
153
176
|
return /*#__PURE__*/React.createElement("div", {
|
|
154
|
-
className: prefixCls('td'),
|
|
177
|
+
className: classnames(prefixCls('td'), fixedClassName),
|
|
155
178
|
key: cell.id,
|
|
156
|
-
style: {
|
|
179
|
+
style: _objectSpread({
|
|
157
180
|
width: cell.column.getSize()
|
|
158
|
-
}
|
|
181
|
+
}, fixedStyle)
|
|
159
182
|
}, flexRender(cell.column.columnDef.cell, cell.getContext()));
|
|
160
183
|
}));
|
|
161
184
|
}));
|
|
162
|
-
var tableContent =
|
|
185
|
+
var tableContent = /*#__PURE__*/React.createElement(Spin, {
|
|
163
186
|
spinning: !!loading
|
|
164
187
|
}, /*#__PURE__*/React.createElement("div", {
|
|
165
188
|
className: prefixCls('content')
|
|
166
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
167
|
-
className: prefixCls('header'),
|
|
189
|
+
}, headerContent, /*#__PURE__*/React.createElement("div", {
|
|
168
190
|
style: {
|
|
169
|
-
height: HEADER_HEIGHT
|
|
170
|
-
}
|
|
171
|
-
}, headerContent), /*#__PURE__*/React.createElement("div", {
|
|
172
|
-
style: {
|
|
173
|
-
height: totalSize.height - HEADER_HEIGHT
|
|
191
|
+
height: y && totalSize ? totalSize.height - HEADER_HEIGHT : 'auto'
|
|
174
192
|
},
|
|
175
|
-
className: prefixCls('body-scroll')
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
ref: tableBodyRef
|
|
179
|
-
}, bodyContent)))) : /*#__PURE__*/React.createElement("div", {
|
|
180
|
-
className: prefixCls('content')
|
|
181
|
-
}, !!loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
182
|
-
className: prefixCls('spin-mask')
|
|
183
|
-
}), /*#__PURE__*/React.createElement(Spin, null, /*#__PURE__*/React.createElement("div", {
|
|
184
|
-
className: prefixCls('spin'),
|
|
185
|
-
style: {
|
|
186
|
-
position: 'absolute'
|
|
187
|
-
}
|
|
188
|
-
}))), headerContent, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ScrollArea, {
|
|
189
|
-
onViewportScroll: onBodyScroll,
|
|
190
|
-
ref: tableBodyRef
|
|
193
|
+
className: classnames(prefixCls('body-scroll'), _defineProperty({}, prefixCls('scroll-y'), y !== undefined)),
|
|
194
|
+
ref: bodyRef,
|
|
195
|
+
onScroll: onBodyScroll
|
|
191
196
|
}, bodyContent)));
|
|
192
197
|
var tableStyle = {};
|
|
193
198
|
if (y) {
|
|
@@ -206,7 +211,7 @@ function Table(props, ref) {
|
|
|
206
211
|
});
|
|
207
212
|
}
|
|
208
213
|
}, /*#__PURE__*/React.createElement("div", {
|
|
209
|
-
className: classnames(prefixCls('main'),
|
|
214
|
+
className: classnames(prefixCls('main'), (_classnames5 = {}, _defineProperty(_classnames5, prefixCls('overflow-hidden'), !!y), _defineProperty(_classnames5, prefixCls('ping-left'), isPingLeft), _defineProperty(_classnames5, prefixCls('ping-right'), isPingRight), _classnames5))
|
|
210
215
|
}, tableContent)), /*#__PURE__*/React.createElement(Pagination, {
|
|
211
216
|
pagination: pagination,
|
|
212
217
|
scroll: scroll,
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
@import '../../ScrollArea/style/index.less';
|
|
5
5
|
@import '../../Empty/style/index.less';
|
|
6
6
|
|
|
7
|
+
@header-height: 40px;
|
|
8
|
+
|
|
7
9
|
.ald-table-container {
|
|
8
|
-
position: relative;
|
|
9
10
|
display: flex;
|
|
10
11
|
flex-direction: column;
|
|
11
12
|
width: 100%;
|
|
@@ -22,7 +23,6 @@
|
|
|
22
23
|
display: flex;
|
|
23
24
|
flex-direction: column;
|
|
24
25
|
border-spacing: 0;
|
|
25
|
-
position: relative;
|
|
26
26
|
|
|
27
27
|
.ald-table-spin {
|
|
28
28
|
position: absolute;
|
|
@@ -86,6 +86,55 @@
|
|
|
86
86
|
position: relative;
|
|
87
87
|
border-bottom: 1px solid var(--alias-colors-border-subtle, #f3f4f6);
|
|
88
88
|
flex: 0 0 auto;
|
|
89
|
+
|
|
90
|
+
&.ald-table-fixed-left,
|
|
91
|
+
&.ald-table-fixed-right {
|
|
92
|
+
position: sticky;
|
|
93
|
+
background-color: #fff;
|
|
94
|
+
z-index: 2;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.fixed-left-shadow {
|
|
99
|
+
&::after {
|
|
100
|
+
position: absolute;
|
|
101
|
+
right: 0;
|
|
102
|
+
transform: translateX(100%);
|
|
103
|
+
top: 0;
|
|
104
|
+
bottom: 0;
|
|
105
|
+
width: 30px;
|
|
106
|
+
transition: box-shadow 0.2s;
|
|
107
|
+
content: '';
|
|
108
|
+
pointer-events: none;
|
|
109
|
+
box-shadow: inset 10px 0 8px -8px rgba(5, 5, 5, 0.06);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.fixed-right-shadow {
|
|
114
|
+
&::after {
|
|
115
|
+
position: absolute;
|
|
116
|
+
left: 0;
|
|
117
|
+
transform: translateX(-100%);
|
|
118
|
+
top: 0;
|
|
119
|
+
bottom: 0;
|
|
120
|
+
width: 30px;
|
|
121
|
+
transition: box-shadow 0.2s;
|
|
122
|
+
content: '';
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
box-shadow: inset -10px 0 8px -8px rgba(5, 5, 5, 0.06);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&.ald-table-ping-left {
|
|
129
|
+
.ald-table-fixed-left {
|
|
130
|
+
.fixed-left-shadow();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&.ald-table-ping-right {
|
|
135
|
+
.ald-table-fixed-right {
|
|
136
|
+
.fixed-right-shadow();
|
|
137
|
+
}
|
|
89
138
|
}
|
|
90
139
|
|
|
91
140
|
.ald-table-th {
|
|
@@ -99,7 +148,7 @@
|
|
|
99
148
|
padding-left: var(--alias-spacing-200, 16px);
|
|
100
149
|
font-size: 12px;
|
|
101
150
|
overflow: hidden;
|
|
102
|
-
height:
|
|
151
|
+
height: @header-height;
|
|
103
152
|
display: flex;
|
|
104
153
|
align-items: center;
|
|
105
154
|
}
|
|
@@ -130,7 +179,6 @@
|
|
|
130
179
|
|
|
131
180
|
.ald-table-body {
|
|
132
181
|
min-height: 96px;
|
|
133
|
-
overflow: auto;
|
|
134
182
|
|
|
135
183
|
.ald-table-tr {
|
|
136
184
|
&.ald-table-row-hover:hover {
|
|
@@ -186,8 +234,26 @@
|
|
|
186
234
|
height: 100%;
|
|
187
235
|
}
|
|
188
236
|
|
|
237
|
+
.ald-table-header {
|
|
238
|
+
background-color: #fff;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.ald-table-header-scroll-placeholder {
|
|
242
|
+
height: @header-height;
|
|
243
|
+
position: sticky;
|
|
244
|
+
right: 0;
|
|
245
|
+
background-color: #fff;
|
|
246
|
+
z-index: 2;
|
|
247
|
+
flex: 0 0 auto;
|
|
248
|
+
}
|
|
249
|
+
|
|
189
250
|
.ald-table-body-scroll {
|
|
190
251
|
overflow: auto;
|
|
252
|
+
height: 100%;
|
|
253
|
+
|
|
254
|
+
&.ald-table-scroll-y {
|
|
255
|
+
overflow-y: scroll;
|
|
256
|
+
}
|
|
191
257
|
}
|
|
192
258
|
|
|
193
259
|
.ald-table-empty {
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -39,4 +39,8 @@ export interface ITableColumn<TDataItem = unknown> {
|
|
|
39
39
|
ellipsis?: boolean;
|
|
40
40
|
noPadding?: boolean;
|
|
41
41
|
align?: 'left' | 'center' | 'right';
|
|
42
|
+
fixed?: 'left' | 'right';
|
|
43
|
+
}
|
|
44
|
+
export interface IInnerTableColumn<TDataItem = unknown> extends ITableColumn<TDataItem> {
|
|
45
|
+
columnWidths: number[];
|
|
42
46
|
}
|