@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.
Files changed (133) hide show
  1. package/_base/_story/a11y.jsx +1302 -0
  2. package/_base/_story/a11y.scss +49 -0
  3. package/_base/_story/index.stories.js +3 -1
  4. package/_utils/index.ts +9 -4
  5. package/button/Button.tsx +1 -0
  6. package/cascader/__test__/cascader.test.js +221 -0
  7. package/cascader/_story/cascader.stories.js +138 -0
  8. package/cascader/index.tsx +37 -21
  9. package/cascader/item.tsx +4 -2
  10. package/checkbox/checkbox.tsx +2 -0
  11. package/checkbox/checkboxGroup.tsx +3 -2
  12. package/datePicker/__test__/datePicker.test.js +85 -2
  13. package/datePicker/_story/datePicker.stories.js +29 -1
  14. package/datePicker/_story/v2/YearButton.jsx +17 -0
  15. package/datePicker/_story/v2/index.js +1 -0
  16. package/datePicker/monthsGrid.tsx +12 -1
  17. package/datePicker/navigation.tsx +55 -29
  18. package/descriptions/__test__/descriptions.test.js +27 -1
  19. package/descriptions/_story/descriptions.stories.js +52 -2
  20. package/descriptions/item.tsx +1 -1
  21. package/dist/css/semi.css +56 -32
  22. package/dist/css/semi.min.css +1 -1
  23. package/dist/umd/semi-ui.js +854 -258
  24. package/dist/umd/semi-ui.js.map +1 -1
  25. package/dist/umd/semi-ui.min.js +1 -1
  26. package/dist/umd/semi-ui.min.js.map +1 -1
  27. package/empty/index.tsx +2 -2
  28. package/form/_story/form.stories.js +0 -67
  29. package/form/hoc/withField.tsx +1 -1
  30. package/gulpfile.js +2 -1
  31. package/lib/cjs/_base/base.css +2 -2
  32. package/lib/cjs/_utils/index.d.ts +1 -0
  33. package/lib/cjs/_utils/index.js +12 -5
  34. package/lib/cjs/button/Button.d.ts +1 -0
  35. package/lib/cjs/cascader/index.d.ts +7 -0
  36. package/lib/cjs/cascader/index.js +35 -22
  37. package/lib/cjs/cascader/item.d.ts +2 -0
  38. package/lib/cjs/cascader/item.js +4 -2
  39. package/lib/cjs/checkbox/checkbox.js +3 -1
  40. package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -0
  41. package/lib/cjs/checkbox/checkboxGroup.js +3 -1
  42. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -0
  43. package/lib/cjs/datePicker/monthsGrid.js +6 -0
  44. package/lib/cjs/datePicker/navigation.js +47 -7
  45. package/lib/cjs/descriptions/item.js +1 -1
  46. package/lib/cjs/empty/index.d.ts +2 -2
  47. package/lib/cjs/empty/index.js +19 -18
  48. package/lib/cjs/form/baseForm.d.ts +6 -0
  49. package/lib/cjs/form/field.d.ts +6 -0
  50. package/lib/cjs/form/hoc/withField.js +3 -1
  51. package/lib/cjs/locale/source/es.d.ts +7 -0
  52. package/lib/cjs/locale/source/es.js +168 -0
  53. package/lib/cjs/modal/Modal.d.ts +2 -2
  54. package/lib/cjs/modal/Modal.js +2 -2
  55. package/lib/cjs/modal/confirm.d.ts +10 -10
  56. package/lib/cjs/navigation/index.d.ts +2 -2
  57. package/lib/cjs/pagination/index.js +9 -4
  58. package/lib/cjs/rating/item.js +1 -1
  59. package/lib/cjs/select/index.d.ts +10 -0
  60. package/lib/cjs/select/index.js +15 -9
  61. package/lib/cjs/timeline/item.d.ts +5 -2
  62. package/lib/cjs/timeline/item.js +13 -7
  63. package/lib/cjs/tree/treeNode.js +0 -2
  64. package/lib/cjs/upload/fileCard.d.ts +2 -0
  65. package/lib/cjs/upload/fileCard.js +70 -45
  66. package/lib/cjs/upload/index.d.ts +23 -2
  67. package/lib/cjs/upload/index.js +133 -25
  68. package/lib/cjs/upload/interface.d.ts +3 -0
  69. package/lib/es/_base/base.css +2 -2
  70. package/lib/es/_utils/index.d.ts +1 -0
  71. package/lib/es/_utils/index.js +12 -5
  72. package/lib/es/button/Button.d.ts +1 -0
  73. package/lib/es/cascader/index.d.ts +7 -0
  74. package/lib/es/cascader/index.js +34 -25
  75. package/lib/es/cascader/item.d.ts +2 -0
  76. package/lib/es/cascader/item.js +4 -2
  77. package/lib/es/checkbox/checkbox.js +3 -1
  78. package/lib/es/checkbox/checkboxGroup.d.ts +1 -0
  79. package/lib/es/checkbox/checkboxGroup.js +3 -1
  80. package/lib/es/datePicker/monthsGrid.d.ts +1 -0
  81. package/lib/es/datePicker/monthsGrid.js +6 -0
  82. package/lib/es/datePicker/navigation.js +48 -8
  83. package/lib/es/descriptions/item.js +1 -1
  84. package/lib/es/empty/index.d.ts +2 -2
  85. package/lib/es/empty/index.js +19 -18
  86. package/lib/es/form/baseForm.d.ts +6 -0
  87. package/lib/es/form/field.d.ts +6 -0
  88. package/lib/es/form/hoc/withField.js +3 -1
  89. package/lib/es/locale/source/es.d.ts +7 -0
  90. package/lib/es/locale/source/es.js +157 -0
  91. package/lib/es/modal/Modal.d.ts +2 -2
  92. package/lib/es/modal/Modal.js +2 -2
  93. package/lib/es/modal/confirm.d.ts +10 -10
  94. package/lib/es/navigation/index.d.ts +2 -2
  95. package/lib/es/pagination/index.js +8 -4
  96. package/lib/es/rating/item.js +1 -1
  97. package/lib/es/select/index.d.ts +10 -0
  98. package/lib/es/select/index.js +19 -9
  99. package/lib/es/timeline/item.d.ts +5 -2
  100. package/lib/es/timeline/item.js +12 -7
  101. package/lib/es/tree/treeNode.js +0 -2
  102. package/lib/es/upload/fileCard.d.ts +2 -0
  103. package/lib/es/upload/fileCard.js +69 -44
  104. package/lib/es/upload/index.d.ts +23 -2
  105. package/lib/es/upload/index.js +133 -24
  106. package/lib/es/upload/interface.d.ts +3 -0
  107. package/locale/source/es.ts +160 -0
  108. package/modal/Modal.tsx +4 -4
  109. package/navigation/__test__/navigation.test.js +4 -4
  110. package/navigation/_story/AutoOpen/index.js +1 -1
  111. package/navigation/_story/WithChildren/index.js +1 -1
  112. package/navigation/_story/navigation.stories.js +1 -1
  113. package/navigation/_story/navigation.stories.tsx +4 -4
  114. package/navigation/index.tsx +2 -2
  115. package/package.json +17 -9
  116. package/pagination/_story/pagination.stories.js +11 -0
  117. package/pagination/index.tsx +9 -4
  118. package/popover/Arrow.tsx +1 -1
  119. package/radio/_story/radio.stories.js +12 -1
  120. package/rating/item.tsx +1 -1
  121. package/select/_story/select.stories.js +39 -14
  122. package/select/index.tsx +21 -7
  123. package/table/_story/DynamicFilters/index.js +13 -16
  124. package/timeline/__test__/timeline.test.js +17 -1
  125. package/timeline/_story/timeline.stories.js +70 -6
  126. package/timeline/item.tsx +11 -6
  127. package/tooltip/_story/tooltip.stories.js +1 -1
  128. package/tree/_story/tree.stories.js +2 -2
  129. package/tree/treeNode.tsx +0 -2
  130. package/upload/__test__/upload.test.js +50 -1
  131. package/upload/fileCard.tsx +110 -95
  132. package/upload/index.tsx +147 -53
  133. package/upload/interface.ts +3 -0
