@douyinfe/semi-ui 2.1.4-alpha.0 → 2.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/_base/_story/a11y.jsx +1302 -0
  2. package/_base/_story/a11y.scss +49 -0
  3. package/_base/_story/index.scss +1 -0
  4. package/_base/_story/index.stories.js +3 -1
  5. package/_utils/index.ts +2 -1
  6. package/button/Button.tsx +1 -0
  7. package/button/__test__/button.test.js +15 -0
  8. package/button/_story/button.stories.js +13 -0
  9. package/button/buttonGroup.tsx +6 -4
  10. package/cascader/__test__/cascader.test.js +221 -0
  11. package/cascader/_story/cascader.stories.js +138 -0
  12. package/cascader/index.tsx +37 -21
  13. package/cascader/item.tsx +7 -2
  14. package/checkbox/__test__/checkboxGroup.test.js +37 -5
  15. package/checkbox/_story/checkbox.stories.js +78 -6
  16. package/checkbox/checkbox.tsx +3 -0
  17. package/checkbox/checkboxGroup.tsx +3 -2
  18. package/datePicker/__test__/datePicker.test.js +67 -2
  19. package/datePicker/_story/datePicker.stories.js +3 -1
  20. package/datePicker/_story/v2/YearButton.jsx +17 -0
  21. package/datePicker/_story/v2/index.js +1 -0
  22. package/datePicker/monthsGrid.tsx +12 -1
  23. package/datePicker/navigation.tsx +55 -29
  24. package/descriptions/__test__/descriptions.test.js +27 -1
  25. package/descriptions/_story/descriptions.stories.js +52 -2
  26. package/descriptions/item.tsx +1 -1
  27. package/dist/css/semi.css +105 -32
  28. package/dist/css/semi.min.css +1 -1
  29. package/dist/umd/semi-ui.js +801 -227
  30. package/dist/umd/semi-ui.js.map +1 -1
  31. package/dist/umd/semi-ui.min.js +1 -1
  32. package/dist/umd/semi-ui.min.js.map +1 -1
  33. package/form/_story/form.stories.js +0 -67
  34. package/form/_story/form.stories.tsx +2 -2
  35. package/form/hoc/withField.tsx +2 -2
  36. package/lib/cjs/_base/base.css +2 -2
  37. package/lib/cjs/_utils/index.d.ts +1 -0
  38. package/lib/cjs/_utils/index.js +3 -2
  39. package/lib/cjs/button/Button.d.ts +1 -0
  40. package/lib/cjs/button/buttonGroup.js +11 -3
  41. package/lib/cjs/cascader/index.d.ts +7 -0
  42. package/lib/cjs/cascader/index.js +35 -22
  43. package/lib/cjs/cascader/item.d.ts +2 -0
  44. package/lib/cjs/cascader/item.js +9 -2
  45. package/lib/cjs/checkbox/checkbox.js +4 -1
  46. package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -0
  47. package/lib/cjs/checkbox/checkboxGroup.js +3 -1
  48. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  49. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  50. package/lib/cjs/datePicker/monthsGrid.d.ts +2 -1
  51. package/lib/cjs/datePicker/monthsGrid.js +6 -0
  52. package/lib/cjs/datePicker/navigation.js +47 -7
  53. package/lib/cjs/descriptions/item.js +1 -1
  54. package/lib/cjs/form/baseForm.d.ts +6 -0
  55. package/lib/cjs/form/field.d.ts +6 -0
  56. package/lib/cjs/form/hoc/withField.js +3 -1
  57. package/lib/cjs/locale/source/es.d.ts +7 -0
  58. package/lib/cjs/locale/source/es.js +168 -0
  59. package/lib/cjs/modal/Modal.d.ts +8 -8
  60. package/lib/cjs/modal/Modal.js +4 -4
  61. package/lib/cjs/modal/confirm.d.ts +10 -10
  62. package/lib/cjs/navigation/index.d.ts +2 -2
  63. package/lib/cjs/pagination/index.js +9 -4
  64. package/lib/cjs/radio/radio.d.ts +1 -1
  65. package/lib/cjs/radio/radio.js +1 -0
  66. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  67. package/lib/cjs/rating/item.js +3 -2
  68. package/lib/cjs/select/index.d.ts +10 -0
  69. package/lib/cjs/select/index.js +15 -9
  70. package/lib/cjs/table/Table.d.ts +1 -1
  71. package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
  72. package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
  73. package/lib/cjs/timePicker/index.d.ts +2 -2
  74. package/lib/cjs/timeline/item.d.ts +5 -2
  75. package/lib/cjs/timeline/item.js +13 -7
  76. package/lib/cjs/tree/treeNode.js +0 -2
  77. package/lib/cjs/treeSelect/index.js +1 -0
  78. package/lib/cjs/typography/title.d.ts +1 -1
  79. package/lib/cjs/upload/fileCard.d.ts +2 -0
  80. package/lib/cjs/upload/fileCard.js +70 -45
  81. package/lib/cjs/upload/index.d.ts +34 -4
  82. package/lib/cjs/upload/index.js +141 -25
  83. package/lib/cjs/upload/interface.d.ts +3 -0
  84. package/lib/es/_base/base.css +2 -2
  85. package/lib/es/_utils/index.d.ts +1 -0
  86. package/lib/es/_utils/index.js +3 -2
  87. package/lib/es/button/Button.d.ts +1 -0
  88. package/lib/es/button/buttonGroup.js +3 -3
  89. package/lib/es/cascader/index.d.ts +7 -0
  90. package/lib/es/cascader/index.js +34 -25
  91. package/lib/es/cascader/item.d.ts +2 -0
  92. package/lib/es/cascader/item.js +9 -2
  93. package/lib/es/checkbox/checkbox.js +4 -1
  94. package/lib/es/checkbox/checkboxGroup.d.ts +1 -0
  95. package/lib/es/checkbox/checkboxGroup.js +3 -1
  96. package/lib/es/datePicker/dateInput.d.ts +1 -1
  97. package/lib/es/datePicker/datePicker.d.ts +1 -1
  98. package/lib/es/datePicker/monthsGrid.d.ts +2 -1
  99. package/lib/es/datePicker/monthsGrid.js +6 -0
  100. package/lib/es/datePicker/navigation.js +48 -8
  101. package/lib/es/descriptions/item.js +1 -1
  102. package/lib/es/form/baseForm.d.ts +6 -0
  103. package/lib/es/form/field.d.ts +6 -0
  104. package/lib/es/form/hoc/withField.js +3 -1
  105. package/lib/es/locale/source/es.d.ts +7 -0
  106. package/lib/es/locale/source/es.js +157 -0
  107. package/lib/es/modal/Modal.d.ts +8 -8
  108. package/lib/es/modal/Modal.js +4 -4
  109. package/lib/es/modal/confirm.d.ts +10 -10
  110. package/lib/es/navigation/index.d.ts +2 -2
  111. package/lib/es/pagination/index.js +8 -4
  112. package/lib/es/radio/radio.d.ts +1 -1
  113. package/lib/es/radio/radio.js +1 -0
  114. package/lib/es/radio/radioGroup.d.ts +1 -1
  115. package/lib/es/rating/item.js +3 -2
  116. package/lib/es/select/index.d.ts +10 -0
  117. package/lib/es/select/index.js +19 -9
  118. package/lib/es/table/Table.d.ts +1 -1
  119. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  120. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  121. package/lib/es/timePicker/index.d.ts +2 -2
  122. package/lib/es/timeline/item.d.ts +5 -2
  123. package/lib/es/timeline/item.js +12 -7
  124. package/lib/es/tree/treeNode.js +0 -2
  125. package/lib/es/treeSelect/index.js +1 -0
  126. package/lib/es/typography/title.d.ts +1 -1
  127. package/lib/es/upload/fileCard.d.ts +2 -0
  128. package/lib/es/upload/fileCard.js +69 -44
  129. package/lib/es/upload/index.d.ts +34 -4
  130. package/lib/es/upload/index.js +141 -24
  131. package/lib/es/upload/interface.d.ts +3 -0
  132. package/locale/source/es.ts +160 -0
  133. package/modal/Modal.tsx +6 -6
  134. package/navigation/__test__/navigation.test.js +4 -4
  135. package/navigation/_story/AutoOpen/index.js +1 -1
  136. package/navigation/_story/WithChildren/index.js +1 -1
  137. package/navigation/_story/navigation.stories.js +1 -1
  138. package/navigation/_story/navigation.stories.tsx +4 -4
  139. package/navigation/index.tsx +2 -2
  140. package/package.json +16 -8
  141. package/pagination/_story/pagination.stories.js +11 -0
  142. package/pagination/index.tsx +9 -4
  143. package/popover/Arrow.tsx +1 -1
  144. package/radio/__test__/radioGroup.test.jsx +41 -6
  145. package/radio/_story/radio.stories.js +22 -11
  146. package/radio/radio.tsx +1 -0
  147. package/rating/item.tsx +2 -1
  148. package/select/_story/select.stories.js +39 -14
  149. package/select/index.tsx +21 -7
  150. package/table/_story/DynamicFilters/index.js +13 -16
  151. package/timeline/__test__/timeline.test.js +17 -1
  152. package/timeline/_story/timeline.stories.js +70 -6
  153. package/timeline/item.tsx +11 -6
  154. package/tooltip/_story/tooltip.stories.js +1 -1
  155. package/tree/_story/tree.stories.js +2 -2
  156. package/tree/treeNode.tsx +0 -2
  157. package/treeSelect/index.tsx +3 -2
  158. package/tsconfig.json +2 -1
  159. package/upload/__test__/upload.test.js +50 -1
  160. package/upload/fileCard.tsx +110 -95
  161. package/upload/index.tsx +155 -54
  162. package/upload/interface.ts +3 -0
