@rainbow-oh/yee-c 0.8.14 → 0.8.16
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/cjs/Progress/circle.js +1 -1
- package/dist/cjs/Progress/line.js +1 -1
- package/dist/cjs/Progress/progress.js +2 -0
- package/dist/cjs/Progress/steps.js +1 -1
- package/dist/cjs/Search/search.js +45 -16
- package/dist/cjs/Select/interface.d.ts +2 -1
- package/dist/cjs/Spin/demo/types.js +1 -1
- package/dist/cjs/Spin/indicator.d.ts +1 -1
- package/dist/cjs/Spin/indicator.js +144 -0
- package/dist/cjs/Spin/interface.d.ts +1 -1
- package/dist/cjs/Spin/style/index.less +86 -0
- package/dist/cjs/Table/demo/fixed.d.ts +3 -0
- package/dist/cjs/Table/demo/fixed.js +123 -0
- package/dist/cjs/Table/hooks/useColumns.d.ts +2 -1
- package/dist/cjs/Table/hooks/useColumns.js +4 -3
- package/dist/cjs/Table/style/index.less +23 -3
- package/dist/cjs/Table/table.js +67 -21
- package/dist/cjs/Table/util/index.d.ts +1 -1
- package/dist/cjs/Table/util/index.js +16 -3
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Progress/circle.js +2 -1
- package/dist/esm/Progress/line.js +2 -1
- package/dist/esm/Progress/progress.js +2 -0
- package/dist/esm/Progress/steps.js +6 -1
- package/dist/esm/Search/search.js +31 -7
- package/dist/esm/Select/interface.d.ts +2 -1
- package/dist/esm/Spin/demo/types.js +10 -7
- package/dist/esm/Spin/indicator.d.ts +1 -1
- package/dist/esm/Spin/indicator.js +137 -0
- package/dist/esm/Spin/interface.d.ts +1 -1
- package/dist/esm/Spin/style/index.less +86 -0
- package/dist/esm/Table/demo/fixed.d.ts +3 -0
- package/dist/esm/Table/demo/fixed.js +84 -0
- package/dist/esm/Table/hooks/useColumns.d.ts +2 -1
- package/dist/esm/Table/hooks/useColumns.js +4 -3
- package/dist/esm/Table/style/index.less +23 -3
- package/dist/esm/Table/table.js +85 -26
- package/dist/esm/Table/util/index.d.ts +1 -1
- package/dist/esm/Table/util/index.js +16 -3
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Progress/circle.tsx +1 -1
- package/src/Progress/line.tsx +1 -1
- package/src/Progress/progress.tsx +2 -0
- package/src/Progress/steps.tsx +3 -1
- package/src/Search/search.tsx +33 -4
- package/src/Select/interface.ts +2 -1
- package/src/Spin/demo/types.tsx +18 -3
- package/src/Spin/index.en-US.md +5 -2
- package/src/Spin/index.zh-CN.md +5 -2
- package/src/Spin/indicator.tsx +165 -1
- package/src/Spin/interface.ts +1 -1
- package/src/Spin/style/index.less +86 -0
- package/src/Table/demo/fixed.tsx +92 -0
- package/src/Table/hooks/useColumns.ts +4 -2
- package/src/Table/index.en-US.md +1 -0
- package/src/Table/index.zh-CN.md +1 -0
- package/src/Table/style/index.less +23 -3
- package/src/Table/table.tsx +88 -23
- package/src/Table/util/index.ts +32 -7
- package/src/version.ts +1 -1
|
@@ -69,6 +69,64 @@
|
|
|
69
69
|
animation: yee-spin-spokes-fade 1.2s linear infinite;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
&-bounce {
|
|
74
|
+
@{pls}-bounce {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
gap: 3px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@{pls}-bounce-dot {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
background-color: var(--m-indicator-dot-bg-color);
|
|
86
|
+
border-radius: 50%;
|
|
87
|
+
animation: yee-spin-bounce 0.6s ease-in-out infinite alternate;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&-pulse {
|
|
92
|
+
@{pls}-pulse-circle {
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: 0;
|
|
95
|
+
left: 0;
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
border-radius: 50%;
|
|
99
|
+
background-color: var(--m-indicator-dot-bg-color);
|
|
100
|
+
opacity: 0.6;
|
|
101
|
+
animation: yee-spin-pulse 1.5s ease-in-out infinite;
|
|
102
|
+
|
|
103
|
+
&-delay {
|
|
104
|
+
animation-delay: 0.5s;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&-wheel {
|
|
110
|
+
@{pls}-wheel-hub {
|
|
111
|
+
display: none;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@{pls}-wheel-spokes {
|
|
115
|
+
position: relative;
|
|
116
|
+
width: 100%;
|
|
117
|
+
height: 100%;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@{pls}-wheel-spoke {
|
|
121
|
+
position: absolute;
|
|
122
|
+
left: 50%;
|
|
123
|
+
width: 2px;
|
|
124
|
+
margin-left: -1px;
|
|
125
|
+
background-color: var(--m-indicator-dot-bg-color);
|
|
126
|
+
border-radius: 1px;
|
|
127
|
+
animation: yee-spin-spokes-fade 1.2s linear infinite;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
72
130
|
}
|
|
73
131
|
|
|
74
132
|
&-tip {
|
|
@@ -168,3 +226,31 @@
|
|
|
168
226
|
opacity: 0.15;
|
|
169
227
|
}
|
|
170
228
|
}
|
|
229
|
+
|
|
230
|
+
@keyframes yee-spin-bounce {
|
|
231
|
+
0% {
|
|
232
|
+
transform: translateY(25%);
|
|
233
|
+
opacity: 0.4;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
100% {
|
|
237
|
+
transform: translateY(-25%);
|
|
238
|
+
opacity: 1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@keyframes yee-spin-pulse {
|
|
243
|
+
0% {
|
|
244
|
+
transform: scale(0);
|
|
245
|
+
opacity: 0.6;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
50% {
|
|
249
|
+
opacity: 0.3;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
100% {
|
|
253
|
+
transform: scale(1);
|
|
254
|
+
opacity: 0;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Table } from "../..";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var columns = [{
|
|
4
|
+
title: 'Name',
|
|
5
|
+
dataIndex: 'name',
|
|
6
|
+
key: 'name',
|
|
7
|
+
fixed: 'left',
|
|
8
|
+
width: 140
|
|
9
|
+
}, {
|
|
10
|
+
title: 'Age',
|
|
11
|
+
dataIndex: 'age',
|
|
12
|
+
key: 'age',
|
|
13
|
+
fixed: 'left',
|
|
14
|
+
width: 100
|
|
15
|
+
}, {
|
|
16
|
+
title: 'Address',
|
|
17
|
+
dataIndex: 'address',
|
|
18
|
+
key: 'address',
|
|
19
|
+
width: 240
|
|
20
|
+
}, {
|
|
21
|
+
title: 'Company',
|
|
22
|
+
dataIndex: 'company',
|
|
23
|
+
key: 'company',
|
|
24
|
+
width: 180
|
|
25
|
+
}, {
|
|
26
|
+
title: 'Department',
|
|
27
|
+
dataIndex: 'department',
|
|
28
|
+
key: 'department',
|
|
29
|
+
width: 180
|
|
30
|
+
}, {
|
|
31
|
+
title: 'Email',
|
|
32
|
+
dataIndex: 'email',
|
|
33
|
+
key: 'email',
|
|
34
|
+
width: 240
|
|
35
|
+
}, {
|
|
36
|
+
title: 'Action',
|
|
37
|
+
key: 'action',
|
|
38
|
+
fixed: 'right',
|
|
39
|
+
width: 100,
|
|
40
|
+
render: function render(record) {
|
|
41
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
42
|
+
onClick: function onClick() {
|
|
43
|
+
return console.log(record);
|
|
44
|
+
}
|
|
45
|
+
}, "View");
|
|
46
|
+
}
|
|
47
|
+
}];
|
|
48
|
+
var dataSource = [{
|
|
49
|
+
key: '1',
|
|
50
|
+
name: 'John Brown',
|
|
51
|
+
age: 32,
|
|
52
|
+
address: 'New York No. 1 Lake Park',
|
|
53
|
+
company: 'Acme Inc.',
|
|
54
|
+
department: 'Engineering',
|
|
55
|
+
email: 'john.brown@example.com'
|
|
56
|
+
}, {
|
|
57
|
+
key: '2',
|
|
58
|
+
name: 'Jim Green',
|
|
59
|
+
age: 42,
|
|
60
|
+
address: 'London No. 1 Lake Park',
|
|
61
|
+
company: 'Globex',
|
|
62
|
+
department: 'Marketing',
|
|
63
|
+
email: 'jim.green@example.com'
|
|
64
|
+
}, {
|
|
65
|
+
key: '3',
|
|
66
|
+
name: 'Joe Black',
|
|
67
|
+
age: 28,
|
|
68
|
+
address: 'Sidney No. 1 Lake Park',
|
|
69
|
+
company: 'Initech',
|
|
70
|
+
department: 'Product',
|
|
71
|
+
email: 'joe.black@example.com'
|
|
72
|
+
}];
|
|
73
|
+
export default (function () {
|
|
74
|
+
return /*#__PURE__*/React.createElement(Table, {
|
|
75
|
+
columns: columns,
|
|
76
|
+
dataSource: dataSource,
|
|
77
|
+
rowKey: "key",
|
|
78
|
+
pagination: false,
|
|
79
|
+
scroll: {
|
|
80
|
+
x: 1180
|
|
81
|
+
},
|
|
82
|
+
tableLayout: "fixed"
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ColumnProps, ExpandableType, RowSelectionType, WrapedColumnProps } from '../interface';
|
|
3
|
-
export default function useColumns({ children, columns, rowSelection, expandable, }: {
|
|
3
|
+
export default function useColumns({ children, columns, rowSelection, expandable, measuredColumnWidths, }: {
|
|
4
4
|
children?: React.ReactElement<ColumnProps> | React.ReactElement<ColumnProps>[];
|
|
5
5
|
columns: ColumnProps[];
|
|
6
6
|
rowSelection?: RowSelectionType;
|
|
7
7
|
expandable?: ExpandableType;
|
|
8
|
+
measuredColumnWidths?: number[];
|
|
8
9
|
}): {
|
|
9
10
|
wrapedColumns: WrapedColumnProps[];
|
|
10
11
|
headerRows: import("../interface").HeaderCell[][];
|
|
@@ -21,7 +21,8 @@ export default function useColumns(_ref) {
|
|
|
21
21
|
var children = _ref.children,
|
|
22
22
|
columns = _ref.columns,
|
|
23
23
|
rowSelection = _ref.rowSelection,
|
|
24
|
-
expandable = _ref.expandable
|
|
24
|
+
expandable = _ref.expandable,
|
|
25
|
+
measuredColumnWidths = _ref.measuredColumnWidths;
|
|
25
26
|
var childColumns = useMemo(function () {
|
|
26
27
|
return children ? getColumnsFromChild(children) : null;
|
|
27
28
|
}, [children]);
|
|
@@ -33,13 +34,13 @@ export default function useColumns(_ref) {
|
|
|
33
34
|
var base = deepClone(childColumns || columns || []) || [];
|
|
34
35
|
var tree = injectSelectionExpand(base, rowSelection, expandable);
|
|
35
36
|
var leaves = flattenLeafColumns(tree);
|
|
36
|
-
var wraped = handleColumns(leaves);
|
|
37
|
+
var wraped = handleColumns(leaves, measuredColumnWidths);
|
|
37
38
|
var rows = parseHeaderRows(tree, wraped);
|
|
38
39
|
return {
|
|
39
40
|
wrapedColumns: wraped,
|
|
40
41
|
headerRows: rows
|
|
41
42
|
};
|
|
42
|
-
}, [childColumns, columns, rowSelection, expandable]),
|
|
43
|
+
}, [childColumns, columns, rowSelection, expandable, measuredColumnWidths]),
|
|
43
44
|
wrapedColumns = _useMemo.wrapedColumns,
|
|
44
45
|
headerRows = _useMemo.headerRows;
|
|
45
46
|
return {
|
|
@@ -85,15 +85,34 @@
|
|
|
85
85
|
overflow: auto;
|
|
86
86
|
|
|
87
87
|
&-wrapper {
|
|
88
|
-
overflow: auto;
|
|
89
88
|
width: 100%;
|
|
90
89
|
|
|
91
90
|
&-scroll-left @{pls}-cell-fixed-left-last {
|
|
92
|
-
|
|
91
|
+
&::after {
|
|
92
|
+
content: '';
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
position: absolute;
|
|
95
|
+
display: block;
|
|
96
|
+
height: 100%;
|
|
97
|
+
width: 15px;
|
|
98
|
+
right: -15px;
|
|
99
|
+
top: 0;
|
|
100
|
+
box-shadow: inset 4px 0 8px -4px var(--yee-table-fixed-left-after-bs-color);
|
|
101
|
+
}
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
&-scroll-right @{pls}-cell-fixed-right-first {
|
|
96
|
-
|
|
105
|
+
&::after {
|
|
106
|
+
content: '';
|
|
107
|
+
pointer-events: none;
|
|
108
|
+
position: absolute;
|
|
109
|
+
display: block;
|
|
110
|
+
height: 100%;
|
|
111
|
+
width: 15px;
|
|
112
|
+
left: -15px;
|
|
113
|
+
top: 0;
|
|
114
|
+
box-shadow: inset -4px 0 8px -4px var(--yee-table-fixed-right-after-bs-color);
|
|
115
|
+
}
|
|
97
116
|
}
|
|
98
117
|
}
|
|
99
118
|
|
|
@@ -156,6 +175,7 @@
|
|
|
156
175
|
&-fixed-left,
|
|
157
176
|
&-fixed-right {
|
|
158
177
|
position: sticky;
|
|
178
|
+
z-index: 1;
|
|
159
179
|
background-color: var(--yee-table-fixed-column-bg-color);
|
|
160
180
|
}
|
|
161
181
|
}
|
package/dist/esm/Table/table.js
CHANGED
|
@@ -27,6 +27,7 @@ import TBody from "./tbody";
|
|
|
27
27
|
import TFooter from "./tfooter";
|
|
28
28
|
import THeader from "./theader";
|
|
29
29
|
import { GlobalContext } from "../Config-Provider";
|
|
30
|
+
import useLatest from "../hooks/useLatest";
|
|
30
31
|
import mergeContextToProps from "../utils/mergeContextToProps";
|
|
31
32
|
import omit from "../utils/omit";
|
|
32
33
|
import { pickDataAttrs } from "../utils/types";
|
|
@@ -73,6 +74,10 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
73
74
|
onChange = props.onChange,
|
|
74
75
|
rest = _objectWithoutProperties(props, _excluded);
|
|
75
76
|
var dataAttrs = pickDataAttrs(rest);
|
|
77
|
+
var _React$useState = React.useState(),
|
|
78
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
79
|
+
measuredColumnWidths = _React$useState2[0],
|
|
80
|
+
setMeasuredColumnWidths = _React$useState2[1];
|
|
76
81
|
var getRowKey = React.useCallback(function (record) {
|
|
77
82
|
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : rowKey;
|
|
78
83
|
return typeof key === 'function' ? key(record) : record[key];
|
|
@@ -86,7 +91,8 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
86
91
|
children: children,
|
|
87
92
|
columns: propColumns,
|
|
88
93
|
expandable: expandable,
|
|
89
|
-
rowSelection: rowSelection
|
|
94
|
+
rowSelection: rowSelection,
|
|
95
|
+
measuredColumnWidths: measuredColumnWidths
|
|
90
96
|
}),
|
|
91
97
|
wrapedColumns = _useColumns.wrapedColumns,
|
|
92
98
|
headerRows = _useColumns.headerRows;
|
|
@@ -165,30 +171,70 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
165
171
|
|
|
166
172
|
// Track filter changes to emit onChange after filtered data is recalculated
|
|
167
173
|
var prevFilterRecordsRef = useRef(filterRecords);
|
|
168
|
-
var contentWrapperRef = useRef(null);
|
|
169
174
|
var contentRef = useRef(null);
|
|
170
|
-
var
|
|
175
|
+
var tableRef = useRef(null);
|
|
176
|
+
var _React$useState3 = React.useState({
|
|
171
177
|
left: false,
|
|
172
178
|
right: false
|
|
173
179
|
}),
|
|
174
|
-
_React$
|
|
175
|
-
horizontalScroll = _React$
|
|
176
|
-
setHorizontalScroll = _React$
|
|
180
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
181
|
+
horizontalScroll = _React$useState4[0],
|
|
182
|
+
setHorizontalScroll = _React$useState4[1];
|
|
177
183
|
var updateHorizontalScroll = React.useCallback(function () {
|
|
178
|
-
var wrapper = contentWrapperRef.current;
|
|
179
184
|
var content = contentRef.current;
|
|
180
|
-
if (!
|
|
181
|
-
var
|
|
182
|
-
var maxScrollLeft = scrollContainer.scrollWidth - scrollContainer.clientWidth;
|
|
185
|
+
if (!content) return;
|
|
186
|
+
var maxScrollLeft = content.scrollWidth - content.clientWidth;
|
|
183
187
|
var hasHorizontalScroll = maxScrollLeft > 1;
|
|
184
188
|
var next = {
|
|
185
|
-
left: hasHorizontalScroll &&
|
|
186
|
-
right: hasHorizontalScroll &&
|
|
189
|
+
left: hasHorizontalScroll && content.scrollLeft > 1,
|
|
190
|
+
right: hasHorizontalScroll && content.scrollLeft < maxScrollLeft - 1
|
|
187
191
|
};
|
|
188
192
|
setHorizontalScroll(function (current) {
|
|
189
193
|
return current.left === next.left && current.right === next.right ? current : next;
|
|
190
194
|
});
|
|
191
195
|
}, []);
|
|
196
|
+
|
|
197
|
+
// A primitive signature of everything in the columns that can affect the
|
|
198
|
+
// measured layout, used as an effect dependency instead of the array itself.
|
|
199
|
+
var columnLayoutKey = useMemo(function () {
|
|
200
|
+
return wrapedColumns.map(function (column, index) {
|
|
201
|
+
var _ref2, _column$key, _column$fixed, _column$width;
|
|
202
|
+
return "".concat((_ref2 = (_column$key = column.key) !== null && _column$key !== void 0 ? _column$key : column.dataIndex) !== null && _ref2 !== void 0 ? _ref2 : index, ":").concat((_column$fixed = column.fixed) !== null && _column$fixed !== void 0 ? _column$fixed : '', ":").concat((_column$width = column.width) !== null && _column$width !== void 0 ? _column$width : '');
|
|
203
|
+
}).join('|');
|
|
204
|
+
}, [wrapedColumns]);
|
|
205
|
+
|
|
206
|
+
// Keep the latest columns in a ref so that the measure callback stays stable:
|
|
207
|
+
// `wrapedColumns` is derived from `measuredColumnWidths`, so depending on it
|
|
208
|
+
// directly would recreate the callback (and the ResizeObserver) on every
|
|
209
|
+
// measurement.
|
|
210
|
+
var wrapedColumnsRef = useLatest(wrapedColumns);
|
|
211
|
+
var updateMeasuredColumnWidths = React.useCallback(function () {
|
|
212
|
+
var _tableRef$current;
|
|
213
|
+
var columns = wrapedColumnsRef.current;
|
|
214
|
+
if (!columns.some(function (column) {
|
|
215
|
+
return column.fixed;
|
|
216
|
+
})) return;
|
|
217
|
+
var colElements = (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.querySelectorAll(':scope > colgroup > col');
|
|
218
|
+
if (!colElements || colElements.length !== columns.length) return;
|
|
219
|
+
|
|
220
|
+
// Round to whole pixels: sticky offsets do not need sub-pixel precision,
|
|
221
|
+
// and raw fractional widths would otherwise flip-flop (scrollbar showing /
|
|
222
|
+
// hiding, browser zoom) and keep re-triggering renders.
|
|
223
|
+
var nextWidths = Array.from(colElements, function (column) {
|
|
224
|
+
return Math.round(column.getBoundingClientRect().width);
|
|
225
|
+
});
|
|
226
|
+
if (nextWidths.some(function (width) {
|
|
227
|
+
return !Number.isFinite(width) || width <= 0;
|
|
228
|
+
})) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
setMeasuredColumnWidths(function (current) {
|
|
232
|
+
var unchanged = (current === null || current === void 0 ? void 0 : current.length) === nextWidths.length && current.every(function (width, index) {
|
|
233
|
+
return width === nextWidths[index];
|
|
234
|
+
});
|
|
235
|
+
return unchanged ? current : nextWidths;
|
|
236
|
+
});
|
|
237
|
+
}, [wrapedColumnsRef]);
|
|
192
238
|
useEffect(function () {
|
|
193
239
|
if (prevFilterRecordsRef.current === filterRecords) return;
|
|
194
240
|
prevFilterRecordsRef.current = filterRecords;
|
|
@@ -204,24 +250,37 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
204
250
|
action: 'filter'
|
|
205
251
|
});
|
|
206
252
|
}, [filterRecords, filters, sortedData, pagination, current, pageSize, sorters, onChange]);
|
|
253
|
+
|
|
254
|
+
// Observers are attached once: both callbacks are referentially stable.
|
|
207
255
|
useEffect(function () {
|
|
208
|
-
updateHorizontalScroll();
|
|
209
|
-
var wrapper = contentWrapperRef.current;
|
|
210
256
|
var content = contentRef.current;
|
|
211
|
-
|
|
257
|
+
var tableElement = tableRef.current;
|
|
258
|
+
if (!content || !tableElement) return undefined;
|
|
259
|
+
var handleResize = function handleResize() {
|
|
260
|
+
updateHorizontalScroll();
|
|
261
|
+
updateMeasuredColumnWidths();
|
|
262
|
+
};
|
|
212
263
|
if (typeof ResizeObserver === 'undefined') {
|
|
213
|
-
window.addEventListener('resize',
|
|
264
|
+
window.addEventListener('resize', handleResize);
|
|
214
265
|
return function () {
|
|
215
|
-
return window.removeEventListener('resize',
|
|
266
|
+
return window.removeEventListener('resize', handleResize);
|
|
216
267
|
};
|
|
217
268
|
}
|
|
218
|
-
var resizeObserver = new ResizeObserver(
|
|
219
|
-
resizeObserver.observe(wrapper);
|
|
269
|
+
var resizeObserver = new ResizeObserver(handleResize);
|
|
220
270
|
resizeObserver.observe(content);
|
|
271
|
+
resizeObserver.observe(tableElement);
|
|
221
272
|
return function () {
|
|
222
273
|
return resizeObserver.disconnect();
|
|
223
274
|
};
|
|
224
|
-
}, [updateHorizontalScroll,
|
|
275
|
+
}, [updateHorizontalScroll, updateMeasuredColumnWidths]);
|
|
276
|
+
|
|
277
|
+
// Re-sync when something that can change the layout changes. `columnLayoutKey`
|
|
278
|
+
// is a primitive, so a measurement round-trip (which produces a new
|
|
279
|
+
// `wrapedColumns` array with identical layout config) does not retrigger it.
|
|
280
|
+
useEffect(function () {
|
|
281
|
+
updateHorizontalScroll();
|
|
282
|
+
updateMeasuredColumnWidths();
|
|
283
|
+
}, [columnLayoutKey, pageData, scroll === null || scroll === void 0 ? void 0 : scroll.x, scroll === null || scroll === void 0 ? void 0 : scroll.y, updateHorizontalScroll, updateMeasuredColumnWidths]);
|
|
225
284
|
var renderHeader = function renderHeader() {
|
|
226
285
|
return /*#__PURE__*/React.createElement(Header, {
|
|
227
286
|
prefixCls: prefixCls,
|
|
@@ -269,6 +328,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
269
328
|
var renderTable = function renderTable() {
|
|
270
329
|
var tableProps = {
|
|
271
330
|
style: _objectSpread(_objectSpread({}, styles === null || styles === void 0 ? void 0 : styles.table), {}, {
|
|
331
|
+
minWidth: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
272
332
|
tableLayout: pageData !== null && pageData !== void 0 && pageData.length ? tableLayout : undefined
|
|
273
333
|
}),
|
|
274
334
|
className: clsx(_defineProperty({}, "".concat(prefixCls, "-bordered"), bordered), classNames === null || classNames === void 0 ? void 0 : classNames.table)
|
|
@@ -283,19 +343,18 @@ var Table = /*#__PURE__*/React.forwardRef(function (baseprops, ref) {
|
|
|
283
343
|
locale: locale,
|
|
284
344
|
rowKey: rowKey
|
|
285
345
|
}
|
|
286
|
-
}, /*#__PURE__*/React.createElement("table",
|
|
346
|
+
}, /*#__PURE__*/React.createElement("table", _extends({
|
|
347
|
+
ref: tableRef
|
|
348
|
+
}, tableProps), /*#__PURE__*/React.createElement(ColGroup, {
|
|
287
349
|
columns: wrapedColumns
|
|
288
350
|
}), renderTHeader(), renderTBody(), renderTFooter()));
|
|
289
351
|
return /*#__PURE__*/React.createElement("div", {
|
|
290
|
-
|
|
291
|
-
className: clsx("".concat(prefixCls, "-content-wrapper"), _defineProperty(_defineProperty({}, "".concat(prefixCls, "-content-wrapper-scroll-left"), horizontalScroll.left), "".concat(prefixCls, "-content-wrapper-scroll-right"), horizontalScroll.right)),
|
|
292
|
-
onScroll: updateHorizontalScroll
|
|
352
|
+
className: clsx("".concat(prefixCls, "-content-wrapper"), _defineProperty(_defineProperty({}, "".concat(prefixCls, "-content-wrapper-scroll-left"), horizontalScroll.left), "".concat(prefixCls, "-content-wrapper-scroll-right"), horizontalScroll.right))
|
|
293
353
|
}, /*#__PURE__*/React.createElement("div", {
|
|
294
354
|
ref: contentRef,
|
|
295
355
|
className: clsx("".concat(prefixCls, "-content"), _defineProperty(_defineProperty({}, "".concat(prefixCls, "-").concat(size, "-size"), size), "".concat(prefixCls, "-fixed-header"), scroll === null || scroll === void 0 ? void 0 : scroll.y)),
|
|
296
356
|
style: {
|
|
297
|
-
height: scroll === null || scroll === void 0 ? void 0 : scroll.y
|
|
298
|
-
width: scroll === null || scroll === void 0 ? void 0 : scroll.x
|
|
357
|
+
height: scroll === null || scroll === void 0 ? void 0 : scroll.y
|
|
299
358
|
},
|
|
300
359
|
onScroll: updateHorizontalScroll
|
|
301
360
|
}, table));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WrapedColumnProps } from '../interface';
|
|
2
|
-
export declare function handleColumns(columns: Array<WrapedColumnProps
|
|
2
|
+
export declare function handleColumns(columns: Array<WrapedColumnProps>, measuredColumnWidths?: number[]): WrapedColumnProps[];
|
|
@@ -4,7 +4,20 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
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; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
|
|
7
|
+
var getColumnWidth = function getColumnWidth(column, index, measuredColumnWidths) {
|
|
8
|
+
var measuredWidth = measuredColumnWidths === null || measuredColumnWidths === void 0 ? void 0 : measuredColumnWidths[index];
|
|
9
|
+
if (Number.isFinite(measuredWidth) && measuredWidth && measuredWidth > 0) {
|
|
10
|
+
return measuredWidth;
|
|
11
|
+
}
|
|
12
|
+
if (typeof column.width === 'number') {
|
|
13
|
+
return column.width;
|
|
14
|
+
}
|
|
15
|
+
if (typeof column.width === 'string' && /^\s*\d+(?:\.\d+)?px\s*$/.test(column.width)) {
|
|
16
|
+
return Number.parseFloat(column.width);
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
};
|
|
20
|
+
export function handleColumns(columns, measuredColumnWidths) {
|
|
8
21
|
var leftWidthCount = 0;
|
|
9
22
|
var rightWidthCount = 0;
|
|
10
23
|
for (var i = 0; i < columns.length; i++) {
|
|
@@ -20,7 +33,7 @@ export function handleColumns(columns) {
|
|
|
20
33
|
if (!nextIsFixedLeft) {
|
|
21
34
|
col.isFixedLeftLast = true;
|
|
22
35
|
}
|
|
23
|
-
leftWidthCount
|
|
36
|
+
leftWidthCount += getColumnWidth(col, i, measuredColumnWidths);
|
|
24
37
|
}
|
|
25
38
|
}
|
|
26
39
|
for (var j = columns.length - 1; j >= 0; j--) {
|
|
@@ -33,7 +46,7 @@ export function handleColumns(columns) {
|
|
|
33
46
|
if (((_columns2 = columns[j - 1]) === null || _columns2 === void 0 ? void 0 : _columns2.fixed) !== 'right') {
|
|
34
47
|
_col.isFixedRightFirst = true;
|
|
35
48
|
}
|
|
36
|
-
rightWidthCount
|
|
49
|
+
rightWidthCount += getColumnWidth(_col, j, measuredColumnWidths);
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
return columns;
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED