@douyinfe/semi-ui 2.1.4 → 2.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_base/_story/a11y.jsx +1302 -0
- package/_base/_story/a11y.scss +49 -0
- package/_base/_story/index.stories.js +3 -1
- package/_utils/index.ts +9 -4
- package/button/Button.tsx +1 -0
- package/cascader/__test__/cascader.test.js +221 -0
- package/cascader/_story/cascader.stories.js +138 -0
- package/cascader/index.tsx +37 -21
- package/cascader/item.tsx +4 -2
- package/checkbox/checkbox.tsx +2 -0
- package/checkbox/checkboxGroup.tsx +3 -2
- package/datePicker/__test__/datePicker.test.js +85 -2
- package/datePicker/_story/datePicker.stories.js +29 -1
- package/datePicker/_story/v2/YearButton.jsx +17 -0
- package/datePicker/_story/v2/index.js +1 -0
- package/datePicker/monthsGrid.tsx +12 -1
- package/datePicker/navigation.tsx +55 -29
- package/descriptions/__test__/descriptions.test.js +27 -1
- package/descriptions/_story/descriptions.stories.js +52 -2
- package/descriptions/item.tsx +1 -1
- package/dist/css/semi.css +56 -32
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +854 -258
- 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/empty/index.tsx +2 -2
- package/form/_story/form.stories.js +0 -67
- package/form/hoc/withField.tsx +1 -1
- package/gulpfile.js +2 -1
- package/lib/cjs/_base/base.css +2 -2
- package/lib/cjs/_utils/index.d.ts +1 -0
- package/lib/cjs/_utils/index.js +12 -5
- package/lib/cjs/button/Button.d.ts +1 -0
- package/lib/cjs/cascader/index.d.ts +7 -0
- package/lib/cjs/cascader/index.js +35 -22
- package/lib/cjs/cascader/item.d.ts +2 -0
- package/lib/cjs/cascader/item.js +4 -2
- package/lib/cjs/checkbox/checkbox.js +3 -1
- package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -0
- package/lib/cjs/checkbox/checkboxGroup.js +3 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGrid.js +6 -0
- package/lib/cjs/datePicker/navigation.js +47 -7
- package/lib/cjs/descriptions/item.js +1 -1
- package/lib/cjs/empty/index.d.ts +2 -2
- package/lib/cjs/empty/index.js +19 -18
- package/lib/cjs/form/baseForm.d.ts +6 -0
- package/lib/cjs/form/field.d.ts +6 -0
- package/lib/cjs/form/hoc/withField.js +3 -1
- package/lib/cjs/locale/source/es.d.ts +7 -0
- package/lib/cjs/locale/source/es.js +168 -0
- package/lib/cjs/modal/Modal.d.ts +2 -2
- package/lib/cjs/modal/Modal.js +2 -2
- package/lib/cjs/modal/confirm.d.ts +10 -10
- package/lib/cjs/navigation/index.d.ts +2 -2
- package/lib/cjs/pagination/index.js +9 -4
- package/lib/cjs/rating/item.js +1 -1
- package/lib/cjs/select/index.d.ts +10 -0
- package/lib/cjs/select/index.js +15 -9
- package/lib/cjs/timeline/item.d.ts +5 -2
- package/lib/cjs/timeline/item.js +13 -7
- package/lib/cjs/tree/treeNode.js +0 -2
- package/lib/cjs/upload/fileCard.d.ts +2 -0
- package/lib/cjs/upload/fileCard.js +70 -45
- package/lib/cjs/upload/index.d.ts +23 -2
- package/lib/cjs/upload/index.js +133 -25
- package/lib/cjs/upload/interface.d.ts +3 -0
- package/lib/es/_base/base.css +2 -2
- package/lib/es/_utils/index.d.ts +1 -0
- package/lib/es/_utils/index.js +12 -5
- package/lib/es/button/Button.d.ts +1 -0
- package/lib/es/cascader/index.d.ts +7 -0
- package/lib/es/cascader/index.js +34 -25
- package/lib/es/cascader/item.d.ts +2 -0
- package/lib/es/cascader/item.js +4 -2
- package/lib/es/checkbox/checkbox.js +3 -1
- package/lib/es/checkbox/checkboxGroup.d.ts +1 -0
- package/lib/es/checkbox/checkboxGroup.js +3 -1
- package/lib/es/datePicker/monthsGrid.d.ts +1 -0
- package/lib/es/datePicker/monthsGrid.js +6 -0
- package/lib/es/datePicker/navigation.js +48 -8
- package/lib/es/descriptions/item.js +1 -1
- package/lib/es/empty/index.d.ts +2 -2
- package/lib/es/empty/index.js +19 -18
- package/lib/es/form/baseForm.d.ts +6 -0
- package/lib/es/form/field.d.ts +6 -0
- package/lib/es/form/hoc/withField.js +3 -1
- package/lib/es/locale/source/es.d.ts +7 -0
- package/lib/es/locale/source/es.js +157 -0
- package/lib/es/modal/Modal.d.ts +2 -2
- package/lib/es/modal/Modal.js +2 -2
- package/lib/es/modal/confirm.d.ts +10 -10
- package/lib/es/navigation/index.d.ts +2 -2
- package/lib/es/pagination/index.js +8 -4
- package/lib/es/rating/item.js +1 -1
- package/lib/es/select/index.d.ts +10 -0
- package/lib/es/select/index.js +19 -9
- package/lib/es/timeline/item.d.ts +5 -2
- package/lib/es/timeline/item.js +12 -7
- package/lib/es/tree/treeNode.js +0 -2
- package/lib/es/upload/fileCard.d.ts +2 -0
- package/lib/es/upload/fileCard.js +69 -44
- package/lib/es/upload/index.d.ts +23 -2
- package/lib/es/upload/index.js +133 -24
- package/lib/es/upload/interface.d.ts +3 -0
- package/locale/source/es.ts +160 -0
- package/modal/Modal.tsx +4 -4
- package/navigation/__test__/navigation.test.js +4 -4
- package/navigation/_story/AutoOpen/index.js +1 -1
- package/navigation/_story/WithChildren/index.js +1 -1
- package/navigation/_story/navigation.stories.js +1 -1
- package/navigation/_story/navigation.stories.tsx +4 -4
- package/navigation/index.tsx +2 -2
- package/package.json +17 -9
- package/pagination/_story/pagination.stories.js +11 -0
- package/pagination/index.tsx +9 -4
- package/popover/Arrow.tsx +1 -1
- package/radio/_story/radio.stories.js +12 -1
- package/rating/item.tsx +1 -1
- package/select/_story/select.stories.js +39 -14
- package/select/index.tsx +21 -7
- package/table/_story/DynamicFilters/index.js +13 -16
- package/timeline/__test__/timeline.test.js +17 -1
- package/timeline/_story/timeline.stories.js +70 -6
- package/timeline/item.tsx +11 -6
- package/tooltip/_story/tooltip.stories.js +1 -1
- package/tree/_story/tree.stories.js +2 -2
- package/tree/treeNode.tsx +0 -2
- package/upload/__test__/upload.test.js +50 -1
- package/upload/fileCard.tsx +110 -95
- package/upload/index.tsx +147 -53
- package/upload/interface.ts +3 -0
package/lib/cjs/timeline/item.js
CHANGED
|
@@ -18,6 +18,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
18
18
|
|
|
19
19
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
20
20
|
|
|
21
|
+
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
22
|
+
|
|
21
23
|
var _react = _interopRequireWildcard(require("react"));
|
|
22
24
|
|
|
23
25
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -46,7 +48,8 @@ class Item extends _react.PureComponent {
|
|
|
46
48
|
type,
|
|
47
49
|
style,
|
|
48
50
|
time,
|
|
49
|
-
extra
|
|
51
|
+
extra,
|
|
52
|
+
onClick
|
|
50
53
|
} = this.props;
|
|
51
54
|
const itemCls = (0, _classnames.default)(prefixCls, className);
|
|
52
55
|
const dotCls = (0, _classnames.default)({
|
|
@@ -61,16 +64,17 @@ class Item extends _react.PureComponent {
|
|
|
61
64
|
} : null;
|
|
62
65
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
63
66
|
className: itemCls,
|
|
64
|
-
style: style
|
|
67
|
+
style: style,
|
|
68
|
+
onClick: onClick
|
|
65
69
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
66
70
|
className: "".concat(prefixCls, "-tail")
|
|
67
71
|
}), /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
|
|
68
72
|
className: dotCls
|
|
69
73
|
}, dotStyle), dot), /*#__PURE__*/_react.default.createElement("div", {
|
|
70
74
|
className: "".concat(prefixCls, "-content")
|
|
71
|
-
}, children, extra
|
|
75
|
+
}, children, extra && /*#__PURE__*/_react.default.createElement("div", {
|
|
72
76
|
className: "".concat(prefixCls, "-content-extra")
|
|
73
|
-
}, extra)
|
|
77
|
+
}, extra), time && /*#__PURE__*/_react.default.createElement("div", {
|
|
74
78
|
className: "".concat(prefixCls, "-content-time")
|
|
75
79
|
}, time)));
|
|
76
80
|
}
|
|
@@ -80,15 +84,17 @@ class Item extends _react.PureComponent {
|
|
|
80
84
|
exports.default = Item;
|
|
81
85
|
Item.propTypes = {
|
|
82
86
|
color: _propTypes.default.string,
|
|
83
|
-
time: _propTypes.default.
|
|
87
|
+
time: _propTypes.default.node,
|
|
84
88
|
type: _propTypes.default.oneOf(_constants.strings.ITEM_TYPE),
|
|
85
89
|
dot: _propTypes.default.node,
|
|
86
90
|
extra: _propTypes.default.node,
|
|
87
91
|
position: _propTypes.default.oneOf(_constants.strings.ITEM_POS),
|
|
88
92
|
className: _propTypes.default.string,
|
|
89
|
-
style: _propTypes.default.object
|
|
93
|
+
style: _propTypes.default.object,
|
|
94
|
+
onClick: _propTypes.default.func
|
|
90
95
|
};
|
|
91
96
|
Item.defaultProps = {
|
|
92
97
|
type: 'default',
|
|
93
|
-
time: ''
|
|
98
|
+
time: '',
|
|
99
|
+
onClick: _noop2.default
|
|
94
100
|
};
|
package/lib/cjs/tree/treeNode.js
CHANGED
|
@@ -26,6 +26,7 @@ declare class FileCard extends PureComponent<FileCardProps> {
|
|
|
26
26
|
style: PropTypes.Requireable<object>;
|
|
27
27
|
url: PropTypes.Requireable<string>;
|
|
28
28
|
validateMessage: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
29
|
+
index: PropTypes.Requireable<number>;
|
|
29
30
|
};
|
|
30
31
|
static defaultProps: {
|
|
31
32
|
listType: "list";
|
|
@@ -39,6 +40,7 @@ declare class FileCard extends PureComponent<FileCardProps> {
|
|
|
39
40
|
renderValidateMessage(): ReactNode;
|
|
40
41
|
renderPicValidateMsg(): ReactNode;
|
|
41
42
|
renderPic(locale: Locale['Upload']): ReactNode;
|
|
43
|
+
renderFile(locale: Locale["Upload"]): JSX.Element;
|
|
42
44
|
onRemove(e: MouseEvent): void;
|
|
43
45
|
onReplace(e: MouseEvent): void;
|
|
44
46
|
onRetry(e: MouseEvent): void;
|
|
@@ -26,6 +26,8 @@ var _constants = require("@douyinfe/semi-foundation/lib/cjs/upload/constants");
|
|
|
26
26
|
|
|
27
27
|
var _utils = require("@douyinfe/semi-foundation/lib/cjs/upload/utils");
|
|
28
28
|
|
|
29
|
+
var _semiIcons = require("@douyinfe/semi-icons");
|
|
30
|
+
|
|
29
31
|
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
30
32
|
|
|
31
33
|
var _index = _interopRequireDefault(require("../iconButton/index"));
|
|
@@ -38,8 +40,6 @@ var _index4 = _interopRequireDefault(require("../spin/index"));
|
|
|
38
40
|
|
|
39
41
|
var _reactUtils = require("../_base/reactUtils");
|
|
40
42
|
|
|
41
|
-
var _semiIcons = require("@douyinfe/semi-icons");
|
|
42
|
-
|
|
43
43
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
44
44
|
|
|
45
45
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -191,16 +191,23 @@ class FileCard extends _react.PureComponent {
|
|
|
191
191
|
status,
|
|
192
192
|
disabled,
|
|
193
193
|
style,
|
|
194
|
-
onPreviewClick
|
|
194
|
+
onPreviewClick,
|
|
195
|
+
showPicInfo,
|
|
196
|
+
renderPicInfo,
|
|
197
|
+
renderThumbnail,
|
|
198
|
+
name,
|
|
199
|
+
index
|
|
195
200
|
} = this.props;
|
|
201
|
+
const showProgress = status === _constants.strings.FILE_STATUS_UPLOADING && percent !== 100;
|
|
202
|
+
const showRetry = status === _constants.strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
|
|
203
|
+
const showReplace = status === _constants.strings.FILE_STATUS_SUCCESS && this.props.showReplace;
|
|
196
204
|
const filePicCardCls = (0, _classnames.default)({
|
|
197
205
|
["".concat(prefixCls, "-picture-file-card")]: true,
|
|
198
206
|
["".concat(prefixCls, "-picture-file-card-disabled")]: disabled,
|
|
199
|
-
["".concat(prefixCls, "-picture-file-card-show-pointer")]: typeof onPreviewClick !== 'undefined'
|
|
207
|
+
["".concat(prefixCls, "-picture-file-card-show-pointer")]: typeof onPreviewClick !== 'undefined',
|
|
208
|
+
["".concat(prefixCls, "-picture-file-card-error")]: status === _constants.strings.FILE_STATUS_UPLOAD_FAIL,
|
|
209
|
+
["".concat(prefixCls, "-picture-file-card-uploading")]: showProgress
|
|
200
210
|
});
|
|
201
|
-
const showProgress = status === _constants.strings.FILE_STATUS_UPLOADING && percent !== 100;
|
|
202
|
-
const showRetry = status === _constants.strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
|
|
203
|
-
const showReplace = status === _constants.strings.FILE_STATUS_SUCCESS && this.props.showReplace;
|
|
204
211
|
const closeCls = "".concat(prefixCls, "-picture-file-card-close");
|
|
205
212
|
|
|
206
213
|
const retry = /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -223,47 +230,38 @@ class FileCard extends _react.PureComponent {
|
|
|
223
230
|
className: "".concat(prefixCls, "-picture-file-card-icon-replace")
|
|
224
231
|
})));
|
|
225
232
|
|
|
233
|
+
const picInfo = typeof renderPicInfo === 'function' ? renderPicInfo(this.props) : /*#__PURE__*/_react.default.createElement("div", {
|
|
234
|
+
className: "".concat(prefixCls, "-picture-file-card-pic-info")
|
|
235
|
+
}, index + 1);
|
|
236
|
+
const thumbnail = typeof renderThumbnail === 'function' ? renderThumbnail(this.props) : /*#__PURE__*/_react.default.createElement("img", {
|
|
237
|
+
src: url,
|
|
238
|
+
alt: "picture of ".concat(name)
|
|
239
|
+
});
|
|
226
240
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
227
241
|
className: filePicCardCls,
|
|
228
242
|
style: style,
|
|
229
243
|
onClick: onPreviewClick
|
|
230
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
231
|
-
src: url
|
|
232
|
-
}), showProgress ? /*#__PURE__*/_react.default.createElement(_index2.default, {
|
|
244
|
+
}, thumbnail, showProgress ? /*#__PURE__*/_react.default.createElement(_index2.default, {
|
|
233
245
|
percent: percent,
|
|
234
246
|
type: "circle",
|
|
235
247
|
size: "small",
|
|
236
248
|
orbitStroke: '#FFF'
|
|
237
|
-
}) : null, showRetry ? retry : null, showReplace && replace,
|
|
238
|
-
className: closeCls
|
|
239
|
-
onClick: e => this.onRemove(e)
|
|
249
|
+
}) : null, showRetry ? retry : null, showReplace && replace, showPicInfo && picInfo, !disabled && /*#__PURE__*/_react.default.createElement("div", {
|
|
250
|
+
className: closeCls
|
|
240
251
|
}, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, {
|
|
241
|
-
size: "extra-small"
|
|
252
|
+
size: "extra-small",
|
|
253
|
+
onClick: e => this.onRemove(e)
|
|
242
254
|
})), this.renderPicValidateMsg());
|
|
243
255
|
}
|
|
244
256
|
|
|
245
|
-
|
|
246
|
-
e.stopPropagation();
|
|
247
|
-
this.props.onRemove(this.props, e);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
onReplace(e) {
|
|
251
|
-
e.stopPropagation();
|
|
252
|
-
this.props.onReplace(this.props, e);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
onRetry(e) {
|
|
256
|
-
e.stopPropagation();
|
|
257
|
-
this.props.onRetry(this.props, e);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
render() {
|
|
257
|
+
renderFile(locale) {
|
|
261
258
|
const {
|
|
262
259
|
name,
|
|
263
260
|
size,
|
|
264
261
|
percent,
|
|
265
262
|
url,
|
|
266
|
-
|
|
263
|
+
showRetry: propsShowRetry,
|
|
264
|
+
showReplace: propsShowReplace,
|
|
267
265
|
preview,
|
|
268
266
|
previewFile,
|
|
269
267
|
status,
|
|
@@ -284,15 +282,8 @@ class FileCard extends _react.PureComponent {
|
|
|
284
282
|
const replaceCls = "".concat(prefixCls, "-file-card-replace");
|
|
285
283
|
const showProgress = !(percent === 100 || typeof percent === 'undefined') && status === _constants.strings.FILE_STATUS_UPLOADING; // only show retry when upload fail & showRetry is true, no need to show during validate fail
|
|
286
284
|
|
|
287
|
-
const showRetry = status === _constants.strings.FILE_STATUS_UPLOAD_FAIL &&
|
|
288
|
-
const showReplace = status === _constants.strings.FILE_STATUS_SUCCESS &&
|
|
289
|
-
|
|
290
|
-
if (listType === _constants.strings.FILE_LIST_PIC) {
|
|
291
|
-
return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
292
|
-
componentName: "Upload"
|
|
293
|
-
}, locale => this.renderPic(locale));
|
|
294
|
-
}
|
|
295
|
-
|
|
285
|
+
const showRetry = status === _constants.strings.FILE_STATUS_UPLOAD_FAIL && propsShowRetry;
|
|
286
|
+
const showReplace = status === _constants.strings.FILE_STATUS_SUCCESS && propsShowReplace;
|
|
296
287
|
const fileSize = this.transSize(size);
|
|
297
288
|
let previewContent = preview ? /*#__PURE__*/_react.default.createElement("img", {
|
|
298
289
|
src: url
|
|
@@ -304,9 +295,7 @@ class FileCard extends _react.PureComponent {
|
|
|
304
295
|
previewContent = previewFile(this.props);
|
|
305
296
|
}
|
|
306
297
|
|
|
307
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
308
|
-
componentName: "Upload"
|
|
309
|
-
}, locale => /*#__PURE__*/_react.default.createElement("div", {
|
|
298
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
310
299
|
className: fileCardCls,
|
|
311
300
|
style: style,
|
|
312
301
|
onClick: onPreviewClick
|
|
@@ -351,7 +340,42 @@ class FileCard extends _react.PureComponent {
|
|
|
351
340
|
theme: "borderless",
|
|
352
341
|
size: "small",
|
|
353
342
|
className: closeCls
|
|
354
|
-
}))
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
onRemove(e) {
|
|
347
|
+
e.stopPropagation();
|
|
348
|
+
this.props.onRemove(this.props, e);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
onReplace(e) {
|
|
352
|
+
e.stopPropagation();
|
|
353
|
+
this.props.onReplace(this.props, e);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
onRetry(e) {
|
|
357
|
+
e.stopPropagation();
|
|
358
|
+
this.props.onRetry(this.props, e);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
render() {
|
|
362
|
+
const {
|
|
363
|
+
listType
|
|
364
|
+
} = this.props;
|
|
365
|
+
|
|
366
|
+
if (listType === _constants.strings.FILE_LIST_PIC) {
|
|
367
|
+
return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
368
|
+
componentName: "Upload"
|
|
369
|
+
}, locale => this.renderPic(locale));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (listType === _constants.strings.FILE_LIST_DEFAULT) {
|
|
373
|
+
return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
374
|
+
componentName: "Upload"
|
|
375
|
+
}, locale => this.renderFile(locale));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return null;
|
|
355
379
|
}
|
|
356
380
|
|
|
357
381
|
}
|
|
@@ -374,7 +398,8 @@ FileCard.propTypes = {
|
|
|
374
398
|
status: _propTypes.default.string,
|
|
375
399
|
style: _propTypes.default.object,
|
|
376
400
|
url: _propTypes.default.string,
|
|
377
|
-
validateMessage: _propTypes.default.node
|
|
401
|
+
validateMessage: _propTypes.default.node,
|
|
402
|
+
index: _propTypes.default.number
|
|
378
403
|
};
|
|
379
404
|
FileCard.defaultProps = {
|
|
380
405
|
listType: _constants.strings.FILE_LIST_DEFAULT,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactNode, CSSProperties, RefObject, ChangeEvent, DragEvent } from 'react';
|
|
1
|
+
import React, { ReactNode, CSSProperties, RefObject, ChangeEvent, DragEvent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import UploadFoundation, { UploadAdapter, BeforeUploadObjectResult, AfterUploadResult } from '@douyinfe/semi-foundation/lib/cjs/upload/foundation';
|
|
3
|
+
import UploadFoundation, { CustomFile, UploadAdapter, BeforeUploadObjectResult, AfterUploadResult } from '@douyinfe/semi-foundation/lib/cjs/upload/foundation';
|
|
4
4
|
import FileCard from './fileCard';
|
|
5
5
|
import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
|
|
6
6
|
import { FileItem, RenderFileItemProps, UploadListType, PromptPositionType, BeforeUploadProps, AfterUploadProps, OnChangeProps, customRequestArgs, CustomError } from './interface';
|
|
@@ -54,7 +54,10 @@ export interface UploadProps {
|
|
|
54
54
|
prompt?: ReactNode;
|
|
55
55
|
promptPosition?: PromptPositionType;
|
|
56
56
|
renderFileItem?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
57
|
+
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
58
|
+
renderThumbnail?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
57
59
|
showClear?: boolean;
|
|
60
|
+
showPicInfo?: boolean;
|
|
58
61
|
showReplace?: boolean;
|
|
59
62
|
showRetry?: boolean;
|
|
60
63
|
showUploadList?: boolean;
|
|
@@ -121,7 +124,10 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
121
124
|
prompt: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
122
125
|
promptPosition: PropTypes.Requireable<"left" | "right" | "bottom">;
|
|
123
126
|
renderFileItem: PropTypes.Requireable<(...args: any[]) => any>;
|
|
127
|
+
renderPicInfo: PropTypes.Requireable<(...args: any[]) => any>;
|
|
128
|
+
renderThumbnail: PropTypes.Requireable<(...args: any[]) => any>;
|
|
124
129
|
showClear: PropTypes.Requireable<boolean>;
|
|
130
|
+
showPicInfo: PropTypes.Requireable<boolean>;
|
|
125
131
|
showReplace: PropTypes.Requireable<boolean>;
|
|
126
132
|
showRetry: PropTypes.Requireable<boolean>;
|
|
127
133
|
showUploadList: PropTypes.Requireable<boolean>;
|
|
@@ -157,13 +163,28 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
157
163
|
onReplaceChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
158
164
|
clear: () => void;
|
|
159
165
|
remove: (fileItem: FileItem) => void;
|
|
166
|
+
/**
|
|
167
|
+
* ref method
|
|
168
|
+
* insert files at index
|
|
169
|
+
* @param files Array<CustomFile>
|
|
170
|
+
* @param index number
|
|
171
|
+
* @returns
|
|
172
|
+
*/
|
|
173
|
+
insert: (files: Array<CustomFile>, index: number) => void;
|
|
174
|
+
/**
|
|
175
|
+
* ref method
|
|
176
|
+
* manual upload by user
|
|
177
|
+
*/
|
|
160
178
|
upload: () => void;
|
|
161
179
|
renderFile: (file: FileItem, index: number, locale: Locale['Upload']) => ReactNode;
|
|
162
180
|
renderFileList: () => ReactNode;
|
|
181
|
+
renderFileListPic: () => JSX.Element;
|
|
182
|
+
renderFileListDefault: () => JSX.Element;
|
|
163
183
|
onDrop: (e: DragEvent<HTMLDivElement>) => void;
|
|
164
184
|
onDragOver: (e: DragEvent<HTMLDivElement>) => void;
|
|
165
185
|
onDragLeave: (e: DragEvent<HTMLDivElement>) => void;
|
|
166
186
|
onDragEnter: (e: DragEvent<HTMLDivElement>) => void;
|
|
187
|
+
renderAddContent: () => React.ReactNode;
|
|
167
188
|
renderDragArea: () => ReactNode;
|
|
168
189
|
render(): ReactNode;
|
|
169
190
|
}
|
package/lib/cjs/upload/index.js
CHANGED
|
@@ -97,6 +97,23 @@ class Upload extends _baseComponent.default {
|
|
|
97
97
|
this.remove = fileItem => {
|
|
98
98
|
this.foundation.handleRemove(fileItem);
|
|
99
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* ref method
|
|
102
|
+
* insert files at index
|
|
103
|
+
* @param files Array<CustomFile>
|
|
104
|
+
* @param index number
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
this.insert = (files, index) => {
|
|
110
|
+
return this.foundation.insertFileToList(files, index);
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* ref method
|
|
114
|
+
* manual upload by user
|
|
115
|
+
*/
|
|
116
|
+
|
|
100
117
|
|
|
101
118
|
this.upload = () => {
|
|
102
119
|
const {
|
|
@@ -112,14 +129,18 @@ class Upload extends _baseComponent.default {
|
|
|
112
129
|
name,
|
|
113
130
|
status,
|
|
114
131
|
validateMessage,
|
|
115
|
-
_sizeInvalid
|
|
132
|
+
_sizeInvalid,
|
|
133
|
+
uid
|
|
116
134
|
} = file;
|
|
117
135
|
const {
|
|
118
136
|
previewFile,
|
|
119
137
|
listType,
|
|
120
138
|
itemStyle,
|
|
121
139
|
showRetry,
|
|
140
|
+
showPicInfo,
|
|
141
|
+
renderPicInfo,
|
|
122
142
|
renderFileItem,
|
|
143
|
+
renderThumbnail,
|
|
123
144
|
disabled,
|
|
124
145
|
onPreviewClick,
|
|
125
146
|
showReplace
|
|
@@ -140,10 +161,14 @@ class Upload extends _baseComponent.default {
|
|
|
140
161
|
listType,
|
|
141
162
|
onRemove,
|
|
142
163
|
onRetry,
|
|
143
|
-
|
|
164
|
+
index,
|
|
165
|
+
key: uid || (0, _concat.default)(_context = "".concat(name)).call(_context, index),
|
|
144
166
|
showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
|
|
145
167
|
style: itemStyle,
|
|
146
168
|
disabled,
|
|
169
|
+
showPicInfo,
|
|
170
|
+
renderPicInfo,
|
|
171
|
+
renderThumbnail,
|
|
147
172
|
showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
|
|
148
173
|
onReplace,
|
|
149
174
|
onPreviewClick: typeof onPreviewClick !== 'undefined' ? () => this.foundation.handlePreviewClick(file) : undefined
|
|
@@ -165,28 +190,69 @@ class Upload extends _baseComponent.default {
|
|
|
165
190
|
};
|
|
166
191
|
|
|
167
192
|
this.renderFileList = () => {
|
|
193
|
+
const {
|
|
194
|
+
listType
|
|
195
|
+
} = this.props;
|
|
196
|
+
|
|
197
|
+
if (listType === _constants.strings.FILE_LIST_PIC) {
|
|
198
|
+
return this.renderFileListPic();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (listType === _constants.strings.FILE_LIST_DEFAULT) {
|
|
202
|
+
return this.renderFileListDefault();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return null;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
this.renderFileListPic = () => {
|
|
168
209
|
const {
|
|
169
210
|
showUploadList,
|
|
170
|
-
listType,
|
|
171
211
|
limit,
|
|
172
212
|
disabled,
|
|
173
|
-
children
|
|
213
|
+
children,
|
|
214
|
+
draggable
|
|
174
215
|
} = this.props;
|
|
175
216
|
const {
|
|
176
|
-
fileList: stateFileList
|
|
217
|
+
fileList: stateFileList,
|
|
218
|
+
dragAreaStatus
|
|
177
219
|
} = this.state;
|
|
178
220
|
const fileList = this.props.fileList || stateFileList;
|
|
179
|
-
const
|
|
180
|
-
const
|
|
221
|
+
const showAddTriggerInList = limit ? limit > fileList.length : true;
|
|
222
|
+
const dragAreaBaseCls = "".concat(prefixCls, "-drag-area");
|
|
181
223
|
const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"), {
|
|
182
|
-
["".concat(prefixCls, "-picture-add")]:
|
|
224
|
+
["".concat(prefixCls, "-picture-add")]: true,
|
|
183
225
|
["".concat(prefixCls, "-picture-add-disabled")]: disabled
|
|
184
226
|
});
|
|
185
|
-
|
|
186
|
-
|
|
227
|
+
const fileListCls = (0, _classnames.default)("".concat(prefixCls, "-file-list"), {
|
|
228
|
+
["".concat(prefixCls, "-picture-file-list")]: true
|
|
229
|
+
});
|
|
230
|
+
const dragAreaCls = (0, _classnames.default)({
|
|
231
|
+
["".concat(dragAreaBaseCls, "-legal")]: dragAreaStatus === _constants.strings.DRAG_AREA_LEGAL,
|
|
232
|
+
["".concat(dragAreaBaseCls, "-illegal")]: dragAreaStatus === _constants.strings.DRAG_AREA_ILLEGAL
|
|
233
|
+
});
|
|
234
|
+
const mainCls = "".concat(prefixCls, "-file-list-main");
|
|
235
|
+
const addContentProps = {
|
|
187
236
|
className: uploadAddCls,
|
|
188
237
|
onClick: this.onClick
|
|
189
|
-
}
|
|
238
|
+
};
|
|
239
|
+
const containerProps = {
|
|
240
|
+
className: fileListCls
|
|
241
|
+
};
|
|
242
|
+
const draggableProps = {
|
|
243
|
+
onDrop: this.onDrop,
|
|
244
|
+
onDragOver: this.onDragOver,
|
|
245
|
+
onDragLeave: this.onDragLeave,
|
|
246
|
+
onDragEnter: this.onDragEnter
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
if (draggable) {
|
|
250
|
+
(0, _assign.default)(addContentProps, draggableProps, {
|
|
251
|
+
className: (0, _classnames.default)(uploadAddCls, dragAreaCls)
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const addContent = /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({}, addContentProps), children);
|
|
190
256
|
|
|
191
257
|
if (!showUploadList || !fileList.length) {
|
|
192
258
|
if (showAddTriggerInList) {
|
|
@@ -196,18 +262,39 @@ class Upload extends _baseComponent.default {
|
|
|
196
262
|
return null;
|
|
197
263
|
}
|
|
198
264
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
})
|
|
265
|
+
return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
266
|
+
componentName: "Upload"
|
|
267
|
+
}, locale => /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({}, containerProps), /*#__PURE__*/_react.default.createElement("div", {
|
|
268
|
+
className: mainCls
|
|
269
|
+
}, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
this.renderFileListDefault = () => {
|
|
273
|
+
const {
|
|
274
|
+
showUploadList,
|
|
275
|
+
limit,
|
|
276
|
+
disabled
|
|
277
|
+
} = this.props;
|
|
278
|
+
const {
|
|
279
|
+
fileList: stateFileList
|
|
280
|
+
} = this.state;
|
|
281
|
+
const fileList = this.props.fileList || stateFileList;
|
|
282
|
+
const fileListCls = (0, _classnames.default)("".concat(prefixCls, "-file-list"));
|
|
202
283
|
const titleCls = "".concat(prefixCls, "-file-list-title");
|
|
203
284
|
const mainCls = "".concat(prefixCls, "-file-list-main");
|
|
204
|
-
const showTitle = limit !== 1 && fileList.length
|
|
285
|
+
const showTitle = limit !== 1 && fileList.length;
|
|
205
286
|
const showClear = this.props.showClear && !disabled;
|
|
287
|
+
const containerProps = {
|
|
288
|
+
className: fileListCls
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
if (!showUploadList || !fileList.length) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
|
|
206
295
|
return /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
207
296
|
componentName: "Upload"
|
|
208
|
-
}, locale => /*#__PURE__*/_react.default.createElement("div", {
|
|
209
|
-
className: fileListCls
|
|
210
|
-
}, showTitle ? /*#__PURE__*/_react.default.createElement("div", {
|
|
297
|
+
}, locale => /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({}, containerProps), showTitle ? /*#__PURE__*/_react.default.createElement("div", {
|
|
211
298
|
className: titleCls
|
|
212
299
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
213
300
|
className: "".concat(titleCls, "-choosen")
|
|
@@ -216,7 +303,7 @@ class Upload extends _baseComponent.default {
|
|
|
216
303
|
className: "".concat(titleCls, "-clear")
|
|
217
304
|
}, locale.clear) : null) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
218
305
|
className: mainCls
|
|
219
|
-
}, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale))
|
|
306
|
+
}, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)))));
|
|
220
307
|
};
|
|
221
308
|
|
|
222
309
|
this.onDrop = e => {
|
|
@@ -236,6 +323,28 @@ class Upload extends _baseComponent.default {
|
|
|
236
323
|
this.foundation.handleDragEnter(e);
|
|
237
324
|
};
|
|
238
325
|
|
|
326
|
+
this.renderAddContent = () => {
|
|
327
|
+
const {
|
|
328
|
+
draggable,
|
|
329
|
+
children,
|
|
330
|
+
listType
|
|
331
|
+
} = this.props;
|
|
332
|
+
const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"));
|
|
333
|
+
|
|
334
|
+
if (listType === _constants.strings.FILE_LIST_PIC) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (draggable) {
|
|
339
|
+
return this.renderDragArea();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
343
|
+
className: uploadAddCls,
|
|
344
|
+
onClick: this.onClick
|
|
345
|
+
}, children);
|
|
346
|
+
};
|
|
347
|
+
|
|
239
348
|
this.renderDragArea = () => {
|
|
240
349
|
const {
|
|
241
350
|
dragAreaStatus
|
|
@@ -422,7 +531,6 @@ class Upload extends _baseComponent.default {
|
|
|
422
531
|
["".concat(prefixCls, "-warning")]: validateStatus === 'warning',
|
|
423
532
|
["".concat(prefixCls, "-success")]: validateStatus === 'success'
|
|
424
533
|
}, className);
|
|
425
|
-
const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"));
|
|
426
534
|
const inputCls = (0, _classnames.default)("".concat(prefixCls, "-hidden-input"));
|
|
427
535
|
const inputReplaceCls = (0, _classnames.default)("".concat(prefixCls, "-hidden-input-replace"));
|
|
428
536
|
const promptCls = (0, _classnames.default)("".concat(prefixCls, "-prompt"));
|
|
@@ -431,10 +539,6 @@ class Upload extends _baseComponent.default {
|
|
|
431
539
|
directory: 'directory',
|
|
432
540
|
webkitdirectory: 'webkitdirectory'
|
|
433
541
|
} : {};
|
|
434
|
-
const addContent = listType !== _constants.strings.FILE_LIST_PIC ? /*#__PURE__*/_react.default.createElement("div", {
|
|
435
|
-
className: uploadAddCls,
|
|
436
|
-
onClick: this.onClick
|
|
437
|
-
}, children) : null;
|
|
438
542
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
439
543
|
className: uploadCls,
|
|
440
544
|
style: style,
|
|
@@ -460,7 +564,7 @@ class Upload extends _baseComponent.default {
|
|
|
460
564
|
tabIndex: -1,
|
|
461
565
|
className: inputReplaceCls,
|
|
462
566
|
ref: this.replaceInputRef
|
|
463
|
-
}),
|
|
567
|
+
}), this.renderAddContent(), prompt ? /*#__PURE__*/_react.default.createElement("div", {
|
|
464
568
|
className: promptCls
|
|
465
569
|
}, prompt) : null, validateMessage ? /*#__PURE__*/_react.default.createElement("div", {
|
|
466
570
|
className: validateMsgCls
|
|
@@ -515,7 +619,10 @@ Upload.propTypes = {
|
|
|
515
619
|
prompt: _propTypes.default.node,
|
|
516
620
|
promptPosition: _propTypes.default.oneOf(_constants.strings.PROMPT_POSITION),
|
|
517
621
|
renderFileItem: _propTypes.default.func,
|
|
622
|
+
renderPicInfo: _propTypes.default.func,
|
|
623
|
+
renderThumbnail: _propTypes.default.func,
|
|
518
624
|
showClear: _propTypes.default.bool,
|
|
625
|
+
showPicInfo: _propTypes.default.bool,
|
|
519
626
|
showReplace: _propTypes.default.bool,
|
|
520
627
|
showRetry: _propTypes.default.bool,
|
|
521
628
|
showUploadList: _propTypes.default.bool,
|
|
@@ -549,6 +656,7 @@ Upload.defaultProps = {
|
|
|
549
656
|
onSuccess: _noop2.default,
|
|
550
657
|
promptPosition: 'right',
|
|
551
658
|
showClear: true,
|
|
659
|
+
showPicInfo: false,
|
|
552
660
|
showReplace: false,
|
|
553
661
|
showRetry: true,
|
|
554
662
|
showUploadList: true,
|
|
@@ -42,12 +42,15 @@ export interface FileItem extends BaseFileItem {
|
|
|
42
42
|
validateMessage?: ReactNode;
|
|
43
43
|
}
|
|
44
44
|
export interface RenderFileItemProps extends FileItem {
|
|
45
|
+
index?: number;
|
|
45
46
|
previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
46
47
|
listType: UploadListType;
|
|
47
48
|
onRemove: (props: RenderFileItemProps, e: MouseEvent) => void;
|
|
48
49
|
onRetry: (props: RenderFileItemProps, e: MouseEvent) => void;
|
|
49
50
|
onReplace: (props: RenderFileItemProps, e: MouseEvent) => void;
|
|
50
51
|
key: string;
|
|
52
|
+
showPicInfo?: boolean;
|
|
53
|
+
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
51
54
|
showRetry: boolean;
|
|
52
55
|
showReplace: boolean;
|
|
53
56
|
style?: CSSProperties;
|
package/lib/es/_base/base.css
CHANGED
|
@@ -399,7 +399,7 @@ body, body[theme-mode=dark] .semi-always-light {
|
|
|
399
399
|
--semi-color-link-visited: rgba(var(--semi-blue-5), 1);
|
|
400
400
|
--semi-color-border: rgba(var(--semi-grey-9), .08);
|
|
401
401
|
--semi-color-nav-bg: rgba(var(--semi-white), 1);
|
|
402
|
-
--semi-overlay-bg: rgba(22, 22, 26, .6);
|
|
402
|
+
--semi-color-overlay-bg: rgba(22, 22, 26, .6);
|
|
403
403
|
--semi-color-fill-0: rgba(var(--semi-grey-8), .05);
|
|
404
404
|
--semi-color-fill-1: rgba(var(--semi-grey-8), .09);
|
|
405
405
|
--semi-color-fill-2: rgba(var(--semi-grey-8), .13);
|
|
@@ -486,7 +486,7 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
486
486
|
--semi-color-link-visited: rgba(var(--semi-blue-5), 1);
|
|
487
487
|
--semi-color-nav-bg: rgba(35, 36, 41, 1);
|
|
488
488
|
--semi-shadow-elevated: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 4px 14px rgba(0, 0, 0, .25);
|
|
489
|
-
--semi-overlay-bg: rgba(22, 22, 26, .6);
|
|
489
|
+
--semi-color-overlay-bg: rgba(22, 22, 26, .6);
|
|
490
490
|
--semi-color-fill-0: rgba(var(--semi-white), .05);
|
|
491
491
|
--semi-color-fill-1: rgba(var(--semi-white), .09);
|
|
492
492
|
--semi-color-fill-2: rgba(var(--semi-white), .13);
|
package/lib/es/_utils/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare function cloneDeep(value: any, customizer?: (value: any) => void)
|
|
|
30
30
|
export declare const getHighLightTextHTML: ({ sourceString, searchWords, option }: GetHighLightTextHTMLProps) => (string | React.ReactElement<{
|
|
31
31
|
style: Record<string, any>;
|
|
32
32
|
className: string;
|
|
33
|
+
key: string;
|
|
33
34
|
}, string | React.JSXElementConstructor<any>>)[];
|
|
34
35
|
export interface RegisterMediaQueryOption {
|
|
35
36
|
match?: (e: MediaQueryList | MediaQueryListEvent) => void;
|