@douyinfe/semi-ui 2.4.1 → 2.5.0-beta.0
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/cascader/__test__/cascader.test.js +24 -0
- package/cascader/_story/cascader.stories.js +73 -0
- package/cascader/index.tsx +5 -2
- package/dist/css/semi.css +50 -27
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +398 -139
- 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/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/cascader/index.js +6 -0
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/select/option.js +2 -2
- package/lib/cjs/table/Table.d.ts +1 -1
- package/lib/cjs/table/Table.js +8 -2
- package/lib/cjs/table/interface.d.ts +1 -0
- package/lib/cjs/tabs/interface.d.ts +1 -1
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tree/index.d.ts +2 -0
- package/lib/cjs/tree/index.js +15 -8
- package/lib/cjs/treeSelect/index.d.ts +2 -0
- package/lib/cjs/treeSelect/index.js +64 -27
- package/lib/cjs/upload/fileCard.js +31 -22
- package/lib/cjs/upload/index.d.ts +6 -0
- package/lib/cjs/upload/index.js +15 -8
- package/lib/cjs/upload/interface.d.ts +8 -6
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/cascader/index.js +5 -0
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/select/option.js +2 -2
- package/lib/es/table/Table.d.ts +1 -1
- package/lib/es/table/Table.js +10 -2
- package/lib/es/table/interface.d.ts +1 -0
- package/lib/es/tabs/interface.d.ts +1 -1
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tree/index.d.ts +2 -0
- package/lib/es/tree/index.js +15 -8
- package/lib/es/treeSelect/index.d.ts +2 -0
- package/lib/es/treeSelect/index.js +64 -27
- package/lib/es/upload/fileCard.js +31 -24
- package/lib/es/upload/index.d.ts +6 -0
- package/lib/es/upload/index.js +14 -8
- package/lib/es/upload/interface.d.ts +8 -6
- package/package.json +9 -9
- package/select/option.tsx +2 -2
- package/table/Table.tsx +7 -2
- package/table/_story/table.stories.js +1 -2
- package/table/_story/v2/FixedHeaderMerge/index.jsx +98 -0
- package/table/_story/v2/defaultFilteredValue.tsx +123 -0
- package/table/_story/v2/index.js +4 -0
- package/table/interface.ts +1 -0
- package/tabs/interface.ts +1 -1
- package/tooltip/_story/tooltip.stories.js +83 -1
- package/tree/__test__/treeMultiple.test.js +94 -0
- package/tree/_story/tree.stories.js +169 -0
- package/tree/index.tsx +12 -5
- package/treeSelect/__test__/treeMultiple.test.js +94 -0
- package/treeSelect/_story/treeSelect.stories.js +242 -0
- package/treeSelect/index.tsx +72 -40
- package/upload/_story/upload.stories.js +22 -6
- package/upload/fileCard.tsx +23 -23
- package/upload/index.tsx +15 -6
- package/upload/interface.ts +7 -5
|
@@ -4,9 +4,9 @@ import cls from 'classnames';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/upload/constants';
|
|
6
6
|
import { getFileSize } from '@douyinfe/semi-foundation/lib/es/upload/utils';
|
|
7
|
-
import { IconAlertCircle, IconClose, IconFile, IconRefresh } from '@douyinfe/semi-icons';
|
|
7
|
+
import { IconAlertCircle, IconClose, IconClear, IconFile, IconRefresh } from '@douyinfe/semi-icons';
|
|
8
8
|
import LocaleConsumer from '../locale/localeConsumer';
|
|
9
|
-
import
|
|
9
|
+
import Button from '../button/index';
|
|
10
10
|
import Progress from '../progress/index';
|
|
11
11
|
import Tooltip from '../tooltip/index';
|
|
12
12
|
import Spin from '../spin/index';
|
|
@@ -167,6 +167,7 @@ class FileCard extends PureComponent {
|
|
|
167
167
|
onPreviewClick,
|
|
168
168
|
showPicInfo,
|
|
169
169
|
renderPicInfo,
|
|
170
|
+
renderPicPreviewIcon,
|
|
170
171
|
renderThumbnail,
|
|
171
172
|
name,
|
|
172
173
|
index
|
|
@@ -174,6 +175,7 @@ class FileCard extends PureComponent {
|
|
|
174
175
|
const showProgress = status === strings.FILE_STATUS_UPLOADING && percent !== 100;
|
|
175
176
|
const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
|
|
176
177
|
const showReplace = status === strings.FILE_STATUS_SUCCESS && this.props.showReplace;
|
|
178
|
+
const showPreview = status === strings.FILE_STATUS_SUCCESS && !this.props.showReplace;
|
|
177
179
|
const filePicCardCls = cls({
|
|
178
180
|
["".concat(prefixCls, "-picture-file-card")]: true,
|
|
179
181
|
["".concat(prefixCls, "-picture-file-card-disabled")]: disabled,
|
|
@@ -181,7 +183,6 @@ class FileCard extends PureComponent {
|
|
|
181
183
|
["".concat(prefixCls, "-picture-file-card-error")]: status === strings.FILE_STATUS_UPLOAD_FAIL,
|
|
182
184
|
["".concat(prefixCls, "-picture-file-card-uploading")]: showProgress
|
|
183
185
|
});
|
|
184
|
-
const closeCls = "".concat(prefixCls, "-picture-file-card-close");
|
|
185
186
|
const retry = /*#__PURE__*/React.createElement("div", {
|
|
186
187
|
role: "button",
|
|
187
188
|
tabIndex: 0,
|
|
@@ -204,6 +205,17 @@ class FileCard extends PureComponent {
|
|
|
204
205
|
}, /*#__PURE__*/React.createElement(ReplaceSvg, {
|
|
205
206
|
className: "".concat(prefixCls, "-picture-file-card-icon-replace")
|
|
206
207
|
})));
|
|
208
|
+
const preview = /*#__PURE__*/React.createElement("div", {
|
|
209
|
+
className: "".concat(prefixCls, "-picture-file-card-preview")
|
|
210
|
+
}, typeof renderPicPreviewIcon === 'function' ? renderPicPreviewIcon(this.props) : null);
|
|
211
|
+
const close = /*#__PURE__*/React.createElement("div", {
|
|
212
|
+
role: "button",
|
|
213
|
+
tabIndex: 0,
|
|
214
|
+
className: "".concat(prefixCls, "-picture-file-card-close"),
|
|
215
|
+
onClick: e => this.onRemove(e)
|
|
216
|
+
}, /*#__PURE__*/React.createElement(IconClear, {
|
|
217
|
+
className: "".concat(prefixCls, "-picture-file-card-icon-close")
|
|
218
|
+
}));
|
|
207
219
|
const picInfo = typeof renderPicInfo === 'function' ? renderPicInfo(this.props) : /*#__PURE__*/React.createElement("div", {
|
|
208
220
|
className: "".concat(prefixCls, "-picture-file-card-pic-info")
|
|
209
221
|
}, index + 1);
|
|
@@ -222,14 +234,7 @@ class FileCard extends PureComponent {
|
|
|
222
234
|
size: "small",
|
|
223
235
|
orbitStroke: '#FFF',
|
|
224
236
|
"aria-label": "uploading file progress"
|
|
225
|
-
}) : null, showRetry ? retry : null, showReplace && replace, showPicInfo && picInfo, !disabled &&
|
|
226
|
-
className: closeCls,
|
|
227
|
-
onClick: e => this.onRemove(e)
|
|
228
|
-
}, /*#__PURE__*/React.createElement(IconClose, {
|
|
229
|
-
tabIndex: 0,
|
|
230
|
-
role: "button",
|
|
231
|
-
size: "extra-small"
|
|
232
|
-
})), this.renderPicValidateMsg());
|
|
237
|
+
}) : null, showRetry ? retry : null, showReplace && replace, showPreview && preview, showPicInfo && picInfo, !disabled && close, this.renderPicValidateMsg());
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
renderFile(locale) {
|
|
@@ -244,7 +249,8 @@ class FileCard extends PureComponent {
|
|
|
244
249
|
previewFile,
|
|
245
250
|
status,
|
|
246
251
|
style,
|
|
247
|
-
onPreviewClick
|
|
252
|
+
onPreviewClick,
|
|
253
|
+
renderFileOperation
|
|
248
254
|
} = this.props;
|
|
249
255
|
const fileCardCls = cls({
|
|
250
256
|
["".concat(prefixCls, "-file-card")]: true,
|
|
@@ -274,6 +280,14 @@ class FileCard extends PureComponent {
|
|
|
274
280
|
previewContent = previewFile(this.props);
|
|
275
281
|
}
|
|
276
282
|
|
|
283
|
+
const operation = typeof renderFileOperation === 'function' ? renderFileOperation(this.props) : /*#__PURE__*/React.createElement(Button, {
|
|
284
|
+
onClick: e => this.onRemove(e),
|
|
285
|
+
type: "tertiary",
|
|
286
|
+
icon: /*#__PURE__*/React.createElement(IconClose, null),
|
|
287
|
+
theme: "borderless",
|
|
288
|
+
size: "small",
|
|
289
|
+
className: closeCls
|
|
290
|
+
});
|
|
277
291
|
return /*#__PURE__*/React.createElement("div", {
|
|
278
292
|
role: "listitem",
|
|
279
293
|
className: fileCardCls,
|
|
@@ -294,7 +308,7 @@ class FileCard extends PureComponent {
|
|
|
294
308
|
position: "top",
|
|
295
309
|
showArrow: false,
|
|
296
310
|
content: locale.replace
|
|
297
|
-
}, /*#__PURE__*/React.createElement(
|
|
311
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
298
312
|
onClick: e => this.onReplace(e),
|
|
299
313
|
type: "tertiary",
|
|
300
314
|
theme: "borderless",
|
|
@@ -316,29 +330,22 @@ class FileCard extends PureComponent {
|
|
|
316
330
|
tabIndex: 0,
|
|
317
331
|
className: "".concat(infoCls, "-retry"),
|
|
318
332
|
onClick: e => this.onRetry(e)
|
|
319
|
-
}, locale.retry) : null)),
|
|
320
|
-
onClick: e => this.onRemove(e),
|
|
321
|
-
type: "tertiary",
|
|
322
|
-
icon: /*#__PURE__*/React.createElement(IconClose, null),
|
|
323
|
-
theme: "borderless",
|
|
324
|
-
size: "small",
|
|
325
|
-
className: closeCls
|
|
326
|
-
}));
|
|
333
|
+
}, locale.retry) : null)), operation);
|
|
327
334
|
}
|
|
328
335
|
|
|
329
336
|
onRemove(e) {
|
|
330
337
|
e.stopPropagation();
|
|
331
|
-
this.props.onRemove(
|
|
338
|
+
this.props.onRemove();
|
|
332
339
|
}
|
|
333
340
|
|
|
334
341
|
onReplace(e) {
|
|
335
342
|
e.stopPropagation();
|
|
336
|
-
this.props.onReplace(
|
|
343
|
+
this.props.onReplace();
|
|
337
344
|
}
|
|
338
345
|
|
|
339
346
|
onRetry(e) {
|
|
340
347
|
e.stopPropagation();
|
|
341
|
-
this.props.onRetry(
|
|
348
|
+
this.props.onRetry();
|
|
342
349
|
}
|
|
343
350
|
|
|
344
351
|
render() {
|
package/lib/es/upload/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface UploadProps {
|
|
|
29
29
|
fileList?: Array<FileItem>;
|
|
30
30
|
fileName?: string;
|
|
31
31
|
headers?: Record<string, any> | ((file: File) => Record<string, string>);
|
|
32
|
+
hotSpotLocation?: 'start' | 'end';
|
|
32
33
|
itemStyle?: CSSProperties;
|
|
33
34
|
limit?: number;
|
|
34
35
|
listType?: UploadListType;
|
|
@@ -56,6 +57,8 @@ export interface UploadProps {
|
|
|
56
57
|
renderFileItem?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
57
58
|
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
58
59
|
renderThumbnail?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
60
|
+
renderPicPreviewIcon?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
61
|
+
renderFileOperation?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
59
62
|
showClear?: boolean;
|
|
60
63
|
showPicInfo?: boolean;
|
|
61
64
|
showReplace?: boolean;
|
|
@@ -99,6 +102,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
99
102
|
fileList: PropTypes.Requireable<any[]>;
|
|
100
103
|
fileName: PropTypes.Requireable<string>;
|
|
101
104
|
headers: PropTypes.Requireable<object>;
|
|
105
|
+
hotSpotLocation: PropTypes.Requireable<string>;
|
|
102
106
|
itemStyle: PropTypes.Requireable<object>;
|
|
103
107
|
limit: PropTypes.Requireable<number>;
|
|
104
108
|
listType: PropTypes.Requireable<"picture" | "list">;
|
|
@@ -124,6 +128,8 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
124
128
|
prompt: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
125
129
|
promptPosition: PropTypes.Requireable<"left" | "right" | "bottom">;
|
|
126
130
|
renderFileItem: PropTypes.Requireable<(...args: any[]) => any>;
|
|
131
|
+
renderPicPreviewIcon: PropTypes.Requireable<(...args: any[]) => any>;
|
|
132
|
+
renderFileOperation: PropTypes.Requireable<(...args: any[]) => any>;
|
|
127
133
|
renderPicInfo: PropTypes.Requireable<(...args: any[]) => any>;
|
|
128
134
|
renderThumbnail: PropTypes.Requireable<(...args: any[]) => any>;
|
|
129
135
|
showClear: PropTypes.Requireable<boolean>;
|
package/lib/es/upload/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _pick from "lodash/pick";
|
|
1
2
|
import _noop from "lodash/noop";
|
|
2
3
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
4
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
@@ -111,14 +112,14 @@ class Upload extends BaseComponent {
|
|
|
111
112
|
previewFile,
|
|
112
113
|
listType,
|
|
113
114
|
itemStyle,
|
|
114
|
-
showRetry,
|
|
115
115
|
showPicInfo,
|
|
116
116
|
renderPicInfo,
|
|
117
|
+
renderPicPreviewIcon,
|
|
118
|
+
renderFileOperation,
|
|
117
119
|
renderFileItem,
|
|
118
120
|
renderThumbnail,
|
|
119
121
|
disabled,
|
|
120
|
-
onPreviewClick
|
|
121
|
-
showReplace
|
|
122
|
+
onPreviewClick
|
|
122
123
|
} = this.props;
|
|
123
124
|
|
|
124
125
|
const onRemove = () => this.remove(file);
|
|
@@ -131,20 +132,20 @@ class Upload extends BaseComponent {
|
|
|
131
132
|
this.replace(index);
|
|
132
133
|
};
|
|
133
134
|
|
|
134
|
-
const fileCardProps = _Object$assign(_Object$assign({}, file), {
|
|
135
|
+
const fileCardProps = _Object$assign(_Object$assign(_Object$assign({}, _pick(this.props, ['showRetry', 'showReplace', ''])), file), {
|
|
135
136
|
previewFile,
|
|
136
137
|
listType,
|
|
137
138
|
onRemove,
|
|
138
139
|
onRetry,
|
|
139
140
|
index,
|
|
140
141
|
key: uid || _concatInstanceProperty(_context = "".concat(name)).call(_context, index),
|
|
141
|
-
showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
|
|
142
142
|
style: itemStyle,
|
|
143
143
|
disabled,
|
|
144
144
|
showPicInfo,
|
|
145
145
|
renderPicInfo,
|
|
146
|
+
renderPicPreviewIcon,
|
|
147
|
+
renderFileOperation,
|
|
146
148
|
renderThumbnail,
|
|
147
|
-
showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
|
|
148
149
|
onReplace,
|
|
149
150
|
onPreviewClick: typeof onPreviewClick !== 'undefined' ? () => this.foundation.handlePreviewClick(file) : undefined
|
|
150
151
|
});
|
|
@@ -186,7 +187,8 @@ class Upload extends BaseComponent {
|
|
|
186
187
|
limit,
|
|
187
188
|
disabled,
|
|
188
189
|
children,
|
|
189
|
-
draggable
|
|
190
|
+
draggable,
|
|
191
|
+
hotSpotLocation
|
|
190
192
|
} = this.props;
|
|
191
193
|
const {
|
|
192
194
|
fileList: stateFileList,
|
|
@@ -244,7 +246,7 @@ class Upload extends BaseComponent {
|
|
|
244
246
|
className: mainCls,
|
|
245
247
|
role: "list",
|
|
246
248
|
"aria-label": "picture list"
|
|
247
|
-
}, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
|
|
249
|
+
}, showAddTriggerInList && hotSpotLocation === 'start' ? addContent : null, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList && hotSpotLocation === 'end' ? addContent : null)));
|
|
248
250
|
};
|
|
249
251
|
|
|
250
252
|
this.renderFileListDefault = () => {
|
|
@@ -584,6 +586,7 @@ Upload.propTypes = {
|
|
|
584
586
|
fileList: PropTypes.array,
|
|
585
587
|
fileName: PropTypes.string,
|
|
586
588
|
headers: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
589
|
+
hotSpotLocation: PropTypes.oneOf(['start', 'end']),
|
|
587
590
|
itemStyle: PropTypes.object,
|
|
588
591
|
limit: PropTypes.number,
|
|
589
592
|
listType: PropTypes.oneOf(strings.LIST_TYPE),
|
|
@@ -609,6 +612,8 @@ Upload.propTypes = {
|
|
|
609
612
|
prompt: PropTypes.node,
|
|
610
613
|
promptPosition: PropTypes.oneOf(strings.PROMPT_POSITION),
|
|
611
614
|
renderFileItem: PropTypes.func,
|
|
615
|
+
renderPicPreviewIcon: PropTypes.func,
|
|
616
|
+
renderFileOperation: PropTypes.func,
|
|
612
617
|
renderPicInfo: PropTypes.func,
|
|
613
618
|
renderThumbnail: PropTypes.func,
|
|
614
619
|
showClear: PropTypes.bool,
|
|
@@ -628,6 +633,7 @@ Upload.defaultProps = {
|
|
|
628
633
|
defaultFileList: [],
|
|
629
634
|
disabled: false,
|
|
630
635
|
listType: 'list',
|
|
636
|
+
hotSpotLocation: 'end',
|
|
631
637
|
multiple: false,
|
|
632
638
|
onAcceptInvalid: _noop,
|
|
633
639
|
onChange: _noop,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, CSSProperties
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
import { BaseFileItem } from '@douyinfe/semi-foundation/lib/es/upload/foundation';
|
|
3
3
|
import { strings } from '@douyinfe/semi-foundation/lib/es/upload/constants';
|
|
4
4
|
import { ArrayElement } from '../_base/base';
|
|
@@ -45,14 +45,16 @@ export interface RenderFileItemProps extends FileItem {
|
|
|
45
45
|
index?: number;
|
|
46
46
|
previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
47
47
|
listType: UploadListType;
|
|
48
|
-
onRemove: (
|
|
49
|
-
onRetry: (
|
|
50
|
-
onReplace: (
|
|
48
|
+
onRemove: () => void;
|
|
49
|
+
onRetry: () => void;
|
|
50
|
+
onReplace: () => void;
|
|
51
51
|
key: string;
|
|
52
52
|
showPicInfo?: boolean;
|
|
53
53
|
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
renderPicPreviewIcon?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
55
|
+
renderFileOperation?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
56
|
+
showRetry?: boolean;
|
|
57
|
+
showReplace?: boolean;
|
|
56
58
|
style?: CSSProperties;
|
|
57
59
|
disabled: boolean;
|
|
58
60
|
onPreviewClick: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-beta.0",
|
|
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.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.
|
|
20
|
-
"@douyinfe/semi-icons": "2.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.
|
|
17
|
+
"@douyinfe/semi-animation": "2.5.0-beta.0",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.5.0-beta.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.5.0-beta.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.5.0-beta.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.5.0-beta.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.5.0-beta.0",
|
|
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": "d71dddacba0c96004c19103f2e0d3cb59ac52857",
|
|
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.
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.5.0-beta.0",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
package/select/option.tsx
CHANGED
|
@@ -57,8 +57,8 @@ class Option extends PureComponent<OptionProps> {
|
|
|
57
57
|
|
|
58
58
|
onClick({ value, label, children, ...rest }: Partial<OptionProps>, event: React.MouseEvent) {
|
|
59
59
|
const { props } = this;
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
60
|
+
const isDisabled = props.disabled;
|
|
61
|
+
if (!isDisabled) {
|
|
62
62
|
props.onSelect({ ...rest, value, label: label || children }, event);
|
|
63
63
|
}
|
|
64
64
|
}
|
package/table/Table.tsx
CHANGED
|
@@ -424,11 +424,12 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
424
424
|
willUpdateStates.cachedColumns = props.columns;
|
|
425
425
|
willUpdateStates.cachedChildren = null;
|
|
426
426
|
} else if (props.children && props.children !== state.cachedChildren) {
|
|
427
|
-
const
|
|
427
|
+
const newNestedColumns = getColumns(props.children);
|
|
428
|
+
const newFlattenColumns = flattenColumns(newNestedColumns);
|
|
428
429
|
const columns = mergeColumns(state.queries, newFlattenColumns, null, false);
|
|
429
430
|
willUpdateStates.flattenColumns = newFlattenColumns;
|
|
430
431
|
willUpdateStates.queries = [...columns];
|
|
431
|
-
willUpdateStates.cachedColumns = [...
|
|
432
|
+
willUpdateStates.cachedColumns = [...newNestedColumns];
|
|
432
433
|
willUpdateStates.cachedChildren = props.children;
|
|
433
434
|
}
|
|
434
435
|
|
|
@@ -943,11 +944,15 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
943
944
|
titleArr.push(sorter);
|
|
944
945
|
}
|
|
945
946
|
|
|
947
|
+
const stateFilteredValue = get(curQuery, 'filteredValue');
|
|
948
|
+
const defaultFilteredValue = get(curQuery, 'defaultFilteredValue');
|
|
949
|
+
const filteredValue = stateFilteredValue ? stateFilteredValue : defaultFilteredValue;
|
|
946
950
|
if ((Array.isArray(column.filters) && column.filters.length) || isValidElement(column.filterDropdown)) {
|
|
947
951
|
const filter = (
|
|
948
952
|
<ColumnFilter
|
|
949
953
|
key={strings.DEFAULT_KEY_COLUMN_FILTER}
|
|
950
954
|
{...curQuery}
|
|
955
|
+
filteredValue={filteredValue}
|
|
951
956
|
onFilterDropdownVisibleChange={(visible: boolean) => this.foundation.toggleShowFilter(dataIndex, visible)}
|
|
952
957
|
onSelect={(data: OnSelectData) => this.foundation.handleFilterSelect(dataIndex, data)}
|
|
953
958
|
/>
|
|
@@ -76,8 +76,7 @@ export { default as ScrollBar } from './ScrollBar';
|
|
|
76
76
|
export { default as TableSpan } from './TableSpan';
|
|
77
77
|
export { default as FixRenderReturnProps } from './FixRenderReturnProps';
|
|
78
78
|
export { default as WarnColumnWithoutDataIndex } from './WarnColumnWithoutDataIndex';
|
|
79
|
-
export
|
|
80
|
-
export { default as FixedZIndex } from './v2/FixedZIndex';
|
|
79
|
+
export * from './v2';
|
|
81
80
|
|
|
82
81
|
// empty table
|
|
83
82
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Table, Button } from '@douyinfe/semi-ui';
|
|
3
|
+
|
|
4
|
+
Demo.storyName = "fixed jsx column nested bug";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* fixed https://github.com/DouyinFE/semi-design/issues/619
|
|
9
|
+
*
|
|
10
|
+
* Test with Cypress
|
|
11
|
+
*/
|
|
12
|
+
export default function Demo() {
|
|
13
|
+
const columns = [
|
|
14
|
+
{
|
|
15
|
+
title: 'Base Information',
|
|
16
|
+
fixed: 'left',
|
|
17
|
+
children: [
|
|
18
|
+
{
|
|
19
|
+
title: 'Name',
|
|
20
|
+
dataIndex: 'name',
|
|
21
|
+
width: 200,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: 'Age',
|
|
25
|
+
dataIndex: 'age',
|
|
26
|
+
width: 100,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: 'Company Information',
|
|
32
|
+
children: [
|
|
33
|
+
{
|
|
34
|
+
title: 'Company Name',
|
|
35
|
+
dataIndex: 'company.name',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'Company Address',
|
|
39
|
+
dataIndex: 'company.address',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const data = useMemo(() => {
|
|
46
|
+
const data = [];
|
|
47
|
+
for (let i = 0; i < 100; i++) {
|
|
48
|
+
let age = 40 + (Math.random() > 0.5 ? 1 : -1) * (i % 9);
|
|
49
|
+
let name = `Edward King ${i}`;
|
|
50
|
+
data.push({
|
|
51
|
+
key: '' + i,
|
|
52
|
+
company: {
|
|
53
|
+
name: 'ByteDance',
|
|
54
|
+
address: 'No. 48, Zhichun Road',
|
|
55
|
+
},
|
|
56
|
+
name,
|
|
57
|
+
age,
|
|
58
|
+
address: `No ${i + 1}, Zhongguancun Street`,
|
|
59
|
+
description: `My name is ${name}, I am ${age} years old, living in No ${i + 1}, Zhongguancun Street`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return data;
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const [flag, setFlag] = React.useState(true);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<Button data-cy="button" onClick={()=> setFlag(!flag)}>reRender</Button>
|
|
70
|
+
<Table dataSource={data} pagination={true} size="small">
|
|
71
|
+
{columns.map((item, titleIndex) =>
|
|
72
|
+
(
|
|
73
|
+
<Table.Column
|
|
74
|
+
key={titleIndex}
|
|
75
|
+
title={item.title}
|
|
76
|
+
>
|
|
77
|
+
{item.children.map(
|
|
78
|
+
(childItem, columnIndex) =>
|
|
79
|
+
(
|
|
80
|
+
<Table.Column
|
|
81
|
+
title={childItem.title}
|
|
82
|
+
dataIndex={childItem.dataIndex}
|
|
83
|
+
key={titleIndex.toString() + columnIndex.toString()}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
)}
|
|
87
|
+
</Table.Column>
|
|
88
|
+
)
|
|
89
|
+
)}
|
|
90
|
+
<Table.Column
|
|
91
|
+
title=""
|
|
92
|
+
key="lastColumn"
|
|
93
|
+
render={() => 123}
|
|
94
|
+
/>
|
|
95
|
+
</Table>
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { Table, Avatar, Button } from '@douyinfe/semi-ui';
|
|
3
|
+
import * as dateFns from 'date-fns';
|
|
4
|
+
import { ColumnProps, ChangeInfoFilter } from '@douyinfe/semi-ui/table';
|
|
5
|
+
|
|
6
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
7
|
+
const figmaIconUrl = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png';
|
|
8
|
+
|
|
9
|
+
function App() {
|
|
10
|
+
const [dataSource, setData] = useState([]);
|
|
11
|
+
const [filteredValue, setFilteredValue] = useState(['Semi Pro 设计稿']);
|
|
12
|
+
|
|
13
|
+
const scroll = useMemo(() => ({ y: 300 }), []);
|
|
14
|
+
|
|
15
|
+
const columns: ColumnProps[] = [
|
|
16
|
+
{
|
|
17
|
+
title: '标题',
|
|
18
|
+
dataIndex: 'name',
|
|
19
|
+
width: 400,
|
|
20
|
+
render: (text, record, index) => {
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<Avatar size="small" shape="square" src={figmaIconUrl} style={{ marginRight: 12 }}></Avatar>
|
|
24
|
+
{text}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
filters: [
|
|
29
|
+
{
|
|
30
|
+
text: 'Semi Design 设计稿',
|
|
31
|
+
value: 'Semi Design 设计稿',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
text: 'Semi Pro 设计稿',
|
|
35
|
+
value: 'Semi Pro 设计稿',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
onFilter: (value, record) => record.name.includes(value),
|
|
39
|
+
sorter: (a, b) => a.name.length - b.name.length > 0 ? 1 : -1,
|
|
40
|
+
// filterMultiple: false,
|
|
41
|
+
// filteredValue: filteredValue,
|
|
42
|
+
defaultFilteredValue: filteredValue,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: '大小',
|
|
46
|
+
dataIndex: 'size',
|
|
47
|
+
sorter: (a, b) => a.size - b.size > 0 ? 1 : -1,
|
|
48
|
+
render: (text) => `${text} KB`
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: '所有者',
|
|
52
|
+
dataIndex: 'owner',
|
|
53
|
+
render: (text, record, index) => {
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>{typeof text === 'string' && text.slice(0, 1)}</Avatar>
|
|
57
|
+
{text}
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: '更新日期',
|
|
65
|
+
dataIndex: 'updateTime',
|
|
66
|
+
sorter: (a, b) => a.updateTime - b.updateTime > 0 ? 1 : -1,
|
|
67
|
+
render: (value) => {
|
|
68
|
+
return dateFns.format(new Date(value), 'yyyy-MM-dd');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const getData = (total) => {
|
|
74
|
+
const data = [];
|
|
75
|
+
for (let i = 0; i < total; i++) {
|
|
76
|
+
const isSemiDesign = i % 2 === 0;
|
|
77
|
+
const randomNumber = (i * 1000) % 199;
|
|
78
|
+
data.push({
|
|
79
|
+
key: '' + i,
|
|
80
|
+
name: isSemiDesign ? `Semi Design 设计稿${i}.fig` : `Semi Pro 设计稿${i}.fig`,
|
|
81
|
+
owner: isSemiDesign ? '姜鹏志' : '郝宣',
|
|
82
|
+
size: randomNumber,
|
|
83
|
+
updateTime: new Date().valueOf() + randomNumber * DAY,
|
|
84
|
+
avatarBg: isSemiDesign ? 'grey' : 'red'
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return data;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const handleFilterChange = (filters: ChangeInfoFilter<any>[]) => {
|
|
91
|
+
console.log('filters', filters);
|
|
92
|
+
if (Array.isArray(filters) && filters.length) {
|
|
93
|
+
const { filteredValue } = filters.find(filter => filter.dataIndex === 'name');
|
|
94
|
+
setFilteredValue(filteredValue);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleChange = (options) => {
|
|
99
|
+
const { filters } = options;
|
|
100
|
+
handleFilterChange(filters);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const toggleChangeData = () => {
|
|
104
|
+
const length = dataSource.length;
|
|
105
|
+
const newData = getData(length === 46 ? 25 : 46);
|
|
106
|
+
setData(newData);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
const data = getData(46);
|
|
111
|
+
setData(data);
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div>
|
|
116
|
+
<Button onClick={toggleChangeData}>toggle change dataSource (46/25)</Button>
|
|
117
|
+
<Table columns={columns} dataSource={dataSource} scroll={scroll} onChange={handleChange} />
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
App.storyName = 'defaultFilteredValue';
|
|
123
|
+
export default App;
|
package/table/interface.ts
CHANGED
|
@@ -79,6 +79,7 @@ export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
|
79
79
|
className?: string;
|
|
80
80
|
colSpan?: number;
|
|
81
81
|
dataIndex?: string;
|
|
82
|
+
defaultFilteredValue?: any[];
|
|
82
83
|
defaultSortOrder?: SortOrder;
|
|
83
84
|
filterChildrenRecord?: boolean;
|
|
84
85
|
filterDropdown?: React.ReactNode;
|