@@ -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,14 +124,17 @@ 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>;
128
134
  style: PropTypes.Requireable<object>;
129
135
  timeout: PropTypes.Requireable<number>;
130
136
  transformFile: PropTypes.Requireable<(...args: any[]) => any>;
131
- uploadTrigger: PropTypes.Requireable<"custom" | "auto">;
137
+ uploadTrigger: PropTypes.Requireable<"auto" | "custom">;
132
138
  validateMessage: PropTypes.Requireable<PropTypes.ReactNodeLike>;
133
139
  validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
134
140
  withCredentials: PropTypes.Requireable<boolean>;
@@ -136,7 +142,16 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
136
142
  static defaultProps: Partial<UploadProps>;
137
143
  static FileCard: typeof FileCard;
138
144
  constructor(props: UploadProps);
139
- static getDerivedStateFromProps(props: UploadProps): Partial<UploadState> | null;
145
+ /**
146
+ * Notes:
147
+ * The input parameter and return value here do not declare the type, otherwise tsc may report an error in form/fields.tsx when wrap after withField
148
+ * `The types of the parameters "props" and "nextProps" are incompatible.
149
+ The attribute "action" is missing in the type "Readonly<any>", but it is required in the type "UploadProps".`
150
+ * which seems to be a bug, remove props type declare here
151
+ */
152
+ static getDerivedStateFromProps(props: any): {
153
+ fileList: any;
154
+ };
140
155
  get adapter(): UploadAdapter<UploadProps, UploadState>;
