@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
package/upload/fileCard.tsx
CHANGED
|
@@ -3,11 +3,11 @@ import cls from 'classnames';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/upload/constants';
|
|
5
5
|
import { getFileSize } from '@douyinfe/semi-foundation/upload/utils';
|
|
6
|
-
import { IconAlertCircle, IconClose, IconFile, IconRefresh } from '@douyinfe/semi-icons';
|
|
6
|
+
import { IconAlertCircle, IconClose, IconClear, IconFile, IconRefresh, IconEyeOpened } from '@douyinfe/semi-icons';
|
|
7
7
|
import LocaleConsumer from '../locale/localeConsumer';
|
|
8
8
|
import { Locale } from '../locale/interface';
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import Button from '../button/index';
|
|
11
11
|
import Progress from '../progress/index';
|
|
12
12
|
import Tooltip from '../tooltip/index';
|
|
13
13
|
import Spin from '../spin/index';
|
|
@@ -123,10 +123,11 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
renderPic(locale: Locale['Upload']): ReactNode {
|
|
126
|
-
const { url, percent, status, disabled, style, onPreviewClick, showPicInfo, renderPicInfo, renderThumbnail, name, index } = this.props;
|
|
126
|
+
const { url, percent, status, disabled, style, onPreviewClick, showPicInfo, renderPicInfo, renderPicPreviewIcon, renderThumbnail, name, index } = this.props;
|
|
127
127
|
const showProgress = status === strings.FILE_STATUS_UPLOADING && percent !== 100;
|
|
128
128
|
const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
|
|
129
129
|
const showReplace = status === strings.FILE_STATUS_SUCCESS && this.props.showReplace;
|
|
130
|
+
const showPreview = status === strings.FILE_STATUS_SUCCESS && !this.props.showReplace;
|
|
130
131
|
const filePicCardCls = cls({
|
|
131
132
|
[`${prefixCls}-picture-file-card`]: true,
|
|
132
133
|
[`${prefixCls}-picture-file-card-disabled`]: disabled,
|
|
@@ -134,7 +135,6 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
134
135
|
[`${prefixCls}-picture-file-card-error`]: status === strings.FILE_STATUS_UPLOAD_FAIL,
|
|
135
136
|
[`${prefixCls}-picture-file-card-uploading`]: showProgress
|
|
136
137
|
});
|
|
137
|
-
const closeCls = `${prefixCls}-picture-file-card-close`;
|
|
138
138
|
const retry = (
|
|
139
139
|
<div role="button" tabIndex={0} className={`${prefixCls}-picture-file-card-retry`} onClick={e => this.onRetry(e)}>
|
|
140
140
|
<IconRefresh className={`${prefixCls}-picture-file-card-icon-retry`} />
|
|
@@ -146,7 +146,16 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
146
146
|
<ReplaceSvg className={`${prefixCls}-picture-file-card-icon-replace`} />
|
|
147
147
|
</div>
|
|
148
148
|
</Tooltip>
|
|
149
|
-
|
|
149
|
+
);
|
|
150
|
+
const preview = (
|
|
151
|
+
<div className={`${prefixCls}-picture-file-card-preview`}>
|
|
152
|
+
{typeof renderPicPreviewIcon === 'function'? renderPicPreviewIcon(this.props): null}
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
const close = (
|
|
156
|
+
<div role="button" tabIndex={0} className={`${prefixCls}-picture-file-card-close`} onClick={e => this.onRemove(e)}>
|
|
157
|
+
<IconClear className={`${prefixCls}-picture-file-card-icon-close`} />
|
|
158
|
+
</div>
|
|
150
159
|
);
|
|
151
160
|
|
|
152
161
|
const picInfo = typeof renderPicInfo === 'function' ? renderPicInfo(this.props) : (
|
|
@@ -161,19 +170,16 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
161
170
|
{showProgress ? <Progress percent={percent} type="circle" size="small" orbitStroke={'#FFF'} aria-label="uploading file progress" /> : null}
|
|
162
171
|
{showRetry ? retry : null}
|
|
163
172
|
{showReplace && replace}
|
|
173
|
+
{showPreview && preview}
|
|
164
174
|
{showPicInfo && picInfo}
|
|
165
|
-
{!disabled &&
|
|
166
|
-
<div className={closeCls} onClick={e => this.onRemove(e)}>
|
|
167
|
-
<IconClose tabIndex={0} role="button" size="extra-small" />
|
|
168
|
-
</div>
|
|
169
|
-
)}
|
|
175
|
+
{!disabled && close}
|
|
170
176
|
{this.renderPicValidateMsg()}
|
|
171
177
|
</div>
|
|
172
178
|
);
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
renderFile(locale: Locale["Upload"]) {
|
|
176
|
-
const { name, size, percent, url, showRetry: propsShowRetry, showReplace: propsShowReplace, preview, previewFile, status, style, onPreviewClick } = this.props;
|
|
182
|
+
const { name, size, percent, url, showRetry: propsShowRetry, showReplace: propsShowReplace, preview, previewFile, status, style, onPreviewClick, renderFileOperation } = this.props;
|
|
177
183
|
const fileCardCls = cls({
|
|
178
184
|
[`${prefixCls}-file-card`]: true,
|
|
179
185
|
[`${prefixCls}-file-card-fail`]: status === strings.FILE_STATUS_VALID_FAIL || status === strings.FILE_STATUS_UPLOAD_FAIL,
|
|
@@ -195,6 +201,7 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
195
201
|
if (previewFile) {
|
|
196
202
|
previewContent = previewFile(this.props);
|
|
197
203
|
}
|
|
204
|
+
const operation = typeof renderFileOperation === 'function'? renderFileOperation(this.props) : <Button onClick={e => this.onRemove(e)} type="tertiary" icon={<IconClose />} theme="borderless" size="small" className={closeCls} />;
|
|
198
205
|
return (
|
|
199
206
|
<div role="listitem" className={fileCardCls} style={style} onClick={onPreviewClick}>
|
|
200
207
|
<div className={previewCls}>
|
|
@@ -209,7 +216,7 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
209
216
|
<span className={`${infoCls}-size`}>{fileSize}</span>
|
|
210
217
|
{showReplace && (
|
|
211
218
|
<Tooltip trigger="hover" position="top" showArrow={false} content={locale.replace}>
|
|
212
|
-
<
|
|
219
|
+
<Button
|
|
213
220
|
onClick={e => this.onReplace(e)}
|
|
214
221
|
type="tertiary"
|
|
215
222
|
theme="borderless"
|
|
@@ -231,31 +238,24 @@ class FileCard extends PureComponent<FileCardProps> {
|
|
|
231
238
|
{showRetry ? <span role="button" tabIndex={0} className={`${infoCls}-retry`} onClick={e => this.onRetry(e)}>{locale.retry}</span> : null}
|
|
232
239
|
</div>
|
|
233
240
|
</div>
|
|
234
|
-
|
|
235
|
-
onClick={e => this.onRemove(e)}
|
|
236
|
-
type="tertiary"
|
|
237
|
-
icon={<IconClose />}
|
|
238
|
-
theme="borderless"
|
|
239
|
-
size="small"
|
|
240
|
-
className={closeCls}
|
|
241
|
-
/>
|
|
241
|
+
{operation}
|
|
242
242
|
</div>
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
onRemove(e: MouseEvent): void {
|
|
247
247
|
e.stopPropagation();
|
|
248
|
-
this.props.onRemove(
|
|
248
|
+
this.props.onRemove();
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
onReplace(e: MouseEvent): void {
|
|
252
252
|
e.stopPropagation();
|
|
253
|
-
this.props.onReplace(
|
|
253
|
+
this.props.onReplace();
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
onRetry(e: MouseEvent): void {
|
|
257
257
|
e.stopPropagation();
|
|
258
|
-
this.props.onRetry(
|
|
258
|
+
this.props.onRetry();
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
render() {
|
package/upload/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { ReactNode, CSSProperties, RefObject, ChangeEvent, DragEvent } from 'react';
|
|
3
3
|
import cls from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { noop } from 'lodash';
|
|
5
|
+
import { noop, pick } from 'lodash';
|
|
6
6
|
import UploadFoundation, { CustomFile, UploadAdapter, BeforeUploadObjectResult, AfterUploadResult } from '@douyinfe/semi-foundation/upload/foundation';
|
|
7
7
|
import { strings, cssClasses } from '@douyinfe/semi-foundation/upload/constants';
|
|
8
8
|
import FileCard from './fileCard';
|
|
@@ -39,6 +39,7 @@ export interface UploadProps {
|
|
|
39
39
|
fileList?: Array<FileItem>;
|
|
40
40
|
fileName?: string;
|
|
41
41
|
headers?: Record<string, any> | ((file: File) => Record<string, string>);
|
|
42
|
+
hotSpotLocation?: 'start' | 'end';
|
|
42
43
|
itemStyle?: CSSProperties;
|
|
43
44
|
limit?: number;
|
|
44
45
|
listType?: UploadListType;
|
|
@@ -66,6 +67,8 @@ export interface UploadProps {
|
|
|
66
67
|
renderFileItem?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
67
68
|
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
68
69
|
renderThumbnail?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
70
|
+
renderPicPreviewIcon?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
71
|
+
renderFileOperation?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
69
72
|
showClear?: boolean;
|
|
70
73
|
showPicInfo?: boolean; // Show pic info in picture wall
|
|
71
74
|
showReplace?: boolean; // Display replacement function
|
|
@@ -111,6 +114,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
111
114
|
fileList: PropTypes.array, // files had been uploaded
|
|
112
115
|
fileName: PropTypes.string, // same as name, to avoid props conflict in Form.Upload
|
|
113
116
|
headers: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
117
|
+
hotSpotLocation: PropTypes.oneOf(['start','end']),
|
|
114
118
|
itemStyle: PropTypes.object,
|
|
115
119
|
limit: PropTypes.number, // 最大允许上传文件个数
|
|
116
120
|
listType: PropTypes.oneOf<UploadProps['listType']>(strings.LIST_TYPE),
|
|
@@ -136,6 +140,8 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
136
140
|
prompt: PropTypes.node,
|
|
137
141
|
promptPosition: PropTypes.oneOf<UploadProps['promptPosition']>(strings.PROMPT_POSITION),
|
|
138
142
|
renderFileItem: PropTypes.func,
|
|
143
|
+
renderPicPreviewIcon: PropTypes.func,
|
|
144
|
+
renderFileOperation: PropTypes.func,
|
|
139
145
|
renderPicInfo: PropTypes.func,
|
|
140
146
|
renderThumbnail: PropTypes.func,
|
|
141
147
|
showClear: PropTypes.bool,
|
|
@@ -156,6 +162,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
156
162
|
defaultFileList: [],
|
|
157
163
|
disabled: false,
|
|
158
164
|
listType: 'list' as const,
|
|
165
|
+
hotSpotLocation: 'end',
|
|
159
166
|
multiple: false,
|
|
160
167
|
onAcceptInvalid: noop,
|
|
161
168
|
onChange: noop,
|
|
@@ -326,7 +333,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
326
333
|
|
|
327
334
|
renderFile = (file: FileItem, index: number, locale: Locale['Upload']): ReactNode => {
|
|
328
335
|
const { name, status, validateMessage, _sizeInvalid, uid } = file;
|
|
329
|
-
const { previewFile, listType, itemStyle,
|
|
336
|
+
const { previewFile, listType, itemStyle, showPicInfo, renderPicInfo, renderPicPreviewIcon, renderFileOperation, renderFileItem, renderThumbnail, disabled, onPreviewClick } = this.props;
|
|
330
337
|
const onRemove = (): void => this.remove(file);
|
|
331
338
|
const onRetry = (): void => {
|
|
332
339
|
this.foundation.retry(file);
|
|
@@ -335,6 +342,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
335
342
|
this.replace(index);
|
|
336
343
|
};
|
|
337
344
|
const fileCardProps = {
|
|
345
|
+
...pick(this.props, ['showRetry', 'showReplace', '']),
|
|
338
346
|
...file,
|
|
339
347
|
previewFile,
|
|
340
348
|
listType,
|
|
@@ -342,13 +350,13 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
342
350
|
onRetry,
|
|
343
351
|
index,
|
|
344
352
|
key: uid || `${name}${index}`,
|
|
345
|
-
showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
|
|
346
353
|
style: itemStyle,
|
|
347
354
|
disabled,
|
|
348
355
|
showPicInfo,
|
|
349
356
|
renderPicInfo,
|
|
357
|
+
renderPicPreviewIcon,
|
|
358
|
+
renderFileOperation,
|
|
350
359
|
renderThumbnail,
|
|
351
|
-
showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
|
|
352
360
|
onReplace,
|
|
353
361
|
onPreviewClick: typeof onPreviewClick !== 'undefined' ? (): void => this.foundation.handlePreviewClick(file) : undefined,
|
|
354
362
|
};
|
|
@@ -382,7 +390,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
382
390
|
};
|
|
383
391
|
|
|
384
392
|
renderFileListPic = () => {
|
|
385
|
-
const { showUploadList, limit, disabled, children, draggable } = this.props;
|
|
393
|
+
const { showUploadList, limit, disabled, children, draggable, hotSpotLocation } = this.props;
|
|
386
394
|
const { fileList: stateFileList, dragAreaStatus } = this.state;
|
|
387
395
|
const fileList = this.props.fileList || stateFileList;
|
|
388
396
|
const showAddTriggerInList = limit ? limit > fileList.length : true;
|
|
@@ -434,8 +442,9 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
434
442
|
{(locale: Locale['Upload']) => (
|
|
435
443
|
<div {...containerProps}>
|
|
436
444
|
<div className={mainCls} role="list" aria-label="picture list">
|
|
445
|
+
{showAddTriggerInList && hotSpotLocation === 'start' ? addContent : null}
|
|
437
446
|
{fileList.map((file, index) => this.renderFile(file, index, locale))}
|
|
438
|
-
{showAddTriggerInList ? addContent : null}
|
|
447
|
+
{showAddTriggerInList && hotSpotLocation === 'end' ? addContent : null}
|
|
439
448
|
</div>
|
|
440
449
|
</div>
|
|
441
450
|
)}
|
package/upload/interface.ts
CHANGED
|
@@ -48,14 +48,16 @@ export interface RenderFileItemProps extends FileItem {
|
|
|
48
48
|
index?: number;
|
|
49
49
|
previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
50
50
|
listType: UploadListType;
|
|
51
|
-
onRemove: (
|
|
52
|
-
onRetry: (
|
|
53
|
-
onReplace: (
|
|
51
|
+
onRemove: () => void;
|
|
52
|
+
onRetry: () => void;
|
|
53
|
+
onReplace: () => void;
|
|
54
54
|
key: string;
|
|
55
55
|
showPicInfo?: boolean;
|
|
56
56
|
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
renderPicPreviewIcon?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
58
|
+
renderFileOperation?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
59
|
+
showRetry?: boolean;
|
|
60
|
+
showReplace?: boolean;
|
|
59
61
|
style?: CSSProperties;
|
|
60
62
|
disabled: boolean;
|
|
61
63
|
onPreviewClick: () => void;
|