@douyinfe/semi-ui 2.3.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/datePicker/_story/RenderDate/index.js +13 -3
- package/datePicker/_story/RenderFullDate/index.js +36 -14
- package/datePicker/_story/RenderFullDate/index.scss +1 -1
- package/datePicker/_story/datePicker.stories.js +19 -11
- package/datePicker/_story/v2/PanelOpen.jsx +39 -0
- package/datePicker/_story/v2/index.js +2 -1
- package/datePicker/datePicker.tsx +1 -0
- package/dist/css/semi.css +84 -36
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +487 -170
- 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/_story/demo.jsx +1 -0
- package/input/index.tsx +1 -0
- package/input/textarea.tsx +6 -4
- package/inputNumber/__test__/inputNumber.test.js +36 -8
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/cascader/index.js +6 -0
- package/lib/cjs/datePicker/datePicker.js +12 -8
- 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/input/index.js +2 -1
- package/lib/cjs/input/textarea.js +5 -3
- package/lib/cjs/navigation/Item.js +1 -1
- package/lib/cjs/navigation/SubNav.js +1 -1
- package/lib/cjs/scrollList/scrollItem.d.ts +5 -1
- package/lib/cjs/scrollList/scrollItem.js +7 -0
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/select/index.js +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 +17 -7
- package/lib/cjs/table/interface.d.ts +1 -0
- package/lib/cjs/tabs/interface.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -0
- package/lib/cjs/timePicker/TimePicker.js +4 -4
- package/lib/cjs/timePicker/index.d.ts +1 -0
- 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/tree/treeNode.js +10 -1
- package/lib/cjs/treeSelect/index.d.ts +2 -0
- package/lib/cjs/treeSelect/index.js +75 -30
- package/lib/cjs/typography/util.js +0 -1
- 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/datePicker/datePicker.js +12 -8
- 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/input/index.js +2 -1
- package/lib/es/input/textarea.js +5 -3
- package/lib/es/navigation/Item.js +1 -1
- package/lib/es/navigation/SubNav.js +1 -1
- package/lib/es/scrollList/scrollItem.d.ts +5 -1
- package/lib/es/scrollList/scrollItem.js +7 -0
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/select/index.js +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 +19 -7
- package/lib/es/table/interface.d.ts +1 -0
- package/lib/es/tabs/interface.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +2 -0
- package/lib/es/timePicker/TimePicker.js +4 -4
- package/lib/es/timePicker/index.d.ts +1 -0
- 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/tree/treeNode.js +9 -1
- package/lib/es/treeSelect/index.d.ts +2 -0
- package/lib/es/treeSelect/index.js +76 -31
- package/lib/es/typography/util.js +0 -1
- 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/navigation/Item.tsx +1 -1
- package/navigation/SubNav.tsx +1 -1
- package/package.json +9 -8
- package/scrollList/scrollItem.tsx +10 -3
- package/select/index.tsx +6 -1
- package/select/option.tsx +2 -2
- package/table/Table.tsx +16 -8
- package/table/_story/table.stories.js +1 -0
- package/table/_story/v2/FixedColumnsChange/index.jsx +104 -0
- package/table/_story/v2/FixedHeaderMerge/index.jsx +98 -0
- package/table/_story/v2/FixedZIndex/index.jsx +87 -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/timePicker/TimePicker.tsx +4 -1
- package/timePicker/__test__/timePicker.test.js +42 -3
- package/timePicker/_story/timepicker.stories.js +18 -0
- 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/tree/treeNode.tsx +9 -2
- package/treeSelect/__test__/treeMultiple.test.js +94 -0
- package/treeSelect/__test__/treeSelect.test.js +157 -0
- package/treeSelect/_story/treeSelect.stories.js +242 -0
- package/treeSelect/index.tsx +93 -52
- package/typography/_story/typography.stories.js +8 -0
- package/typography/util.tsx +0 -1
- 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/navigation/Item.tsx
CHANGED
|
@@ -195,7 +195,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
195
195
|
itemChildren = children;
|
|
196
196
|
} else {
|
|
197
197
|
let placeholderIcons = null;
|
|
198
|
-
if (mode === strings.MODE_VERTICAL && !limitIndent) {
|
|
198
|
+
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
199
199
|
const iconAmount = (icon && !indent) ? level : level - 1;
|
|
200
200
|
placeholderIcons = times(iconAmount, () => this.renderIcon(null, strings.ICON_POS_RIGHT, false));
|
|
201
201
|
}
|
package/navigation/SubNav.tsx
CHANGED
|
@@ -237,7 +237,7 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
let placeholderIcons = null;
|
|
240
|
-
if (mode === strings.MODE_VERTICAL && !limitIndent) {
|
|
240
|
+
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
241
241
|
/* Different icons' amount means different indents.*/
|
|
242
242
|
const iconAmount = (icon && !indent) ? level : level - 1;
|
|
243
243
|
placeholderIcons = times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, undefined, index));
|
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,11 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation
|
|
18
|
-
"@douyinfe/semi-
|
|
19
|
-
"@douyinfe/semi-
|
|
20
|
-
"@douyinfe/semi-
|
|
21
|
-
"@douyinfe/semi-
|
|
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",
|
|
22
23
|
"@types/react-window": "^1.8.2",
|
|
23
24
|
"async-validator": "^3.5.0",
|
|
24
25
|
"classnames": "^2.2.6",
|
|
@@ -68,13 +69,13 @@
|
|
|
68
69
|
],
|
|
69
70
|
"author": "",
|
|
70
71
|
"license": "MIT",
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "d71dddacba0c96004c19103f2e0d3cb59ac52857",
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
74
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
75
76
|
"@babel/preset-env": "^7.15.8",
|
|
76
77
|
"@babel/preset-react": "^7.14.5",
|
|
77
|
-
"@douyinfe/semi-scss-compile": "2.
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.5.0-beta.0",
|
|
78
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
79
80
|
"@types/lodash": "^4.14.176",
|
|
80
81
|
"babel-loader": "^8.2.2",
|
|
@@ -13,8 +13,10 @@ import { Motion } from '../_base/base';
|
|
|
13
13
|
const msPerFrame = 1000 / 60;
|
|
14
14
|
const blankReg = /^\s*$/;
|
|
15
15
|
const wheelMode = 'wheel';
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
interface DebounceSelectFn {
|
|
17
|
+
(e: React.UIEvent, newSelectedNode: HTMLElement): void;
|
|
18
|
+
cancel(): void
|
|
19
|
+
}
|
|
18
20
|
export interface ScrollItemProps<T extends Item> {
|
|
19
21
|
mode?: string;
|
|
20
22
|
cycled?: boolean;
|
|
@@ -110,7 +112,12 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
|
|
|
110
112
|
scrollToCenter: this.scrollToCenter,
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
|
-
|
|
115
|
+
componentWillUnmount(){
|
|
116
|
+
if (this.props.cycled) {
|
|
117
|
+
this.throttledAdjustList.cancel();
|
|
118
|
+
this.debouncedSelect.cancel();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
114
121
|
componentDidMount() {
|
|
115
122
|
this.foundation.init();
|
|
116
123
|
|
package/select/index.tsx
CHANGED
|
@@ -739,7 +739,12 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
739
739
|
|
|
740
740
|
return (
|
|
741
741
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus
|
|
742
|
-
<div
|
|
742
|
+
<div
|
|
743
|
+
role="button"
|
|
744
|
+
aria-label="Use the input box to create an optional item"
|
|
745
|
+
onClick={e => this.onSelect(option, optionIndex, e)}
|
|
746
|
+
key={option.key || option.label}
|
|
747
|
+
>
|
|
743
748
|
{customCreateItem}
|
|
744
749
|
</div>
|
|
745
750
|
);
|
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
|
|
|
@@ -534,7 +535,6 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
534
535
|
this.foundation.initExpandedRowKeys({ groups: stateGroups });
|
|
535
536
|
}
|
|
536
537
|
|
|
537
|
-
|
|
538
538
|
/**
|
|
539
539
|
* After dataSource is updated || (cachedColumns || cachedChildren updated)
|
|
540
540
|
* 1. Cache filtered sorted data and a collection of data rows, stored in this
|
|
@@ -547,17 +547,20 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
547
547
|
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
|
|
548
548
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
549
549
|
states.dataSource = filteredSortedDataSource;
|
|
550
|
-
// when dataSource has change, should reset currentPage
|
|
551
|
-
states.pagination = isObject(statePagination) ? {
|
|
552
|
-
...statePagination,
|
|
553
|
-
currentPage: isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1,
|
|
554
|
-
} : statePagination;
|
|
555
550
|
|
|
556
551
|
if (this.props.groupBy) {
|
|
557
552
|
states.groups = null;
|
|
558
553
|
}
|
|
559
554
|
}
|
|
560
555
|
|
|
556
|
+
// when dataSource has change, should reset currentPage
|
|
557
|
+
if (dataSource !== prevProps.dataSource) {
|
|
558
|
+
states.pagination = isObject(statePagination) ? {
|
|
559
|
+
...statePagination,
|
|
560
|
+
currentPage: isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1,
|
|
561
|
+
} : statePagination;
|
|
562
|
+
}
|
|
563
|
+
|
|
561
564
|
if (Object.keys(states).length) {
|
|
562
565
|
const {
|
|
563
566
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
@@ -941,11 +944,15 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
941
944
|
titleArr.push(sorter);
|
|
942
945
|
}
|
|
943
946
|
|
|
947
|
+
const stateFilteredValue = get(curQuery, 'filteredValue');
|
|
948
|
+
const defaultFilteredValue = get(curQuery, 'defaultFilteredValue');
|
|
949
|
+
const filteredValue = stateFilteredValue ? stateFilteredValue : defaultFilteredValue;
|
|
944
950
|
if ((Array.isArray(column.filters) && column.filters.length) || isValidElement(column.filterDropdown)) {
|
|
945
951
|
const filter = (
|
|
946
952
|
<ColumnFilter
|
|
947
953
|
key={strings.DEFAULT_KEY_COLUMN_FILTER}
|
|
948
954
|
{...curQuery}
|
|
955
|
+
filteredValue={filteredValue}
|
|
949
956
|
onFilterDropdownVisibleChange={(visible: boolean) => this.foundation.toggleShowFilter(dataIndex, visible)}
|
|
950
957
|
onSelect={(data: OnSelectData) => this.foundation.handleFilterSelect(dataIndex, data)}
|
|
951
958
|
/>
|
|
@@ -1372,6 +1379,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
1372
1379
|
<div
|
|
1373
1380
|
ref={this.rootWrapRef}
|
|
1374
1381
|
className={classnames(className, `${prefixCls}-wrapper`)}
|
|
1382
|
+
data-column-fixed={anyColumnFixed}
|
|
1375
1383
|
style={wrapStyle}
|
|
1376
1384
|
id={id}
|
|
1377
1385
|
>
|
|
@@ -76,6 +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 * from './v2';
|
|
79
80
|
|
|
80
81
|
// empty table
|
|
81
82
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
|
+
import { Table, Avatar } from '@douyinfe/semi-ui';
|
|
3
|
+
import * as dateFns from 'date-fns';
|
|
4
|
+
|
|
5
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
6
|
+
const figmaIconUrl = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png';
|
|
7
|
+
|
|
8
|
+
const getData = () => {
|
|
9
|
+
const data = [];
|
|
10
|
+
for (let i = 0; i < 46; i++) {
|
|
11
|
+
const isSemiDesign = i % 2 === 0;
|
|
12
|
+
const randomNumber = (i * 1000) % 199;
|
|
13
|
+
data.push({
|
|
14
|
+
key: '' + i,
|
|
15
|
+
name: isSemiDesign ? `Semi Design 设计稿${i}.fig` : `Semi Pro 设计稿${i}.fig`,
|
|
16
|
+
owner: isSemiDesign ? '姜鹏志' : '郝宣',
|
|
17
|
+
size: randomNumber,
|
|
18
|
+
updateTime: new Date('2022-01-01').valueOf() + randomNumber * DAY,
|
|
19
|
+
avatarBg: isSemiDesign ? 'grey' : 'red'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const data = getData();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* fix https://github.com/DouyinFE/semi-design/issues/381
|
|
29
|
+
*/
|
|
30
|
+
App.storyName = 'fixed columns change';
|
|
31
|
+
function App() {
|
|
32
|
+
const [dataSource, setData] = useState(data);
|
|
33
|
+
const [rowKeys, setRowKeys] = useState([]);
|
|
34
|
+
|
|
35
|
+
const columns = [
|
|
36
|
+
{
|
|
37
|
+
title: '标题',
|
|
38
|
+
dataIndex: 'name',
|
|
39
|
+
width: 400,
|
|
40
|
+
render: (text, record, index) => {
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<Avatar size="small" shape="square" src={figmaIconUrl} style={{ marginRight: 12 }}></Avatar>
|
|
44
|
+
{text}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
filters: [
|
|
49
|
+
{
|
|
50
|
+
text: 'Semi Design 设计稿',
|
|
51
|
+
value: 'Semi Design 设计稿',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
text: 'Semi Pro 设计稿',
|
|
55
|
+
value: 'Semi Pro 设计稿',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
onFilter: (value, record) => record.name.includes(value),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: '大小',
|
|
62
|
+
dataIndex: 'size',
|
|
63
|
+
sorter: (a, b) => a.size - b.size > 0 ? 1 : -1,
|
|
64
|
+
render: (text) => `${text} KB`
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
title: '所有者',
|
|
68
|
+
dataIndex: 'owner',
|
|
69
|
+
render: (text, record, index) => {
|
|
70
|
+
return (
|
|
71
|
+
<div>
|
|
72
|
+
<Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>{typeof text === 'string' && text.slice(0, 1)}</Avatar>
|
|
73
|
+
{text}
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: '更新日期',
|
|
80
|
+
dataIndex: 'updateTime',
|
|
81
|
+
sorter: (a, b) => a.updateTime - b.updateTime > 0 ? 1 : -1,
|
|
82
|
+
render: (value) => {
|
|
83
|
+
return dateFns.format(new Date(value), 'yyyy-MM-dd');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Table
|
|
90
|
+
columns={columns}
|
|
91
|
+
dataSource={dataSource}
|
|
92
|
+
pagination={{
|
|
93
|
+
pageSize: 5,
|
|
94
|
+
}}
|
|
95
|
+
rowSelection={{
|
|
96
|
+
onChange: rowKeys => setRowKeys(rowKeys),
|
|
97
|
+
selectedRowKeys: rowKeys,
|
|
98
|
+
}}
|
|
99
|
+
scroll={{ y: 300 }}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default App;
|