141
156
  foundation: UploadFoundation;
142
157
  inputRef: RefObject<HTMLInputElement>;
@@ -148,13 +163,28 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
148
163
  onReplaceChange: (e: ChangeEvent<HTMLInputElement>) => void;
149
164
  clear: () => void;
150
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
+ */
151
178
  upload: () => void;
152
179
  renderFile: (file: FileItem, index: number, locale: Locale['Upload']) => ReactNode;
153
180
  renderFileList: () => ReactNode;
181
+ renderFileListPic: () => JSX.Element;
182
+ renderFileListDefault: () => JSX.Element;
154
183
  onDrop: (e: DragEvent<HTMLDivElement>) => void;
155
184
  onDragOver: (e: DragEvent<HTMLDivElement>) => void;
156
185
  onDragLeave: (e: DragEvent<HTMLDivElement>) => void;
157
186
  onDragEnter: (e: DragEvent<HTMLDivElement>) => void;
187
+ renderAddContent: () => React.ReactNode;
158
188
  renderDragArea: () => ReactNode;
159
189
  render(): ReactNode;
160
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
@@ -267,6 +377,14 @@ class Upload extends BaseComponent {
267
377
  this.inputRef = /*#__PURE__*/React.createRef();
268
378
  this.replaceInputRef = /*#__PURE__*/React.createRef();
269
379
  }
