@rainbow-oh/yee-c 0.8.15 → 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/Search/search.js +1 -1
- 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/Search/search.js +1 -1
- 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/Search/search.tsx +1 -1
- 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
|
@@ -274,7 +274,7 @@ var Search = import_react.default.forwardRef(
|
|
|
274
274
|
role: "searchbox",
|
|
275
275
|
"aria-autocomplete": hasPopup ? "list" : void 0,
|
|
276
276
|
"aria-controls": hasPopup && open ? listboxId : void 0,
|
|
277
|
-
"aria-activedescendant": hasPopup && open && focusedKey
|
|
277
|
+
"aria-activedescendant": hasPopup && open && focusedKey !== null ? String(focusedKey) : void 0
|
|
278
278
|
})
|
|
279
279
|
),
|
|
280
280
|
loading ? /* @__PURE__ */ import_react.default.createElement(import_Spin.default, { variant: "ring", size: "small", "aria-label": "Loading" }) : renderSuffix()
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Table/demo/fixed.tsx
|
|
30
|
+
var fixed_exports = {};
|
|
31
|
+
__export(fixed_exports, {
|
|
32
|
+
default: () => fixed_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(fixed_exports);
|
|
35
|
+
var import_yee_c = require("../..");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var columns = [
|
|
38
|
+
{
|
|
39
|
+
title: "Name",
|
|
40
|
+
dataIndex: "name",
|
|
41
|
+
key: "name",
|
|
42
|
+
fixed: "left",
|
|
43
|
+
width: 140
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: "Age",
|
|
47
|
+
dataIndex: "age",
|
|
48
|
+
key: "age",
|
|
49
|
+
fixed: "left",
|
|
50
|
+
width: 100
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "Address",
|
|
54
|
+
dataIndex: "address",
|
|
55
|
+
key: "address",
|
|
56
|
+
width: 240
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
title: "Company",
|
|
60
|
+
dataIndex: "company",
|
|
61
|
+
key: "company",
|
|
62
|
+
width: 180
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: "Department",
|
|
66
|
+
dataIndex: "department",
|
|
67
|
+
key: "department",
|
|
68
|
+
width: 180
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: "Email",
|
|
72
|
+
dataIndex: "email",
|
|
73
|
+
key: "email",
|
|
74
|
+
width: 240
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
title: "Action",
|
|
78
|
+
key: "action",
|
|
79
|
+
fixed: "right",
|
|
80
|
+
width: 100,
|
|
81
|
+
render: (record) => /* @__PURE__ */ import_react.default.createElement("a", { onClick: () => console.log(record) }, "View")
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
var dataSource = [
|
|
85
|
+
{
|
|
86
|
+
key: "1",
|
|
87
|
+
name: "John Brown",
|
|
88
|
+
age: 32,
|
|
89
|
+
address: "New York No. 1 Lake Park",
|
|
90
|
+
company: "Acme Inc.",
|
|
91
|
+
department: "Engineering",
|
|
92
|
+
email: "john.brown@example.com"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: "2",
|
|
96
|
+
name: "Jim Green",
|
|
97
|
+
age: 42,
|
|
98
|
+
address: "London No. 1 Lake Park",
|
|
99
|
+
company: "Globex",
|
|
100
|
+
department: "Marketing",
|
|
101
|
+
email: "jim.green@example.com"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: "3",
|
|
105
|
+
name: "Joe Black",
|
|
106
|
+
age: 28,
|
|
107
|
+
address: "Sidney No. 1 Lake Park",
|
|
108
|
+
company: "Initech",
|
|
109
|
+
department: "Product",
|
|
110
|
+
email: "joe.black@example.com"
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
var fixed_default = () => /* @__PURE__ */ import_react.default.createElement(
|
|
114
|
+
import_yee_c.Table,
|
|
115
|
+
{
|
|
116
|
+
columns,
|
|
117
|
+
dataSource,
|
|
118
|
+
rowKey: "key",
|
|
119
|
+
pagination: false,
|
|
120
|
+
scroll: { x: 1180 },
|
|
121
|
+
tableLayout: "fixed"
|
|
122
|
+
}
|
|
123
|
+
);
|
|
@@ -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[][];
|
|
@@ -63,7 +63,8 @@ function useColumns({
|
|
|
63
63
|
children,
|
|
64
64
|
columns,
|
|
65
65
|
rowSelection,
|
|
66
|
-
expandable
|
|
66
|
+
expandable,
|
|
67
|
+
measuredColumnWidths
|
|
67
68
|
}) {
|
|
68
69
|
const childColumns = (0, import_react.useMemo)(() => {
|
|
69
70
|
return children ? getColumnsFromChild(children) : null;
|
|
@@ -72,10 +73,10 @@ function useColumns({
|
|
|
72
73
|
const base = (0, import_deepClone.default)(childColumns || columns || []) || [];
|
|
73
74
|
const tree = (0, import_header.injectSelectionExpand)(base, rowSelection, expandable);
|
|
74
75
|
const leaves = (0, import_header.flattenLeafColumns)(tree);
|
|
75
|
-
const wraped = (0, import_util.handleColumns)(leaves);
|
|
76
|
+
const wraped = (0, import_util.handleColumns)(leaves, measuredColumnWidths);
|
|
76
77
|
const rows = (0, import_header.parseHeaderRows)(tree, wraped);
|
|
77
78
|
return { wrapedColumns: wraped, headerRows: rows };
|
|
78
|
-
}, [childColumns, columns, rowSelection, expandable]);
|
|
79
|
+
}, [childColumns, columns, rowSelection, expandable, measuredColumnWidths]);
|
|
79
80
|
return {
|
|
80
81
|
wrapedColumns,
|
|
81
82
|
headerRows
|
|
@@ -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/cjs/Table/table.js
CHANGED
|
@@ -75,6 +75,7 @@ var import_tbody = __toESM(require("./tbody"));
|
|
|
75
75
|
var import_tfooter = __toESM(require("./tfooter"));
|
|
76
76
|
var import_theader = __toESM(require("./theader"));
|
|
77
77
|
var import_Config_Provider = require("../Config-Provider");
|
|
78
|
+
var import_useLatest = __toESM(require("../hooks/useLatest"));
|
|
78
79
|
var import_mergeContextToProps = __toESM(require("../utils/mergeContextToProps"));
|
|
79
80
|
var import_omit = __toESM(require("../utils/omit"));
|
|
80
81
|
var import_types = require("../utils/types");
|
|
@@ -140,6 +141,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
140
141
|
"onChange"
|
|
141
142
|
]);
|
|
142
143
|
const dataAttrs = (0, import_types.pickDataAttrs)(rest);
|
|
144
|
+
const [measuredColumnWidths, setMeasuredColumnWidths] = import_react.default.useState();
|
|
143
145
|
const getRowKey = import_react.default.useCallback(
|
|
144
146
|
(record, key = rowKey) => {
|
|
145
147
|
return typeof key === "function" ? key(record) : record[key];
|
|
@@ -153,7 +155,8 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
153
155
|
children,
|
|
154
156
|
columns: propColumns,
|
|
155
157
|
expandable,
|
|
156
|
-
rowSelection
|
|
158
|
+
rowSelection,
|
|
159
|
+
measuredColumnWidths
|
|
157
160
|
});
|
|
158
161
|
const {
|
|
159
162
|
data: filteredData,
|
|
@@ -212,28 +215,58 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
212
215
|
onChange: onSelectionChange
|
|
213
216
|
} = (0, import_useSelection.default)({ pageData, dataSource, getRowKey, rowSelection, allKeys });
|
|
214
217
|
const prevFilterRecordsRef = (0, import_react.useRef)(filterRecords);
|
|
215
|
-
const contentWrapperRef = (0, import_react.useRef)(null);
|
|
216
218
|
const contentRef = (0, import_react.useRef)(null);
|
|
219
|
+
const tableRef = (0, import_react.useRef)(null);
|
|
217
220
|
const [horizontalScroll, setHorizontalScroll] = import_react.default.useState({
|
|
218
221
|
left: false,
|
|
219
222
|
right: false
|
|
220
223
|
});
|
|
221
224
|
const updateHorizontalScroll = import_react.default.useCallback(() => {
|
|
222
|
-
const wrapper = contentWrapperRef.current;
|
|
223
225
|
const content = contentRef.current;
|
|
224
|
-
if (!
|
|
226
|
+
if (!content)
|
|
225
227
|
return;
|
|
226
|
-
const
|
|
227
|
-
const maxScrollLeft = scrollContainer.scrollWidth - scrollContainer.clientWidth;
|
|
228
|
+
const maxScrollLeft = content.scrollWidth - content.clientWidth;
|
|
228
229
|
const hasHorizontalScroll = maxScrollLeft > 1;
|
|
229
230
|
const next = {
|
|
230
|
-
left: hasHorizontalScroll &&
|
|
231
|
-
right: hasHorizontalScroll &&
|
|
231
|
+
left: hasHorizontalScroll && content.scrollLeft > 1,
|
|
232
|
+
right: hasHorizontalScroll && content.scrollLeft < maxScrollLeft - 1
|
|
232
233
|
};
|
|
233
234
|
setHorizontalScroll(
|
|
234
235
|
(current2) => current2.left === next.left && current2.right === next.right ? current2 : next
|
|
235
236
|
);
|
|
236
237
|
}, []);
|
|
238
|
+
const columnLayoutKey = (0, import_react.useMemo)(
|
|
239
|
+
() => wrapedColumns.map(
|
|
240
|
+
(column, index) => {
|
|
241
|
+
var _a2, _b, _c, _d;
|
|
242
|
+
return `${(_b = (_a2 = column.key) != null ? _a2 : column.dataIndex) != null ? _b : index}:${(_c = column.fixed) != null ? _c : ""}:${(_d = column.width) != null ? _d : ""}`;
|
|
243
|
+
}
|
|
244
|
+
).join("|"),
|
|
245
|
+
[wrapedColumns]
|
|
246
|
+
);
|
|
247
|
+
const wrapedColumnsRef = (0, import_useLatest.default)(wrapedColumns);
|
|
248
|
+
const updateMeasuredColumnWidths = import_react.default.useCallback(() => {
|
|
249
|
+
var _a2;
|
|
250
|
+
const columns = wrapedColumnsRef.current;
|
|
251
|
+
if (!columns.some((column) => column.fixed))
|
|
252
|
+
return;
|
|
253
|
+
const colElements = (_a2 = tableRef.current) == null ? void 0 : _a2.querySelectorAll(
|
|
254
|
+
":scope > colgroup > col"
|
|
255
|
+
);
|
|
256
|
+
if (!colElements || colElements.length !== columns.length)
|
|
257
|
+
return;
|
|
258
|
+
const nextWidths = Array.from(
|
|
259
|
+
colElements,
|
|
260
|
+
(column) => Math.round(column.getBoundingClientRect().width)
|
|
261
|
+
);
|
|
262
|
+
if (nextWidths.some((width) => !Number.isFinite(width) || width <= 0)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
setMeasuredColumnWidths((current2) => {
|
|
266
|
+
const unchanged = (current2 == null ? void 0 : current2.length) === nextWidths.length && current2.every((width, index) => width === nextWidths[index]);
|
|
267
|
+
return unchanged ? current2 : nextWidths;
|
|
268
|
+
});
|
|
269
|
+
}, [wrapedColumnsRef]);
|
|
237
270
|
(0, import_react.useEffect)(() => {
|
|
238
271
|
if (prevFilterRecordsRef.current === filterRecords)
|
|
239
272
|
return;
|
|
@@ -258,20 +291,34 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
258
291
|
onChange
|
|
259
292
|
]);
|
|
260
293
|
(0, import_react.useEffect)(() => {
|
|
261
|
-
updateHorizontalScroll();
|
|
262
|
-
const wrapper = contentWrapperRef.current;
|
|
263
294
|
const content = contentRef.current;
|
|
264
|
-
|
|
295
|
+
const tableElement = tableRef.current;
|
|
296
|
+
if (!content || !tableElement)
|
|
265
297
|
return void 0;
|
|
298
|
+
const handleResize = () => {
|
|
299
|
+
updateHorizontalScroll();
|
|
300
|
+
updateMeasuredColumnWidths();
|
|
301
|
+
};
|
|
266
302
|
if (typeof ResizeObserver === "undefined") {
|
|
267
|
-
window.addEventListener("resize",
|
|
268
|
-
return () => window.removeEventListener("resize",
|
|
303
|
+
window.addEventListener("resize", handleResize);
|
|
304
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
269
305
|
}
|
|
270
|
-
const resizeObserver = new ResizeObserver(
|
|
271
|
-
resizeObserver.observe(wrapper);
|
|
306
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
272
307
|
resizeObserver.observe(content);
|
|
308
|
+
resizeObserver.observe(tableElement);
|
|
273
309
|
return () => resizeObserver.disconnect();
|
|
274
|
-
}, [updateHorizontalScroll,
|
|
310
|
+
}, [updateHorizontalScroll, updateMeasuredColumnWidths]);
|
|
311
|
+
(0, import_react.useEffect)(() => {
|
|
312
|
+
updateHorizontalScroll();
|
|
313
|
+
updateMeasuredColumnWidths();
|
|
314
|
+
}, [
|
|
315
|
+
columnLayoutKey,
|
|
316
|
+
pageData,
|
|
317
|
+
scroll == null ? void 0 : scroll.x,
|
|
318
|
+
scroll == null ? void 0 : scroll.y,
|
|
319
|
+
updateHorizontalScroll,
|
|
320
|
+
updateMeasuredColumnWidths
|
|
321
|
+
]);
|
|
275
322
|
const renderHeader = () => {
|
|
276
323
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
277
324
|
import_header.default,
|
|
@@ -326,6 +373,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
326
373
|
const renderTable = () => {
|
|
327
374
|
const tableProps = {
|
|
328
375
|
style: __spreadProps(__spreadValues({}, styles == null ? void 0 : styles.table), {
|
|
376
|
+
minWidth: scroll == null ? void 0 : scroll.x,
|
|
329
377
|
tableLayout: (pageData == null ? void 0 : pageData.length) ? tableLayout : void 0
|
|
330
378
|
}),
|
|
331
379
|
className: (0, import_clsx.default)(
|
|
@@ -346,17 +394,15 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
346
394
|
rowKey
|
|
347
395
|
}
|
|
348
396
|
},
|
|
349
|
-
/* @__PURE__ */ import_react.default.createElement("table", __spreadValues({}, tableProps), /* @__PURE__ */ import_react.default.createElement(import_col_group.default, { columns: wrapedColumns }), renderTHeader(), renderTBody(), renderTFooter())
|
|
397
|
+
/* @__PURE__ */ import_react.default.createElement("table", __spreadValues({ ref: tableRef }, tableProps), /* @__PURE__ */ import_react.default.createElement(import_col_group.default, { columns: wrapedColumns }), renderTHeader(), renderTBody(), renderTFooter())
|
|
350
398
|
);
|
|
351
399
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
352
400
|
"div",
|
|
353
401
|
{
|
|
354
|
-
ref: contentWrapperRef,
|
|
355
402
|
className: (0, import_clsx.default)(`${prefixCls}-content-wrapper`, {
|
|
356
403
|
[`${prefixCls}-content-wrapper-scroll-left`]: horizontalScroll.left,
|
|
357
404
|
[`${prefixCls}-content-wrapper-scroll-right`]: horizontalScroll.right
|
|
358
|
-
})
|
|
359
|
-
onScroll: updateHorizontalScroll
|
|
405
|
+
})
|
|
360
406
|
},
|
|
361
407
|
/* @__PURE__ */ import_react.default.createElement(
|
|
362
408
|
"div",
|
|
@@ -366,7 +412,7 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
366
412
|
[`${prefixCls}-${size}-size`]: size,
|
|
367
413
|
[`${prefixCls}-fixed-header`]: scroll == null ? void 0 : scroll.y
|
|
368
414
|
}),
|
|
369
|
-
style: { height: scroll == null ? void 0 : scroll.y
|
|
415
|
+
style: { height: scroll == null ? void 0 : scroll.y },
|
|
370
416
|
onScroll: updateHorizontalScroll
|
|
371
417
|
},
|
|
372
418
|
table2
|
|
@@ -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[];
|
|
@@ -39,7 +39,20 @@ __export(util_exports, {
|
|
|
39
39
|
handleColumns: () => handleColumns
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(util_exports);
|
|
42
|
-
|
|
42
|
+
var getColumnWidth = (column, index, measuredColumnWidths) => {
|
|
43
|
+
const measuredWidth = measuredColumnWidths == null ? void 0 : measuredColumnWidths[index];
|
|
44
|
+
if (Number.isFinite(measuredWidth) && measuredWidth && measuredWidth > 0) {
|
|
45
|
+
return measuredWidth;
|
|
46
|
+
}
|
|
47
|
+
if (typeof column.width === "number") {
|
|
48
|
+
return column.width;
|
|
49
|
+
}
|
|
50
|
+
if (typeof column.width === "string" && /^\s*\d+(?:\.\d+)?px\s*$/.test(column.width)) {
|
|
51
|
+
return Number.parseFloat(column.width);
|
|
52
|
+
}
|
|
53
|
+
return 0;
|
|
54
|
+
};
|
|
55
|
+
function handleColumns(columns, measuredColumnWidths) {
|
|
43
56
|
var _a, _b;
|
|
44
57
|
let leftWidthCount = 0;
|
|
45
58
|
let rightWidthCount = 0;
|
|
@@ -53,7 +66,7 @@ function handleColumns(columns) {
|
|
|
53
66
|
if (!nextIsFixedLeft) {
|
|
54
67
|
col.isFixedLeftLast = true;
|
|
55
68
|
}
|
|
56
|
-
leftWidthCount
|
|
69
|
+
leftWidthCount += getColumnWidth(col, i, measuredColumnWidths);
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
for (let j = columns.length - 1; j >= 0; j--) {
|
|
@@ -63,7 +76,7 @@ function handleColumns(columns) {
|
|
|
63
76
|
if (((_b = columns[j - 1]) == null ? void 0 : _b.fixed) !== "right") {
|
|
64
77
|
col.isFixedRightFirst = true;
|
|
65
78
|
}
|
|
66
|
-
rightWidthCount
|
|
79
|
+
rightWidthCount += getColumnWidth(col, j, measuredColumnWidths);
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
82
|
return columns;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -197,7 +197,7 @@ var Search = /*#__PURE__*/React.forwardRef(function (baseProps, ref) {
|
|
|
197
197
|
role: "searchbox",
|
|
198
198
|
"aria-autocomplete": hasPopup ? 'list' : undefined,
|
|
199
199
|
"aria-controls": hasPopup && open ? listboxId : undefined,
|
|
200
|
-
"aria-activedescendant": hasPopup && open && focusedKey
|
|
200
|
+
"aria-activedescendant": hasPopup && open && focusedKey !== null ? String(focusedKey) : undefined
|
|
201
201
|
})), loading ? /*#__PURE__*/React.createElement(Spin, {
|
|
202
202
|
variant: "ring",
|
|
203
203
|
size: "small",
|
|
@@ -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
|
}
|