@douyinfe/semi-ui 2.4.0 → 2.5.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/v2/FixInputRangeFocus.jsx +25 -0
- package/datePicker/_story/v2/index.js +2 -1
- package/datePicker/datePicker.tsx +4 -0
- package/dist/css/semi.css +51 -27
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +481 -182
- 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 +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/cascader/index.js +6 -0
- package/lib/cjs/datePicker/datePicker.js +16 -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 +1 -1
- package/lib/cjs/select/index.d.ts +3 -3
- package/lib/cjs/select/index.js +32 -28
- package/lib/cjs/select/option.js +2 -2
- package/lib/cjs/select/virtualRow.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/timePicker/TimePicker.js +2 -1
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +6 -2
- 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/datePicker/datePicker.js +16 -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 +1 -1
- package/lib/es/select/index.d.ts +3 -3
- package/lib/es/select/index.js +30 -26
- package/lib/es/select/option.js +2 -2
- package/lib/es/select/virtualRow.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/timePicker/TimePicker.js +2 -1
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tooltip/index.js +6 -2
- 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 -8
- package/select/index.tsx +18 -19
- package/select/option.tsx +2 -2
- package/select/virtualRow.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/FixedResizable/index.jsx +114 -0
- package/table/_story/v2/defaultFilteredValue.tsx +123 -0
- package/table/_story/v2/index.js +5 -0
- package/table/interface.ts +1 -0
- package/tabs/interface.ts +1 -1
- package/timePicker/TimePicker.tsx +1 -0
- package/tooltip/__test__/tooltip.test.js +48 -4
- package/tooltip/_story/tooltip.stories.js +83 -1
- package/tooltip/index.tsx +4 -4
- 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",
|
|
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",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.5.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.5.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.5.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.5.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.5.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": "856255d8b5ad895a5fee47c5920aa1835836aff0",
|
|
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",
|
|
78
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
79
80
|
"@types/lodash": "^4.14.176",
|
|
80
81
|
"babel-loader": "^8.2.2",
|
package/select/index.tsx
CHANGED
|
@@ -530,9 +530,13 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
530
530
|
|
|
531
531
|
}
|
|
532
532
|
},
|
|
533
|
-
updateScrollTop: () => {
|
|
533
|
+
updateScrollTop: (index?: number) => {
|
|
534
534
|
// eslint-disable-next-line max-len
|
|
535
|
-
let
|
|
535
|
+
let optionClassName = `.${prefixcls}-option-selected`;
|
|
536
|
+
if (index !== undefined) {
|
|
537
|
+
optionClassName = `.${prefixcls}-option:nth-child(${index})`;
|
|
538
|
+
}
|
|
539
|
+
let destNode = document.querySelector(`#${prefixcls}-${this.selectOptionListID} ${optionClassName}`) as HTMLDivElement;
|
|
536
540
|
if (Array.isArray(destNode)) {
|
|
537
541
|
// eslint-disable-next-line prefer-destructuring
|
|
538
542
|
destNode = destNode[0];
|
|
@@ -754,31 +758,26 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
754
758
|
this.foundation.handleOptionMouseEnter(optionIndex);
|
|
755
759
|
}
|
|
756
760
|
|
|
757
|
-
renderWithGroup(
|
|
761
|
+
renderWithGroup(visibleOptions: OptionProps[]) {
|
|
758
762
|
const content: JSX.Element[] = [];
|
|
759
763
|
const groupStatus = new Map();
|
|
760
764
|
|
|
761
|
-
|
|
765
|
+
visibleOptions.forEach((option, optionIndex) => {
|
|
762
766
|
const parentGroup = option._parentGroup;
|
|
763
767
|
const optionContent = this.renderOption(option, optionIndex);
|
|
764
|
-
if (parentGroup && groupStatus.has(parentGroup.label)) {
|
|
765
|
-
// group content already insert
|
|
766
|
-
content.push(optionContent);
|
|
767
|
-
} else if (parentGroup) {
|
|
768
|
+
if (parentGroup && !groupStatus.has(parentGroup.label)) {
|
|
769
|
+
// when use with OptionGroup and group content not already insert
|
|
768
770
|
const groupContent = <OptionGroup {...parentGroup} key={parentGroup.label} />;
|
|
769
771
|
groupStatus.set(parentGroup.label, true);
|
|
770
772
|
content.push(groupContent);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
// when not use with OptionGroup
|
|
774
|
-
content.push(optionContent);
|
|
775
|
-
}
|
|
773
|
+
}
|
|
774
|
+
content.push(optionContent);
|
|
776
775
|
});
|
|
777
776
|
|
|
778
777
|
return content;
|
|
779
778
|
}
|
|
780
779
|
|
|
781
|
-
renderVirtualizeList(
|
|
780
|
+
renderVirtualizeList(visibleOptions: OptionProps[]) {
|
|
782
781
|
const { virtualize } = this.props;
|
|
783
782
|
const { direction } = this.context;
|
|
784
783
|
const { height, width, itemSize } = virtualize;
|
|
@@ -787,9 +786,9 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
787
786
|
<List
|
|
788
787
|
ref={this.virtualizeListRef}
|
|
789
788
|
height={height || numbers.LIST_HEIGHT}
|
|
790
|
-
itemCount={
|
|
789
|
+
itemCount={visibleOptions.length}
|
|
791
790
|
itemSize={itemSize}
|
|
792
|
-
itemData={{
|
|
791
|
+
itemData={{ visibleOptions, renderOption: this.renderOption }}
|
|
793
792
|
width={width || '100%'}
|
|
794
793
|
style={{ direction }}
|
|
795
794
|
>
|
|
@@ -814,11 +813,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
814
813
|
} = this.props;
|
|
815
814
|
|
|
816
815
|
// Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
|
|
817
|
-
const
|
|
816
|
+
const visibleOptions = options.filter(item => item._show);
|
|
818
817
|
|
|
819
|
-
let listContent: JSX.Element | JSX.Element[] = this.renderWithGroup(
|
|
818
|
+
let listContent: JSX.Element | JSX.Element[] = this.renderWithGroup(visibleOptions);
|
|
820
819
|
if (virtualize) {
|
|
821
|
-
listContent = this.renderVirtualizeList(
|
|
820
|
+
listContent = this.renderVirtualizeList(visibleOptions);
|
|
822
821
|
}
|
|
823
822
|
|
|
824
823
|
const style = { minWidth: dropdownMinWidth, ...dropdownStyle };
|
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/select/virtualRow.tsx
CHANGED
|
@@ -5,8 +5,8 @@ export interface VirtualRowProps{
|
|
|
5
5
|
style?: React.CSSProperties;
|
|
6
6
|
}
|
|
7
7
|
const VirtualRow = ({ index, data, style }: VirtualRowProps) => {
|
|
8
|
-
const {
|
|
9
|
-
const option =
|
|
8
|
+
const { visibleOptions } = data;
|
|
9
|
+
const option = visibleOptions[index];
|
|
10
10
|
return data.renderOption(option, index, style);
|
|
11
11
|
};
|
|
12
12
|
|
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
|
+
}
|