@douyinfe/semi-ui 2.10.1 → 2.10.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/checkbox/checkbox.tsx +1 -3
- package/checkbox/checkboxInner.tsx +19 -14
- package/dist/umd/semi-ui.js +76 -41
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/baseForm.tsx +0 -1
- package/lib/cjs/checkbox/checkbox.js +1 -2
- package/lib/cjs/checkbox/checkboxInner.js +21 -17
- package/lib/cjs/form/baseForm.js +0 -1
- package/lib/cjs/select/index.js +27 -24
- package/lib/cjs/table/Body/BaseRow.d.ts +1 -0
- package/lib/cjs/table/Body/BaseRow.js +22 -0
- package/lib/cjs/table/HeadTable.d.ts +2 -1
- package/lib/cjs/table/HeadTable.js +2 -1
- package/lib/cjs/table/Table.js +2 -0
- package/lib/es/checkbox/checkbox.js +1 -2
- package/lib/es/checkbox/checkboxInner.js +20 -17
- package/lib/es/form/baseForm.js +0 -1
- package/lib/es/select/index.js +23 -21
- package/lib/es/table/Body/BaseRow.d.ts +1 -0
- package/lib/es/table/Body/BaseRow.js +22 -0
- package/lib/es/table/HeadTable.d.ts +2 -1
- package/lib/es/table/HeadTable.js +2 -1
- package/lib/es/table/Table.js +2 -0
- package/package.json +9 -9
- package/scrollList/_story/ScrollList/index.js +1 -1
- package/select/index.tsx +3 -1
- package/table/Body/BaseRow.tsx +15 -0
- package/table/HeadTable.tsx +3 -1
- package/table/Table.tsx +2 -0
- package/table/_story/v2/FixedOnHeaderRow/index.jsx +134 -0
- package/table/_story/v2/index.js +2 -1
- package/upload/_story/upload.stories.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation": "2.10.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.10.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.10.
|
|
20
|
-
"@douyinfe/semi-icons": "2.10.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.10.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.10.
|
|
17
|
+
"@douyinfe/semi-animation": "2.10.2",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.10.2",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.10.2",
|
|
20
|
+
"@douyinfe/semi-icons": "2.10.2",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.10.2",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.10.2",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "00b27ff43fe6ed5d775d5849bd0adc4c4c5ea231",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-react": "^7.14.5",
|
|
78
|
-
"@douyinfe/semi-scss-compile": "2.10.
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.10.2",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
package/select/index.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import { isSemiIcon } from '../_utils';
|
|
|
28
28
|
import { Subtract } from 'utility-types';
|
|
29
29
|
|
|
30
30
|
import warning from '@douyinfe/semi-foundation/utils/warning';
|
|
31
|
+
import { getUuidShort } from '@douyinfe/semi-foundation/utils/uuid';
|
|
31
32
|
|
|
32
33
|
import '@douyinfe/semi-foundation/select/select.scss';
|
|
33
34
|
import { Locale } from '../locale/interface';
|
|
@@ -340,7 +341,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
340
341
|
isHovering: false,
|
|
341
342
|
};
|
|
342
343
|
/* Generate random string */
|
|
343
|
-
this.selectOptionListID =
|
|
344
|
+
this.selectOptionListID = '';
|
|
344
345
|
this.virtualizeListRef = React.createRef();
|
|
345
346
|
this.inputRef = React.createRef();
|
|
346
347
|
this.triggerRef = React.createRef();
|
|
@@ -559,6 +560,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
559
560
|
|
|
560
561
|
componentDidMount() {
|
|
561
562
|
this.foundation.init();
|
|
563
|
+
this.selectOptionListID = getUuidShort();
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
componentWillUnmount() {
|
package/table/Body/BaseRow.tsx
CHANGED
|
@@ -153,6 +153,21 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
|
|
|
153
153
|
this.foundation = new TableRowFoundation(this.adapter);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
componentDidMount() {
|
|
157
|
+
// fix #745
|
|
158
|
+
// didmount/willUnmount may be called twice when React.StrictMode is true in React 18, we need to ensure that this.cache.customRowProps is correct
|
|
159
|
+
const {
|
|
160
|
+
onRow,
|
|
161
|
+
index,
|
|
162
|
+
record,
|
|
163
|
+
} = this.props;
|
|
164
|
+
const customRowProps = this.adapter.getCache('customRowProps');
|
|
165
|
+
if (typeof customRowProps === 'undefined') {
|
|
166
|
+
const { className: customClassName, style: customStyle, ...rowProps } = onRow(record, index) || {};
|
|
167
|
+
this.adapter.setCache('customRowProps', { ...rowProps });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
156
171
|
shouldComponentUpdate(nextProps: BaseRowProps) {
|
|
157
172
|
/**
|
|
158
173
|
* Shallow comparison of incoming props to simulate PureComponent
|
package/table/HeadTable.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
|
|
7
7
|
import ColGroup from './ColGroup';
|
|
8
8
|
import TableHeader from './TableHeader';
|
|
9
|
-
import { Fixed, TableComponents, Scroll, BodyScrollEvent, ColumnProps } from './interface';
|
|
9
|
+
import { Fixed, TableComponents, Scroll, BodyScrollEvent, ColumnProps, OnHeaderRow } from './interface';
|
|
10
10
|
|
|
11
11
|
export interface HeadTableProps {
|
|
12
12
|
[x: string]: any;
|
|
@@ -23,6 +23,7 @@ export interface HeadTableProps {
|
|
|
23
23
|
selectedRowKeysSet: Set<any>;
|
|
24
24
|
showHeader?: boolean;
|
|
25
25
|
onDidUpdate?: (ref: React.MutableRefObject<any>) => void;
|
|
26
|
+
onHeaderRow?: OnHeaderRow<any>;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -46,6 +47,7 @@ class HeadTable extends React.PureComponent<HeadTableProps> {
|
|
|
46
47
|
selectedRowKeysSet: PropTypes.instanceOf(Set).isRequired, // Useful when update is selected
|
|
47
48
|
showHeader: PropTypes.bool,
|
|
48
49
|
onDidUpdate: PropTypes.func,
|
|
50
|
+
onHeaderRow: PropTypes.func,
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
static defaultProps = {
|
package/table/Table.tsx
CHANGED
|
@@ -1089,6 +1089,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
1089
1089
|
components,
|
|
1090
1090
|
headerRef,
|
|
1091
1091
|
bodyRef,
|
|
1092
|
+
onHeaderRow,
|
|
1092
1093
|
rowSelection,
|
|
1093
1094
|
dataSource,
|
|
1094
1095
|
bodyHasScrollBar,
|
|
@@ -1110,6 +1111,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
1110
1111
|
scroll={scroll}
|
|
1111
1112
|
showHeader={showHeader}
|
|
1112
1113
|
selectedRowKeysSet={selectedRowKeysSet}
|
|
1114
|
+
onHeaderRow={onHeaderRow}
|
|
1113
1115
|
dataSource={dataSource}
|
|
1114
1116
|
bodyHasScrollBar={bodyHasScrollBar}
|
|
1115
1117
|
/>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useState, useMemo, useEffect } from 'react';
|
|
2
|
+
import { Table, Avatar, Toast } from '@douyinfe/semi-ui';
|
|
3
|
+
import * as dateFns from 'date-fns';
|
|
4
|
+
|
|
5
|
+
App.storyName = 'fix onHeaderRow';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* test with cypress
|
|
9
|
+
*/
|
|
10
|
+
export default function App() {
|
|
11
|
+
const [dataSource, setData] = useState([]);
|
|
12
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
13
|
+
const figmaIconUrl = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png';
|
|
14
|
+
|
|
15
|
+
const columns = [
|
|
16
|
+
{
|
|
17
|
+
title: '标题',
|
|
18
|
+
dataIndex: 'name',
|
|
19
|
+
fixed: true,
|
|
20
|
+
width: 250,
|
|
21
|
+
render: (text, record, index) => {
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<Avatar size="small" shape="square" src={figmaIconUrl} style={{ marginRight: 12 }}></Avatar>
|
|
25
|
+
{text}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
filters: [
|
|
30
|
+
{
|
|
31
|
+
text: 'Semi Design 设计稿',
|
|
32
|
+
value: 'Semi Design 设计稿',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
text: 'Semi Pro 设计稿',
|
|
36
|
+
value: 'Semi Pro 设计稿',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
onFilter: (value, record) => record.name.includes(value),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: '大小',
|
|
43
|
+
dataIndex: 'size',
|
|
44
|
+
width: 200,
|
|
45
|
+
sorter: (a, b) => (a.size - b.size > 0 ? 1 : -1),
|
|
46
|
+
render: text => `${text} KB`,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: '所有者',
|
|
50
|
+
dataIndex: 'owner',
|
|
51
|
+
width: 200,
|
|
52
|
+
render: (text, record, index) => {
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>
|
|
56
|
+
{typeof text === 'string' && text.slice(0, 1)}
|
|
57
|
+
</Avatar>
|
|
58
|
+
{text}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: '更新日期',
|
|
65
|
+
dataIndex: 'updateTime',
|
|
66
|
+
width: 200,
|
|
67
|
+
sorter: (a, b) => (a.updateTime - b.updateTime > 0 ? 1 : -1),
|
|
68
|
+
render: value => {
|
|
69
|
+
return dateFns.format(new Date(value), 'yyyy-MM-dd');
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: '',
|
|
74
|
+
dataIndex: 'operate',
|
|
75
|
+
fixed: 'right',
|
|
76
|
+
align: 'center',
|
|
77
|
+
width: 100,
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
const scroll = useMemo(() => ({ y: 300, x: 1200 }), []);
|
|
82
|
+
const rowSelection = useMemo(
|
|
83
|
+
() => ({
|
|
84
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
85
|
+
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
|
86
|
+
},
|
|
87
|
+
getCheckboxProps: record => ({
|
|
88
|
+
disabled: record.name === 'Michael James', // Column configuration not to be checked
|
|
89
|
+
name: record.name,
|
|
90
|
+
}),
|
|
91
|
+
fixed: true,
|
|
92
|
+
}),
|
|
93
|
+
[]
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const getData = () => {
|
|
97
|
+
const data = [];
|
|
98
|
+
for (let i = 0; i < 46; i++) {
|
|
99
|
+
const isSemiDesign = i % 2 === 0;
|
|
100
|
+
const randomNumber = (i * 1000) % 199;
|
|
101
|
+
data.push({
|
|
102
|
+
key: '' + i,
|
|
103
|
+
name: isSemiDesign ? `Semi Design 设计稿${i}.fig` : `Semi Pro 设计稿${i}.fig`,
|
|
104
|
+
owner: isSemiDesign ? '姜鹏志' : '郝宣',
|
|
105
|
+
size: randomNumber,
|
|
106
|
+
updateTime: new Date().valueOf() + randomNumber * DAY,
|
|
107
|
+
avatarBg: isSemiDesign ? 'grey' : 'red',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return data;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
const data = getData();
|
|
115
|
+
setData(data);
|
|
116
|
+
}, []);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Table
|
|
120
|
+
onHeaderRow={(columns, index) => {
|
|
121
|
+
return {
|
|
122
|
+
onClick: event => {
|
|
123
|
+
console.log(event);
|
|
124
|
+
Toast.info('header click');
|
|
125
|
+
}, // 点击表头行
|
|
126
|
+
};
|
|
127
|
+
}}
|
|
128
|
+
columns={columns}
|
|
129
|
+
dataSource={dataSource}
|
|
130
|
+
rowSelection={rowSelection}
|
|
131
|
+
scroll={scroll}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
package/table/_story/v2/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export { default as FixedZIndex } from './FixedZIndex';
|
|
|
4
4
|
export { default as FixedHeaderMerge } from './FixedHeaderMerge';
|
|
5
5
|
export { default as FixedResizable } from './FixedResizable';
|
|
6
6
|
export { default as FixedExpandedRow } from './FixedExpandedRow';
|
|
7
|
-
export { default as FixedMemoryLeak } from './FixedMemoryLeak';
|
|
7
|
+
export { default as FixedMemoryLeak } from './FixedMemoryLeak';
|
|
8
|
+
export { default as FixedOnHeaderRow } from './FixedOnHeaderRow';
|