380
+ /**
381
+ * Notes:
382
+ * The input parameter and return value here do not declare the type, otherwise tsc may report an error in form/fields.tsx when wrap after withField
383
+ * `The types of the parameters "props" and "nextProps" are incompatible.
384
+ The attribute "action" is missing in the type "Readonly<any>", but it is required in the type "UploadProps".`
385
+ * which seems to be a bug, remove props type declare here
386
+ */
387
+
270
388
 
271
389
  static getDerivedStateFromProps(props) {
272
390
  const {
@@ -388,7 +506,6 @@ class Upload extends BaseComponent {
388
506
  ["".concat(prefixCls, "-warning")]: validateStatus === 'warning',
389
507
  ["".concat(prefixCls, "-success")]: validateStatus === 'success'
390
508
  }, className);
391
- const uploadAddCls = cls("".concat(prefixCls, "-add"));
392
509
  const inputCls = cls("".concat(prefixCls, "-hidden-input"));
393
510
  const inputReplaceCls = cls("".concat(prefixCls, "-hidden-input-replace"));
394
511
  const promptCls = cls("".concat(prefixCls, "-prompt"));
@@ -397,10 +514,6 @@ class Upload extends BaseComponent {
397
514
  directory: 'directory',
398
515
  webkitdirectory: 'webkitdirectory'
399
516
  } : {};
400
- const addContent = listType !== strings.FILE_LIST_PIC ? /*#__PURE__*/React.createElement("div", {
401
- className: uploadAddCls,
402
- onClick: this.onClick
403
- }, children) : null;
404
517
  return /*#__PURE__*/React.createElement("div", {
405
518
  className: uploadCls,
406
519
  style: style,
@@ -426,7 +539,7 @@ class Upload extends BaseComponent {
426
539
  tabIndex: -1,
427
540
  className: inputReplaceCls,
428
541
  ref: this.replaceInputRef
429
- }), draggable ? this.renderDragArea() : addContent, prompt ? /*#__PURE__*/React.createElement("div", {
542
+ }), this.renderAddContent(), prompt ? /*#__PURE__*/React.createElement("div", {
430
543
  className: promptCls
431
544
  }, prompt) : null, validateMessage ? /*#__PURE__*/React.createElement("div", {
432
545
  className: validateMsgCls
@@ -481,7 +594,10 @@ Upload.propTypes = {
481
594
  prompt: PropTypes.node,
482
595
  promptPosition: PropTypes.oneOf(strings.PROMPT_POSITION),
483
596
  renderFileItem: PropTypes.func,
597
+ renderPicInfo: PropTypes.func,
598
+ renderThumbnail: PropTypes.func,
484
599
  showClear: PropTypes.bool,
600
+ showPicInfo: PropTypes.bool,
485
601
  showReplace: PropTypes.bool,
486
602
  showRetry: PropTypes.bool,
487
603
  showUploadList: PropTypes.bool,
@@ -515,6 +631,7 @@ Upload.defaultProps = {
515
631
  onSuccess: _noop,
516
632
  promptPosition: 'right',
517
633
  showClear: true,
634
+ showPicInfo: false,
518
635
  showReplace: false,
519
636
  showRetry: true,
520
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;
package/modal/Modal.tsx CHANGED
@@ -11,9 +11,9 @@ import PropTypes from 'prop-types';
11
11
  import { noop } from 'lodash';
12
12
  import '@douyinfe/semi-foundation/modal/modal.scss';
13
13
  import BaseComponent from '../_base/baseComponent';
14
- import confirm, { withConfirm, withError, withInfo, withSuccess, withWarning } from '../modal/confirm';
14
+ import confirm, { withConfirm, withError, withInfo, withSuccess, withWarning } from './confirm';
15
15
  import { Locale } from '../locale/interface';
16
- import useModal from '../modal/useModal';
16
+ import useModal from './useModal';
17
17
  import { ButtonProps } from '../button/Button';
18
18
 
19
19
  export const destroyFns: any[] = [];
@@ -47,8 +47,8 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
47
47
  closable: PropTypes.bool,
48
48
  centered: PropTypes.bool,
49
49
  visible: PropTypes.bool,
50
- width: PropTypes.number,
51
- height: PropTypes.number,
50
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
51
+ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
52
52
  confirmLoading: PropTypes.bool,
53
53
  cancelLoading: PropTypes.bool,
54
54
  okText: PropTypes.string,
@@ -264,9 +264,9 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
264
264
  if (!visible && !hidden) {
265
265
  this.foundation.toggleHidden(true, () => this.foundation.afterClose());
266
266
  } else if (visible && this.state.hidden) {
267
- this.foundation.toggleHidden(false)
267
+ this.foundation.toggleHidden(false);
268
268
  }
269
- }
269
+ };
270
270
 
271
271
  renderFooter = (): ReactNode => {
272
272
  const {
@@ -36,7 +36,7 @@ describe(`Navigation`, () => {
36
36
  onSelect={key => console.log(key)}
37
37
  header={{
38
38
  logo: <img src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwzthlaukjlkulzlp/root-web-sites/webcast_logo.svg" />,
39
- text: '直播运营后台',
39
+ text: 'Semi 运营后台',
40
40
  }}
41
41
  footer={{
42
42
  collapseButton: true,
@@ -71,7 +71,7 @@ describe(`Navigation`, () => {
71
71
  onSelect={data => console.log('trigger onSelect: ', data)}
72
72
  onClick={data => console.log('trigger onClick: ', data)}
73
73
  >
74
- <Nav.Header logo={'bytedance_logo'} text={'直播运营后台'} />
74
+ <Nav.Header logo={'bytedance_logo'} text={'Semi 运营后台'} />
75
75
  <Nav.Item itemKey={'union'} text={'公会中心'} icon={'star'} />
76
76
  <Nav.Sub itemKey={'user'} text="用户管理" icon="user">
77
77
  <Nav.Item itemKey={'golder'} text={'金主管理'} />
@@ -135,7 +135,7 @@ describe(`Navigation`, () => {
135
135
  items={items}
136
136
  header={{
137
137
  logo: 'bytedance_logo',
138
- text: '直播运营后台',
138
+ text: 'Semi 运营后台',
139
139
  }}
140
140
  footer={{ collapseButton: true }}
141
141
  />
@@ -201,7 +201,7 @@ describe(`Navigation`, () => {
201
201
  onClick={onClick}
202
202
  header={{
203
203
  logo: <img src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwzthlaukjlkulzlp/root-web-sites/webcast_logo.svg" />,
204
- text: '直播运营后台',
204
+ text: 'Semi 运营后台',
205
205
  }}
206
206
  footer={{
207
207
  collapseButton: true,
@@ -55,7 +55,7 @@ const Demo = (props = {}) => {
55
55
  onSelect={key => console.log(key)}
56
56
  header={{
57
57
  logo: <img src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/webcast_logo.svg" />,
58
- text: '直播运营后台',
58
+ text: 'Semi运营后台',
59
59
  }}
60
60
  footer={{
61
61
  collapseButton: true,
@@ -106,7 +106,7 @@ const Demo = (props = {}) => {
106
106
  onOpenChange={onOpenChange}
107
107
  header={{
108
108
  logo: <img src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/webcast_logo.svg" />,
109
- text: '直播运营后台',
109
+ text: 'Semi 运营后台',
110
110
  }}
111
111
  footer={{
112
112
  collapseButton: true,
@@ -272,7 +272,7 @@ class HorizontalDemo extends React.Component {
272
272
  logo: (
273
273
  <img src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/webcast_logo.svg" />
274
274
  ),
275
- text: '直播运营后台',
275
+ text: 'Semi 运营后台',
276
276
  }}
277
277
  footer={{
278
278
  collapseButton: true,