@douyinfe/semi-ui 2.17.0 → 2.17.1

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.
@@ -227,7 +227,7 @@ class AutoComplete extends _baseComponent.default {
227
227
  selection
228
228
  } = this.state;
229
229
  const useCustomTrigger = typeof triggerRender === 'function';
230
- const outerProps = (0, _assign.default)({
230
+ const outerProps = (0, _assign.default)((0, _assign.default)({
231
231
  style,
232
232
  className: useCustomTrigger ? (0, _classnames.default)(className) : (0, _classnames.default)({
233
233
  [prefixCls]: true,
@@ -236,7 +236,10 @@ class AutoComplete extends _baseComponent.default {
236
236
  onClick: this.handleInputClick,
237
237
  ref: this.triggerRef,
238
238
  id
239
- }, keyboardEventSet);
239
+ }, keyboardEventSet), {
240
+ // tooltip give tabindex 0 to children by default, autoComplete just need the input get focus, so outer div's tabindex set to -1
241
+ tabIndex: -1
242
+ });
240
243
  const innerProps = {
241
244
  disabled,
242
245
  placeholder,
@@ -195,7 +195,7 @@ class AutoComplete extends BaseComponent {
195
195
  } = this.state;
196
196
  const useCustomTrigger = typeof triggerRender === 'function';
197
197
 
198
- const outerProps = _Object$assign({
198
+ const outerProps = _Object$assign(_Object$assign({
199
199
  style,
200
200
  className: useCustomTrigger ? cls(className) : cls({
201
201
  [prefixCls]: true,
@@ -204,7 +204,10 @@ class AutoComplete extends BaseComponent {
204
204
  onClick: this.handleInputClick,
205
205
  ref: this.triggerRef,
206
206
  id
207
- }, keyboardEventSet);
207
+ }, keyboardEventSet), {
208
+ // tooltip give tabindex 0 to children by default, autoComplete just need the input get focus, so outer div's tabindex set to -1
209
+ tabIndex: -1
210
+ });
208
211
 
209
212
  const innerProps = {
210
213
  disabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -15,11 +15,11 @@
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
17
  "@douyinfe/semi-animation": "2.12.0",
18
- "@douyinfe/semi-animation-react": "2.17.0",
19
- "@douyinfe/semi-foundation": "2.17.0",
20
- "@douyinfe/semi-icons": "2.17.0",
18
+ "@douyinfe/semi-animation-react": "2.17.1",
19
+ "@douyinfe/semi-foundation": "2.17.1",
20
+ "@douyinfe/semi-icons": "2.17.1",
21
21
  "@douyinfe/semi-illustrations": "2.15.0",
22
- "@douyinfe/semi-theme-default": "2.17.0",
22
+ "@douyinfe/semi-theme-default": "2.17.1",
23
23
  "async-validator": "^3.5.0",
24
24
  "classnames": "^2.2.6",
25
25
  "copy-text-to-clipboard": "^2.1.1",
@@ -66,13 +66,13 @@
66
66
  ],
67
67
  "author": "",
68
68
  "license": "MIT",
69
- "gitHead": "802e57ecc50de44c7ad4b2322bdd864eb9727cc3",
69
+ "gitHead": "e2dfadcc7f24b9af6cab08b64ac0ead052219961",
70
70
  "devDependencies": {
71
71
  "@babel/plugin-proposal-decorators": "^7.15.8",
72
72
  "@babel/plugin-transform-runtime": "^7.15.8",
73
73
  "@babel/preset-env": "^7.15.8",
74
74
  "@babel/preset-react": "^7.14.5",
75
- "@douyinfe/semi-scss-compile": "2.17.0",
75
+ "@douyinfe/semi-scss-compile": "2.17.1",
76
76
  "@storybook/addon-knobs": "^6.3.1",
77
77
  "@types/lodash": "^4.14.176",
78
78
  "@types/react": ">=16.0.0",
@@ -0,0 +1,106 @@
1
+ import React, { useState, useMemo, useEffect } from 'react';
2
+
3
+ // eslint-disable-next-line semi-design/no-import
4
+ import { Table, Avatar } from '@douyinfe/semi-ui';
5
+ import * as dateFns from 'date-fns';
6
+
7
+ const DAY = 24 * 60 * 60 * 1000;
8
+ const figmaIconUrl = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png';
9
+
10
+ const columns = [
11
+ {
12
+ title: '标题',
13
+ dataIndex: 'name',
14
+ width: 400,
15
+ render: (text, record, index) => {
16
+ return (
17
+ <div>
18
+ <Avatar size="small" shape="square" src={figmaIconUrl} style={{ marginRight: 12 }}></Avatar>
19
+ {text}
20
+ </div>
21
+ );
22
+ },
23
+ filters: [
24
+ {
25
+ text: 'Semi Design 设计稿',
26
+ value: 'Semi Design 设计稿',
27
+ },
28
+ {
29
+ text: 'Semi Pro 设计稿',
30
+ value: 'Semi Pro 设计稿',
31
+ },
32
+ ],
33
+ onFilter: (value, record) => record.name.includes(value),
34
+ sorter: (a, b) => a.name.length - b.name.length > 0 ? 1 : -1,
35
+ },
36
+ {
37
+ title: '大小',
38
+ dataIndex: 'size',
39
+ sorter: (a, b) => a.size - b.size > 0 ? 1 : -1,
40
+ render: (text) => `${text} KB`
41
+ },
42
+ {
43
+ title: '所有者',
44
+ dataIndex: 'owner',
45
+ render: (text, record, index) => {
46
+ return (
47
+ <div>
48
+ <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>{typeof text === 'string' && text.slice(0, 1)}</Avatar>
49
+ {text}
50
+ </div>
51
+ );
52
+ }
53
+
54
+ },
55
+ {
56
+ title: '更新日期',
57
+ dataIndex: 'updateTime',
58
+ sorter: (a, b) => a.updateTime - b.updateTime > 0 ? 1 : -1,
59
+ render: (value) => {
60
+ return dateFns.format(new Date(value), 'yyyy-MM-dd');
61
+ }
62
+ }
63
+ ];
64
+
65
+ App.storyName = 'Fixed filter issue 1036';
66
+ /**
67
+ * test with cypress, please don't modify this story
68
+ */
69
+ export default function App() {
70
+ const [dataSource, setData] = useState([]);
71
+
72
+ const rowSelection = useMemo(() => ({
73
+ onChange: (selectedRowKeys, selectedRows) => {
74
+ console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
75
+ },
76
+ getCheckboxProps: record => ({
77
+ disabled: record.name === 'Michael James', // Column configuration not to be checked
78
+ name: record.name,
79
+ }),
80
+ }), []);
81
+ const scroll = useMemo(() => ({ y: 300 }), []);
82
+
83
+ const getData = () => {
84
+ const data = [];
85
+ for (let i = 0; i < 46; i++) {
86
+ const isSemiDesign = i % 2 === 0;
87
+ const randomNumber = (i * 1000) % 199;
88
+ data.push({
89
+ key: '' + i,
90
+ name: isSemiDesign ? `Semi Design 设计稿${i}.fig` : `Semi Pro 设计稿${i}.fig`,
91
+ owner: isSemiDesign ? '姜鹏志' : '郝宣',
92
+ size: randomNumber,
93
+ updateTime: new Date('2022-08-11').valueOf() + randomNumber * DAY,
94
+ avatarBg: isSemiDesign ? 'grey' : 'red'
95
+ });
96
+ }
97
+ return data;
98
+ };
99
+
100
+ useEffect(() => {
101
+ const data = getData();
102
+ setData(data);
103
+ }, []);
104
+
105
+ return <Table columns={columns} dataSource={dataSource} rowSelection={rowSelection} scroll={scroll} />;
106
+ }
@@ -0,0 +1,102 @@
1
+ import React, { useState } from 'react';
2
+ // eslint-disable-next-line semi-design/no-import
3
+ import { Table } from '@douyinfe/semi-ui';
4
+ // eslint-disable-next-line semi-design/no-import
5
+ import { ChangeInfo } from '@douyinfe/semi-ui/table';
6
+
7
+ const data = [
8
+ {
9
+ key: 'a',
10
+ group: 'yes',
11
+ count: 3,
12
+ },
13
+ {
14
+ key: 'b',
15
+ group: 'no',
16
+ count: 3,
17
+ },
18
+ {
19
+ key: 'c',
20
+ group: 'no',
21
+ count: 1,
22
+ },
23
+ {
24
+ key: 'd',
25
+ group: 'yes',
26
+ count: 1,
27
+ },
28
+ {
29
+ key: 'e',
30
+ group: 'no',
31
+ count: 2,
32
+ },
33
+ {
34
+ key: 'f',
35
+ group: 'yes',
36
+ count: 2,
37
+ }
38
+ ];
39
+
40
+ Demo.storyName = 'fixed sorter';
41
+ /**
42
+ * 保持分组顺序不变的排序方式
43
+ */
44
+ function Demo() {
45
+ const [filtered, setFiltered] = useState([...data]);
46
+ console.log(filtered);
47
+ const columns = [
48
+ {
49
+ title: 'ID',
50
+ dataIndex: 'key',
51
+ },
52
+ {
53
+ title: 'group',
54
+ dataIndex: 'Group',
55
+ sorter: (a, b) => a.group === 'yes' ? -1 : 1,
56
+ // sortOrder: 'ascend'
57
+ },
58
+ {
59
+ title: 'Count',
60
+ dataIndex: 'count',
61
+ // sorter: true
62
+ sorter: (a, b) => a.count - b.count > 0 ? 1 : -1,
63
+ },
64
+ ];
65
+
66
+ const onTableChange = ({ sorter }: ChangeInfo<any>) => {
67
+ if (sorter) {
68
+ const { dataIndex, sortOrder } = sorter;
69
+ setFiltered(prev => [...prev].sort((a, b) => {
70
+ if (a.group !== b.group) {
71
+ return a.group === 'yes' ? -1 : 1;
72
+ }
73
+
74
+ let ascendValue = -1;
75
+ if (dataIndex === 'count') {
76
+ ascendValue = a.count - b.count > 0 ? 1 : -1;
77
+ }
78
+
79
+ return sortOrder === 'ascend' ? ascendValue : -ascendValue;
80
+ }));
81
+ }
82
+ };
83
+
84
+
85
+ return (
86
+ <div style={{ padding: '20px 0px' }}>
87
+ <Table
88
+ dataSource={filtered}
89
+ onChange={onTableChange}
90
+ rowKey="key"
91
+ groupBy="group"
92
+ columns={columns}
93
+ renderGroupSection={groupKey => <strong>分组 {groupKey}</strong>}
94
+ expandAllGroupRows
95
+ scroll={{ y: 480 }}
96
+ pagination={{ pageSize: 4 }}
97
+ />
98
+ </div>
99
+ );
100
+ }
101
+
102
+ export default Demo;
@@ -4,7 +4,9 @@ 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
8
  export { default as FixedOnHeaderRow } from './FixedOnHeaderRow';
9
9
  export { default as RadioRowSelection } from './radioRowSelection';
10
- export { default as FixedVirtualizedEmpty } from './FixedVirtualizedEmpty';
10
+ export { default as FixedVirtualizedEmpty } from './FixedVirtualizedEmpty';
11
+ export { default as FixedFilter } from './FixedFilter';
12
+ export { default as FixedSorter } from './FixedSorter';