@@ -4,13 +4,13 @@ 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
8
  import LocaleConsumer from '../locale/localeConsumer';
8
9
  import IconButton from '../iconButton/index';
9
10
  import Progress from '../progress/index';
10
11
  import Tooltip from '../tooltip/index';
11
12
  import Spin from '../spin/index';
12
13
  import { isElement } from '../_base/reactUtils';
13
- import { IconAlertCircle, IconClose, IconFile, IconRefresh } from '@douyinfe/semi-icons';
14
14
  const prefixCls = cssClasses.PREFIX;
15
15
 
16
16
  const ErrorSvg = function () {
@@ -158,16 +158,23 @@ class FileCard extends PureComponent {
158
158
  status,
159
159
  disabled,
160
160
  style,
161
- onPreviewClick
161
+ onPreviewClick,
162
+ showPicInfo,
163
+ renderPicInfo,
164
+ renderThumbnail,
165
+ name,
166
+ index
162
167
  } = this.props;
168
+ const showProgress = status === strings.FILE_STATUS_UPLOADING && percent !== 100;
169
+ const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
170
+ const showReplace = status === strings.FILE_STATUS_SUCCESS && this.props.showReplace;
163
171
  const filePicCardCls = cls({
164
172
  ["".concat(prefixCls, "-picture-file-card")]: true,
165
173
  ["".concat(prefixCls, "-picture-file-card-disabled")]: disabled,
166
- ["".concat(prefixCls, "-picture-file-card-show-pointer")]: typeof onPreviewClick !== 'undefined'
174
+ ["".concat(prefixCls, "-picture-file-card-show-pointer")]: typeof onPreviewClick !== 'undefined',
175
+ ["".concat(prefixCls, "-picture-file-card-error")]: status === strings.FILE_STATUS_UPLOAD_FAIL,
176
+ ["".concat(prefixCls, "-picture-file-card-uploading")]: showProgress
167
177
  });
168
- const showProgress = status === strings.FILE_STATUS_UPLOADING && percent !== 100;
169
- const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
170
- const showReplace = status === strings.FILE_STATUS_SUCCESS && this.props.showReplace;
171
178
  const closeCls = "".concat(prefixCls, "-picture-file-card-close");
172
179
  const retry = /*#__PURE__*/React.createElement("div", {
173
180
  className: "".concat(prefixCls, "-picture-file-card-retry"),
@@ -187,47 +194,38 @@ class FileCard extends PureComponent {
187
194
  }, /*#__PURE__*/React.createElement(ReplaceSvg, {
188
195
  className: "".concat(prefixCls, "-picture-file-card-icon-replace")
189
196
  })));
197
+ const picInfo = typeof renderPicInfo === 'function' ? renderPicInfo(this.props) : /*#__PURE__*/React.createElement("div", {
198
+ className: "".concat(prefixCls, "-picture-file-card-pic-info")
199
+ }, index + 1);
200
+ const thumbnail = typeof renderThumbnail === 'function' ? renderThumbnail(this.props) : /*#__PURE__*/React.createElement("img", {
201
+ src: url,
202
+ alt: "picture of ".concat(name)
203
+ });
190
204
  return /*#__PURE__*/React.createElement("div", {
191
205
  className: filePicCardCls,
192
206
  style: style,
193
207
  onClick: onPreviewClick
194
- }, /*#__PURE__*/React.createElement("img", {
195
- src: url
196
- }), showProgress ? /*#__PURE__*/React.createElement(Progress, {
208
+ }, thumbnail, showProgress ? /*#__PURE__*/React.createElement(Progress, {
197
209
  percent: percent,
198
210
  type: "circle",
199
211
  size: "small",
200
212
  orbitStroke: '#FFF'
201
- }) : null, showRetry ? retry : null, showReplace && replace, disabled ? null : /*#__PURE__*/React.createElement("div", {
202
- className: closeCls,
203
- onClick: e => this.onRemove(e)
213
+ }) : null, showRetry ? retry : null, showReplace && replace, showPicInfo && picInfo, !disabled && /*#__PURE__*/React.createElement("div", {
214
+ className: closeCls
204
215
  }, /*#__PURE__*/React.createElement(IconClose, {
205
- size: "extra-small"
216
+ size: "extra-small",
217
+ onClick: e => this.onRemove(e)
206
218
  })), this.renderPicValidateMsg());
207
219
  }
208
220
 
209
- onRemove(e) {
210
- e.stopPropagation();
211
- this.props.onRemove(this.props, e);
212
- }
213
-
214
- onReplace(e) {
215
- e.stopPropagation();
216
- this.props.onReplace(this.props, e);
217
- }
218
-
219
- onRetry(e) {
220
- e.stopPropagation();
221
- this.props.onRetry(this.props, e);
222
- }
223
-
224
- render() {
221
+ renderFile(locale) {
225
222
  const {
226
223
  name,
227
224
  size,
228
225
  percent,
229
226
  url,
230
- listType,
227
+ showRetry: propsShowRetry,
228
+ showReplace: propsShowReplace,
231
229
  preview,
232
230
  previewFile,
233
231
  status,
@@ -248,15 +246,8 @@ class FileCard extends PureComponent {
248
246
  const replaceCls = "".concat(prefixCls, "-file-card-replace");
249
247
  const showProgress = !(percent === 100 || typeof percent === 'undefined') && status === strings.FILE_STATUS_UPLOADING; // only show retry when upload fail & showRetry is true, no need to show during validate fail
250
248
 
251
- const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
252
- const showReplace = status === strings.FILE_STATUS_SUCCESS && this.props.showReplace;
253
-
254
- if (listType === strings.FILE_LIST_PIC) {
255
- return /*#__PURE__*/React.createElement(LocaleConsumer, {
256
- componentName: "Upload"
257
- }, locale => this.renderPic(locale));
258
- }
259
-
249
+ const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && propsShowRetry;
250
+ const showReplace = status === strings.FILE_STATUS_SUCCESS && propsShowReplace;
260
251
  const fileSize = this.transSize(size);
261
252
  let previewContent = preview ? /*#__PURE__*/React.createElement("img", {
262
253
  src: url
@@ -268,9 +259,7 @@ class FileCard extends PureComponent {
268
259
  previewContent = previewFile(this.props);
269
260
  }
270
261
 
271
- return /*#__PURE__*/React.createElement(LocaleConsumer, {
272
- componentName: "Upload"
273
- }, locale => /*#__PURE__*/React.createElement("div", {
262
+ return /*#__PURE__*/React.createElement("div", {
274
263
  className: fileCardCls,
275
264
  style: style,
276
265
  onClick: onPreviewClick
@@ -315,7 +304,42 @@ class FileCard extends PureComponent {
315
304
  theme: "borderless",
316
305
  size: "small",
317
306
  className: closeCls
318
- })));
307
+ }));
308
+ }
309
+
310
+ onRemove(e) {
311
+ e.stopPropagation();
312
+ this.props.onRemove(this.props, e);
313
+ }
314
+
315
+ onReplace(e) {
316
+ e.stopPropagation();
317
+ this.props.onReplace(this.props, e);
318
+ }
319
+
320
+ onRetry(e) {
321
+ e.stopPropagation();
322
+ this.props.onRetry(this.props, e);
323
+ }
324
+
325
+ render() {
326
+ const {
327
+ listType
328
+ } = this.props;
329
+
330
+ if (listType === strings.FILE_LIST_PIC) {
331
+ return /*#__PURE__*/React.createElement(LocaleConsumer, {
332
+ componentName: "Upload"
333
+ }, locale => this.renderPic(locale));
334
+ }
335
+
336
+ if (listType === strings.FILE_LIST_DEFAULT) {
337
+ return /*#__PURE__*/React.createElement(LocaleConsumer, {
338
+ componentName: "Upload"
339
+ }, locale => this.renderFile(locale));
340
+ }
341
+
342
+ return null;
319
343
  }
320
344
 
321
345
  }
@@ -338,7 +362,8 @@ FileCard.propTypes = {
338
362
  status: PropTypes.string,
339
363
  style: PropTypes.object,
340
364
  url: PropTypes.string,
341
- validateMessage: PropTypes.node
365
+ validateMessage: PropTypes.node,
366
+ index: PropTypes.number
342
367
  };
343
368
  FileCard.defaultProps = {
344
369
  listType: 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/es/upload/foundation';
3
+ import UploadFoundation, { CustomFile, UploadAdapter, BeforeUploadObjectResult, AfterUploadResult } from '@douyinfe/semi-foundation/lib/es/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
  }
@@ -72,6 +72,23 @@ class Upload extends BaseComponent {
72
72
  this.remove = fileItem => {
73
73
  this.foundation.handleRemove(fileItem);
74
74
  };
75
+ /**
76
+ * ref method
77
+ * insert files at index
78
+ * @param files Array<CustomFile>
79
+ * @param index number
80
+ * @returns
81
+ */
82
+
83
+
84
+ this.insert = (files, index) => {
85
+ return this.foundation.insertFileToList(files, index);
86
+ };
87
+ /**
88
+ * ref method
89
+ * manual upload by user
90
+ */
91
+
75
92
 
76
93
  this.upload = () => {
77
94
  const {
@@ -87,14 +104,18 @@ class Upload extends BaseComponent {
87
104
  name,
88
105
  status,
89
106
  validateMessage,
90
- _sizeInvalid
107
+ _sizeInvalid,
108
+ uid
91
109
  } = file;
92
110
  const {
93
111
  previewFile,
94
112
  listType,
95
113
  itemStyle,
96
114
  showRetry,
115
+ showPicInfo,
116
+ renderPicInfo,
97
117
  renderFileItem,
118
+ renderThumbnail,
98
119
  disabled,
99
120
  onPreviewClick,
100
121
  showReplace
@@ -115,10 +136,14 @@ class Upload extends BaseComponent {
115
136
  listType,
116
137
  onRemove,
117
138
  onRetry,
118
- key: _concatInstanceProperty(_context = "".concat(name)).call(_context, index),
139
+ index,
140
+ key: uid || _concatInstanceProperty(_context = "".concat(name)).call(_context, index),
119
141
  showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
120
142
  style: itemStyle,
121
143
  disabled,
144
+ showPicInfo,
145
+ renderPicInfo,
146
+ renderThumbnail,
122
147
  showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
123
148
  onReplace,
124
149
  onPreviewClick: typeof onPreviewClick !== 'undefined' ? () => this.foundation.handlePreviewClick(file) : undefined
@@ -140,27 +165,69 @@ class Upload extends BaseComponent {
140
165
  };
141
166
 
142
167
  this.renderFileList = () => {
168
+ const {
169
+ listType
170
+ } = this.props;
171
+
172
+ if (listType === strings.FILE_LIST_PIC) {
173
+ return this.renderFileListPic();
174
+ }
175
+
176
+ if (listType === strings.FILE_LIST_DEFAULT) {
177
+ return this.renderFileListDefault();
178
+ }
179
+
180
+ return null;
181
+ };
182
+
183
+ this.renderFileListPic = () => {
143
184
  const {
144
185
  showUploadList,
145
- listType,
146
186
  limit,
147
187
  disabled,
148
- children
188
+ children,
189
+ draggable
149
190
  } = this.props;
150
191
  const {
151
- fileList: stateFileList
192
+ fileList: stateFileList,
193
+ dragAreaStatus
152
194
  } = this.state;
153
195
  const fileList = this.props.fileList || stateFileList;
154
- const isPicType = listType === strings.FILE_LIST_PIC;
155
- const showAddTriggerInList = isPicType && (limit ? limit > fileList.length : true);
196
+ const showAddTriggerInList = limit ? limit > fileList.length : true;
197
+ const dragAreaBaseCls = "".concat(prefixCls, "-drag-area");
156
198
  const uploadAddCls = cls("".concat(prefixCls, "-add"), {
157
- ["".concat(prefixCls, "-picture-add")]: isPicType,
199
+ ["".concat(prefixCls, "-picture-add")]: true,
158
200
  ["".concat(prefixCls, "-picture-add-disabled")]: disabled
159
201
  });
160
- const addContent = /*#__PURE__*/React.createElement("div", {
202
+ const fileListCls = cls("".concat(prefixCls, "-file-list"), {
203
+ ["".concat(prefixCls, "-picture-file-list")]: true
204
+ });
205
+ const dragAreaCls = cls({
206
+ ["".concat(dragAreaBaseCls, "-legal")]: dragAreaStatus === strings.DRAG_AREA_LEGAL,
207
+ ["".concat(dragAreaBaseCls, "-illegal")]: dragAreaStatus === strings.DRAG_AREA_ILLEGAL
208
+ });
209
+ const mainCls = "".concat(prefixCls, "-file-list-main");
210
+ const addContentProps = {
161
211
  className: uploadAddCls,
162
212
  onClick: this.onClick
163
- }, children);
213
+ };
214
+ const containerProps = {
215
+ className: fileListCls
216
+ };
217
+ const draggableProps = {
218
+ onDrop: this.onDrop,
219
+ onDragOver: this.onDragOver,
220
+ onDragLeave: this.onDragLeave,
221
+ onDragEnter: this.onDragEnter
222
+ };
223
+
224
+ if (draggable) {
225
+ _Object$assign(addContentProps, draggableProps, {
226
+ className: cls(uploadAddCls, dragAreaCls)
227
+ });
228
+ }
229
+
230
+ const addContent = /*#__PURE__*/React.createElement("div", _Object$assign({}, addContentProps), children);
164
231
 
165
232
  if (!showUploadList || !fileList.length) {
166
233
  if (showAddTriggerInList) {
@@ -170,18 +237,39 @@ class Upload extends BaseComponent {
170
237
  return null;
171
238
  }
172
239
 
173
- const fileListCls = cls("".concat(prefixCls, "-file-list"), {
174
- ["".concat(prefixCls, "-picture-file-list")]: isPicType
175
- });
240
+ return /*#__PURE__*/React.createElement(LocaleConsumer, {
241
+ componentName: "Upload"
242
+ }, locale => /*#__PURE__*/React.createElement("div", _Object$assign({}, containerProps), /*#__PURE__*/React.createElement("div", {
243
+ className: mainCls
244
+ }, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
245
+ };
246
+
247
+ this.renderFileListDefault = () => {
248
+ const {
249
+ showUploadList,
250
+ limit,
251
+ disabled
252
+ } = this.props;
253
+ const {
254
+ fileList: stateFileList
255
+ } = this.state;
256
+ const fileList = this.props.fileList || stateFileList;
257
+ const fileListCls = cls("".concat(prefixCls, "-file-list"));
176
258
  const titleCls = "".concat(prefixCls, "-file-list-title");
177
259
  const mainCls = "".concat(prefixCls, "-file-list-main");
178
- const showTitle = limit !== 1 && fileList.length && listType !== strings.FILE_LIST_PIC;
260
+ const showTitle = limit !== 1 && fileList.length;
179
261
  const showClear = this.props.showClear && !disabled;
262
+ const containerProps = {
263
+ className: fileListCls
264
+ };
265
+
266
+ if (!showUploadList || !fileList.length) {
267
+ return null;
268
+ }
269
+
180
270
  return /*#__PURE__*/React.createElement(LocaleConsumer, {
181
271
  componentName: "Upload"
182
- }, locale => /*#__PURE__*/React.createElement("div", {
183
- className: fileListCls
184
- }, showTitle ? /*#__PURE__*/React.createElement("div", {
272
+ }, locale => /*#__PURE__*/React.createElement("div", _Object$assign({}, containerProps), showTitle ? /*#__PURE__*/React.createElement("div", {
185
273
  className: titleCls
186
274
  }, /*#__PURE__*/React.createElement("span", {
187
275
  className: "".concat(titleCls, "-choosen")
@@ -190,7 +278,7 @@ class Upload extends BaseComponent {
190
278
  className: "".concat(titleCls, "-clear")
191
279
  }, locale.clear) : null) : null, /*#__PURE__*/React.createElement("div", {
192
280
  className: mainCls
193
- }, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
281
+ }, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)))));
194
282
  };
195
283
 
196
284
  this.onDrop = e => {
@@ -210,6 +298,28 @@ class Upload extends BaseComponent {
210
298
  this.foundation.handleDragEnter(e);
211
299
  };
212
300
 
301
+ this.renderAddContent = () => {
302
+ const {
303
+ draggable,
304
+ children,
305
+ listType
306
+ } = this.props;
307
+ const uploadAddCls = cls("".concat(prefixCls, "-add"));
308
+
309
+ if (listType === strings.FILE_LIST_PIC) {
310
+ return null;
311
+ }
312
+
313
+ if (draggable) {
314
+ return this.renderDragArea();
315
+ }
316
+
317
+ return /*#__PURE__*/React.createElement("div", {
318
+ className: uploadAddCls,
319
+ onClick: this.onClick
320
+ }, children);
321
+ };
322
+
213
323
  this.renderDragArea = () => {
214
324
  const {
215
325
  dragAreaStatus
@@ -396,7 +506,6 @@ class Upload extends BaseComponent {
396
506
  ["".concat(prefixCls, "-warning")]: validateStatus === 'warning',
397
507
  ["".concat(prefixCls, "-success")]: validateStatus === 'success'
398
508
  }, className);
399
- const uploadAddCls = cls("".concat(prefixCls, "-add"));
400
509
  const inputCls = cls("".concat(prefixCls, "-hidden-input"));
401
510
  const inputReplaceCls = cls("".concat(prefixCls, "-hidden-input-replace"));
402
511
  const promptCls = cls("".concat(prefixCls, "-prompt"));
@@ -405,10 +514,6 @@ class Upload extends BaseComponent {
405
514
  directory: 'directory',
406
515
  webkitdirectory: 'webkitdirectory'
407
516
  } : {};
408
- const addContent = listType !== strings.FILE_LIST_PIC ? /*#__PURE__*/React.createElement("div", {
409
- className: uploadAddCls,
410
- onClick: this.onClick
411
- }, children) : null;
412
517
  return /*#__PURE__*/React.createElement("div", {
413
518
  className: uploadCls,
414
519
  style: style,
@@ -434,7 +539,7 @@ class Upload extends BaseComponent {
434
539
  tabIndex: -1,
435
540
  className: inputReplaceCls,
436
541
  ref: this.replaceInputRef
437
- }), draggable ? this.renderDragArea() : addContent, prompt ? /*#__PURE__*/React.createElement("div", {
542
+ }), this.renderAddContent(), prompt ? /*#__PURE__*/React.createElement("div", {
438
543
  className: promptCls
439
544
  }, prompt) : null, validateMessage ? /*#__PURE__*/React.createElement("div", {
440
545
  className: validateMsgCls
@@ -489,7 +594,10 @@ Upload.propTypes = {
489
594
  prompt: PropTypes.node,
490
595
  promptPosition: PropTypes.oneOf(strings.PROMPT_POSITION),
491
596
  renderFileItem: PropTypes.func,
597
+ renderPicInfo: PropTypes.func,
598
+ renderThumbnail: PropTypes.func,
492
599
  showClear: PropTypes.bool,
600
+ showPicInfo: PropTypes.bool,
493
601
  showReplace: PropTypes.bool,
494
602
  showRetry: PropTypes.bool,
495
603
  showUploadList: PropTypes.bool,
@@ -523,6 +631,7 @@ Upload.defaultProps = {
523
631
  onSuccess: _noop,
524
632
  promptPosition: 'right',
525
633
  showClear: true,
634
+ showPicInfo: false,
526
635
  showReplace: false,
527
636
  showRetry: true,
528
637
  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;
@@ -0,0 +1,160 @@
1
+ import { es } from 'date-fns/locale';
2
+ import { Locale } from '../interface';
3
+
4
+ /**
5
+ * [i18n-Spanish(es)]
6
+ *
7
+ */
8
+
9
+ const locale: Locale = {
10
+ code: 'es',
11
+ dateFnsLocale: es,
12
+ Pagination: {
13
+ item: 'objeto',
14
+ pageSize: ' objetos / página',
15
+ page: ' páginas',
16
+ total: '',
17
+ jumpTo: 'Ir a',
18
+ },
19
+ Modal: {
20
+ confirm: 'Aceptar',
21
+ cancel: 'Cancelar',
22
+ },
23
+ TimePicker: {
24
+ placeholder: {
25
+ time: 'Seleccionar hora',
26
+ timeRange: 'Seleccionar rango de tiempo',
27
+ },
28
+ begin: 'Hora inicial',
29
+ end: 'Hora final',
30
+ hour: '',
31
+ minute: '',
32
+ second: '',
33
+ AM: 'AM',
34
+ PM: 'PM',
35
+ },
36
+ DatePicker: {
37
+ placeholder: {
38
+ date: 'Seleccionar fecha',
39
+ dateTime: 'Seleccionar hora y fecha',
40
+ dateRange: ['Fecha inicial', 'Fecha final'],
41
+ dateTimeRange: ['Fecha inicial', 'Fecha final'],
42
+ },
43
+ footer: {
44
+ confirm: 'Aceptar',
45
+ cancel: 'Cancelar',
46
+ },
47
+ selectDate: 'Seleccionar fecha',
48
+ selectTime: 'Seleccionar hora',
49
+ year: 'año',
50
+ month: 'mes',
51
+ day: 'día',
52
+ monthText: '${month} ${year}',
53
+ months: {
54
+ 1: 'Ene',
55
+ 2: 'Feb',
56
+ 3: 'Mar',
57
+ 4: 'Abr',
58
+ 5: 'May',
59
+ 6: 'Jun',
60
+ 7: 'Jul',
61
+ 8: 'Ago',
62
+ 9: 'Sep',
63
+ 10: 'Oct',
64
+ 11: 'Nov',
65
+ 12: 'Dic',
66
+ },
67
+ fullMonths: {
68
+ 1: 'Enero',
69
+ 2: 'Febrero',
70
+ 3: 'Marzo',
71
+ 4: 'Abril',
72
+ 5: 'Mayo',
73
+ 6: 'Junio',
74
+ 7: 'Julio',
75
+ 8: 'Agosto',
76
+ 9: 'Septiembre',
77
+ 10: 'Octubre',
78
+ 11: 'Noviembre',
79
+ 12: 'Diciembre',
80
+ },
81
+ weeks: {
82
+ Mon: 'Lun',
83
+ Tue: 'Mar',
84
+ Wed: 'Mie',
85
+ Thu: 'Jue',
86
+ Fri: 'Vie',
87
+ Sat: 'Sab',
88
+ Sun: 'Dom',
89
+ },
90
+ localeFormatToken: {
91
+ FORMAT_SWITCH_DATE: 'yyyy-MM-dd',
92
+ },
93
+ },
94
+ Popconfirm: {
95
+ confirm: 'Aceptar',
96
+ cancel: 'Cancelar',
97
+ },
98
+ Navigation: {
99
+ collapseText: 'Contraer barra lateral',
100
+ expandText: 'Expandir barra lateral',
101
+ },
102
+ Table: {
103
+ emptyText: 'Sin resultados',
104
+ pageText: 'Mostrando del ${currentStart} al ${currentEnd} de ${total}',
105
+ },
106
+ Select: {
107
+ emptyText: 'Sin resultados',
108
+ createText: 'Crear',
109
+ },
110
+ Tree: {
111
+ emptyText: 'Sin resultados',
112
+ searchPlaceholder: 'Búsqueda',
113
+ },
114
+ Cascader: {
115
+ emptyText: 'Sin resultados',
116
+ },
117
+ List: {
118
+ emptyText: 'Sin resultados',
119
+ },
120
+ Calendar: {
121
+ allDay: 'Todo el día',
122
+ AM: '${time} AM',
123
+ PM: '${time} PM',
124
+ datestring: '',
125
+ remaining: '${remained} mas',
126
+ },
127
+ Upload: {
128
+ mainText: 'Clic aquí para cargar archivo o arrastre aquí el archivo',
129
+ illegalTips: 'Este tipo de archivo no es compatible',
130
+ legalTips: 'Suelte y comience a cargar',
131
+ retry: 'Reintentar',
132
+ replace: 'Reemplazar archivo',
133
+ clear: 'Limpiar',
134
+ selectedFiles: 'Archivos seleccionados',
135
+ illegalSize: 'Tamaño de archivo inválido',
136
+ fail: 'Error al cargar',
137
+ },
138
+ TreeSelect: {
139
+ searchPlaceholder: 'Búsqueda',
140
+ },
141
+ Typography: {
142
+ copy: 'Copiar',
143
+ copied: 'Copiado',
144
+ expand: 'Expandir',
145
+ collapse: 'Contraer',
146
+ },
147
+ Transfer: {
148
+ emptyLeft: 'Sin datos',
149
+ emptySearch: 'Sin resultados de búsqueda',
150
+ emptyRight: 'Sin contenido, verifique desde la izquierda',
151
+ placeholder: 'Búsqueda',
152
+ clear: 'Limpiar',
153
+ selectAll: 'Seleccionar todo',
154
+ clearSelectAll: 'Deseleccionar todo',
155
+ total: 'Total ${total} objetos',
156
+ selected: '${total} objetos seleccionados',
157
+ },
158
+ };
159
+
160
+ export default locale;