@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
@@ -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
- key: (0, _concat.default)(_context = "".concat(name)).call(_context, index),
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 isPicType = listType === _constants.strings.FILE_LIST_PIC;
180
- const showAddTriggerInList = isPicType && (limit ? limit > fileList.length : true);
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")]: isPicType,
224
+ ["".concat(prefixCls, "-picture-add")]: true,
183
225
  ["".concat(prefixCls, "-picture-add-disabled")]: disabled
184
226
  });
185
-
186
- const addContent = /*#__PURE__*/_react.default.createElement("div", {
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
- }, children);
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
- const fileListCls = (0, _classnames.default)("".concat(prefixCls, "-file-list"), {
200
- ["".concat(prefixCls, "-picture-file-list")]: isPicType
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 && listType !== _constants.strings.FILE_LIST_PIC;
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)), showAddTriggerInList ? addContent : null)));
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
@@ -293,6 +402,14 @@ class Upload extends _baseComponent.default {
293
402
  this.inputRef = /*#__PURE__*/_react.default.createRef();
294
403
  this.replaceInputRef = /*#__PURE__*/_react.default.createRef();
295
404
  }
405
+ /**
406
+ * Notes:
407
+ * 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
408
+ * `The types of the parameters "props" and "nextProps" are incompatible.
409
+ The attribute "action" is missing in the type "Readonly<any>", but it is required in the type "UploadProps".`
410
+ * which seems to be a bug, remove props type declare here
411
+ */
412
+
296
413
 
297
414
  static getDerivedStateFromProps(props) {
298
415
  const {
@@ -414,7 +531,6 @@ class Upload extends _baseComponent.default {
414
531
  ["".concat(prefixCls, "-warning")]: validateStatus === 'warning',
415
532
  ["".concat(prefixCls, "-success")]: validateStatus === 'success'
416
533
  }, className);
417
- const uploadAddCls = (0, _classnames.default)("".concat(prefixCls, "-add"));
418
534
  const inputCls = (0, _classnames.default)("".concat(prefixCls, "-hidden-input"));
419
535
  const inputReplaceCls = (0, _classnames.default)("".concat(prefixCls, "-hidden-input-replace"));
420
536
  const promptCls = (0, _classnames.default)("".concat(prefixCls, "-prompt"));
@@ -423,10 +539,6 @@ class Upload extends _baseComponent.default {
423
539
  directory: 'directory',
424
540
  webkitdirectory: 'webkitdirectory'
425
541
  } : {};
426
- const addContent = listType !== _constants.strings.FILE_LIST_PIC ? /*#__PURE__*/_react.default.createElement("div", {
427
- className: uploadAddCls,
428
- onClick: this.onClick
429
- }, children) : null;
430
542
  return /*#__PURE__*/_react.default.createElement("div", {
431
543
  className: uploadCls,
432
544
  style: style,
@@ -452,7 +564,7 @@ class Upload extends _baseComponent.default {
452
564
  tabIndex: -1,
453
565
  className: inputReplaceCls,
454
566
  ref: this.replaceInputRef
455
- }), draggable ? this.renderDragArea() : addContent, prompt ? /*#__PURE__*/_react.default.createElement("div", {
567
+ }), this.renderAddContent(), prompt ? /*#__PURE__*/_react.default.createElement("div", {
456
568
  className: promptCls
457
569
  }, prompt) : null, validateMessage ? /*#__PURE__*/_react.default.createElement("div", {
458
570
  className: validateMsgCls
@@ -507,7 +619,10 @@ Upload.propTypes = {
507
619
  prompt: _propTypes.default.node,
508
620
  promptPosition: _propTypes.default.oneOf(_constants.strings.PROMPT_POSITION),
509
621
  renderFileItem: _propTypes.default.func,
622
+ renderPicInfo: _propTypes.default.func,
623
+ renderThumbnail: _propTypes.default.func,
510
624
  showClear: _propTypes.default.bool,
625
+ showPicInfo: _propTypes.default.bool,
511
626
  showReplace: _propTypes.default.bool,
512
627
  showRetry: _propTypes.default.bool,
513
628
  showUploadList: _propTypes.default.bool,
@@ -541,6 +656,7 @@ Upload.defaultProps = {
541
656
  onSuccess: _noop2.default,
542
657
  promptPosition: 'right',
543
658
  showClear: true,
659
+ showPicInfo: false,
544
660
  showReplace: false,
545
661
  showRetry: true,
546
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;
@@ -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);
@@ -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;
@@ -102,7 +102,7 @@ export const getHighLightTextHTML = _ref => {
102
102
  const markEle = option.highlightTag || 'mark';
103
103
  const highlightClassName = option.highlightClassName || '';
104
104
  const highlightStyle = option.highlightStyle || {};
105
- return _mapInstanceProperty(chunks).call(chunks, chunk => {
105
+ return _mapInstanceProperty(chunks).call(chunks, (chunk, index) => {
106
106
  const {
107
107
  end,
108
108
  start,
@@ -113,7 +113,8 @@ export const getHighLightTextHTML = _ref => {
113
113
  if (highlight) {
114
114
  return /*#__PURE__*/React.createElement(markEle, {
115
115
  style: highlightStyle,
116
- className: highlightClassName
116
+ className: highlightClassName,
117
+ key: text + index
117
118
  }, text);
118
119
  } else {
119
120
  return text;
@@ -7,6 +7,7 @@ export declare type Size = 'default' | 'small' | 'large';
7
7
  export declare type Theme = 'solid' | 'borderless' | 'light';
8
8
  export declare type Type = 'primary' | 'secondary' | 'tertiary' | 'warning' | 'danger';
9
9
  export interface ButtonProps {
10
+ id?: string;
10
11
  block?: boolean;
11
12
  circle?: boolean;
12
13
  disabled?: boolean;
@@ -15,7 +15,7 @@ var __rest = this && this.__rest || function (s, e) {
15
15
  return t;
16
16
  };
17
17
 
18
- import React from 'react';
18
+ import React, { isValidElement, cloneElement } from 'react';
19
19
  import BaseComponent from '../_base/baseComponent';
20
20
  import PropTypes from 'prop-types';
21
21
  import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/button/constants';
@@ -38,13 +38,13 @@ export default class ButtonGroup extends BaseComponent {
38
38
  if (children) {
39
39
  var _context;
40
40
 
41
- inner = _mapInstanceProperty(_context = _Array$isArray(children) ? children : [children]).call(_context, (itm, index) => /*#__PURE__*/React.cloneElement(itm, _Object$assign(_Object$assign(_Object$assign({
41
+ inner = _mapInstanceProperty(_context = _Array$isArray(children) ? children : [children]).call(_context, (itm, index) => /*#__PURE__*/isValidElement(itm) ? /*#__PURE__*/cloneElement(itm, _Object$assign(_Object$assign(_Object$assign({
42
42
  disabled,
43
43
  size,
44
44
  type
45
45
  }, itm.props), rest), {
46
46
  key: index
47
- })));
47
+ })) : itm);
48
48
  }
49
49
 
50
50
  return /*#__PURE__*/React.createElement("div", {
@@ -105,14 +105,18 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
105
105
  showRestTagsPopover: PropTypes.Requireable<boolean>;
106
106
  restTagsPopoverProps: PropTypes.Requireable<object>;
107
107
  max: PropTypes.Requireable<number>;
108
+ separator: PropTypes.Requireable<string>;
108
109
  onExceed: PropTypes.Requireable<(...args: any[]) => any>;
109
110
  onClear: PropTypes.Requireable<(...args: any[]) => any>;
110
111
  loadData: PropTypes.Requireable<(...args: any[]) => any>;
111
112
  onLoad: PropTypes.Requireable<(...args: any[]) => any>;
112
113
  loadedKeys: PropTypes.Requireable<any[]>;
113
114
  disableStrictly: PropTypes.Requireable<boolean>;
115
+ leafOnly: PropTypes.Requireable<boolean>;
116
+ enableLeafClick: PropTypes.Requireable<boolean>;
114
117
  };
115
118
  static defaultProps: {
119
+ leafOnly: boolean;
116
120
  arrowIcon: JSX.Element;
117
121
  stopPropagation: boolean;
118
122
  motion: boolean;
@@ -129,6 +133,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
129
133
  filterLeafOnly: boolean;
130
134
  showRestTagsPopover: boolean;
131
135
  restTagsPopoverProps: {};
136
+ separator: string;
132
137
  size: "default";
133
138
  treeNodeFilterProp: "label";
134
139
  displayProp: "label";
@@ -138,6 +143,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
138
143
  onClear: (...args: any[]) => void;
139
144
  onDropdownVisibleChange: (...args: any[]) => void;
140
145
  onListScroll: (...args: any[]) => void;
146
+ enableLeafClick: boolean;
141
147
  };
142
148
  options: any;
143
149
  isEmpty: boolean;
@@ -145,6 +151,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
145
151
  triggerRef: React.RefObject<HTMLDivElement>;
146
152
  optionsRef: React.RefObject<any>;
147
153
  clickOutsideHandler: any;
154
+ mergeType: string;
148
155
  constructor(props: CascaderProps);
149
156
  get adapter(): CascaderAdapter;
150
157
  static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState): Partial<CascaderState>;
@@ -1,3 +1,4 @@
1
+ import _flatten from "lodash/flatten";
1
2
  import _noop from "lodash/noop";
2
3
  import _isNumber from "lodash/isNumber";
3
4
  import _isFunction from "lodash/isFunction";
@@ -20,7 +21,7 @@ import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/cascader/c
20
21
  import { numbers as popoverNumbers } from '@douyinfe/semi-foundation/lib/es/popover/constants';
21
22
  import '@douyinfe/semi-foundation/lib/es/cascader/cascader.css';
22
23
  import { IconClear, IconChevronDown } from '@douyinfe/semi-icons';
23
- import { findKeysForValues, convertDataToEntities } from '@douyinfe/semi-foundation/lib/es/cascader/util';
24
+ import { findKeysForValues, convertDataToEntities, calcMergeType } from '@douyinfe/semi-foundation/lib/es/cascader/util';
24
25
  import { calcCheckedKeys, normalizeKeyList, calcDisabledKeys } from '@douyinfe/semi-foundation/lib/es/tree/treeUtil';
25
26
  import ConfigContext from '../configProvider/context';
26
27
  import BaseComponent from '../_base/baseComponent';
@@ -122,6 +123,7 @@ class Cascader extends BaseComponent {
122
123
  dropdownStyle,
123
124
  loadData,
124
125
  emptyContent,
126
+ separator,
125
127
  topSlot,
126
128
  bottomSlot,
127
129
  showNext,
@@ -137,6 +139,7 @@ class Cascader extends BaseComponent {
137
139
  }, topSlot, /*#__PURE__*/React.createElement(Item, {
138
140
  activeKeys: activeKeys,
139
141
  selectedKeys: selectedKeys,
142
+ separator: separator,
140
143
  loadedKeys: loadedKeys,
141
144
  loadingKeys: loadingKeys,
142
145
  onItemClick: this.handleItemClick,
@@ -186,9 +189,9 @@ class Cascader extends BaseComponent {
186
189
  } = this.props;
187
190
  const {
188
191
  checkedKeys,
189
- mergedCheckedKeys
192
+ resolvedCheckedKeys
190
193
  } = this.state;
191
- const realKeys = autoMergeValue ? mergedCheckedKeys : checkedKeys;
194
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
192
195
  const displayTag = [];
193
196
  const hiddenTag = [];
194
197
 
@@ -278,20 +281,23 @@ class Cascader extends BaseComponent {
278
281
  const {
279
282
  disabled,
280
283
  triggerRender,
281
- multiple,
282
- autoMergeValue
284
+ multiple
283
285
  } = this.props;
284
286
  const {
285
287
  selectedKeys,
286
288
  inputValue,
287
289
  inputPlaceHolder,
288
- mergedCheckedKeys,
290
+ resolvedCheckedKeys,
289
291
  checkedKeys
290
292
  } = this.state;
291
293
  let realValue;
292
294
 
293
295
  if (multiple) {
294
- realValue = autoMergeValue ? mergedCheckedKeys : checkedKeys;
296
+ if (this.mergeType === strings.NONE_MERGE_TYPE) {
297
+ realValue = checkedKeys;
298
+ } else {
299
+ realValue = resolvedCheckedKeys;
300
+ }
295
301
  } else {
296
302
  realValue = [...selectedKeys][0];
297
303
  }
@@ -471,8 +477,8 @@ class Cascader extends BaseComponent {
471
477
  /* Key of half checked node, when multiple */
472
478
  halfCheckedKeys: new _Set([]),
473
479
 
474
- /* Auto merged checkedKeys, when multiple */
475
- mergedCheckedKeys: new _Set([]),
480
+ /* Auto merged checkedKeys or leaf checkedKeys, when multiple */
481
+ resolvedCheckedKeys: new _Set([]),
476
482
 
477
483
  /* Keys of loaded item */
478
484
  loadedKeys: new _Set(),
@@ -485,6 +491,7 @@ class Cascader extends BaseComponent {
485
491
  };
486
492
  this.options = {};
487
493
  this.isEmpty = false;
494
+ this.mergeType = calcMergeType(props.autoMergeValue, props.leafOnly);
488
495
  this.inputRef = /*#__PURE__*/React.createRef();
489
496
  this.triggerRef = /*#__PURE__*/React.createRef();
490
497
  this.optionsRef = /*#__PURE__*/React.createRef();
@@ -627,7 +634,9 @@ class Cascader extends BaseComponent {
627
634
  multiple,
628
635
  value,
629
636
  defaultValue,
630
- onChangeWithObject
637
+ onChangeWithObject,
638
+ leafOnly,
639
+ autoMergeValue
631
640
  } = props;
632
641
  const {
633
642
  prevProps
@@ -692,24 +701,19 @@ class Cascader extends BaseComponent {
692
701
  realKeys = formatKeys;
693
702
  }
694
703
 
695
- let checkedKeys = new _Set([]);
696
- let halfCheckedKeys = new _Set([]);
697
-
698
- _forEachInstanceProperty(realKeys).call(realKeys, v => {
699
- const calRes = calcCheckedKeys(v, keyEntities);
700
- checkedKeys = new _Set([...checkedKeys, ...calRes.checkedKeys]);
701
- halfCheckedKeys = new _Set([...halfCheckedKeys, ...calRes.halfCheckedKeys]);
702
- }); // disableStrictly
703
-
704
+ const calRes = calcCheckedKeys(_flatten(realKeys), keyEntities);
705
+ const checkedKeys = new _Set(calRes.checkedKeys);
706
+ const halfCheckedKeys = new _Set(calRes.halfCheckedKeys); // disableStrictly
704
707
 
705
708
  if (props.disableStrictly) {
706
709
  newState.disabledKeys = calcDisabledKeys(keyEntities);
707
710
  }
708
711
 
712
+ const isLeafOnlyMerge = calcMergeType(autoMergeValue, leafOnly) === strings.LEAF_ONLY_MERGE_TYPE;
709
713
  newState.prevProps = props;
710
714
  newState.checkedKeys = checkedKeys;
711
715
  newState.halfCheckedKeys = halfCheckedKeys;
712
- newState.mergedCheckedKeys = new _Set(normalizeKeyList(checkedKeys, keyEntities));
716
+ newState.resolvedCheckedKeys = new _Set(normalizeKeyList(checkedKeys, keyEntities, isLeafOnlyMerge));
713
717
  }
714
718
  }
715
719
 
@@ -743,7 +747,6 @@ class Cascader extends BaseComponent {
743
747
  const {
744
748
  size,
745
749
  disabled,
746
- autoMergeValue,
747
750
  placeholder,
748
751
  maxTagCount,
749
752
  showRestTagsPopover,
@@ -753,11 +756,11 @@ class Cascader extends BaseComponent {
753
756
  inputValue,
754
757
  checkedKeys,
755
758
  keyEntities,
756
- mergedCheckedKeys
759
+ resolvedCheckedKeys
757
760
  } = this.state;
758
761
  const tagInputcls = cls("".concat(prefixcls, "-tagInput-wrapper"));
759
762
  const tagValue = [];
760
- const realKeys = autoMergeValue ? mergedCheckedKeys : checkedKeys;
763
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
761
764
 
762
765
  _forEachInstanceProperty(_context3 = [...realKeys]).call(_context3, checkedKey => {
763
766
  if (!_isEmpty(keyEntities[checkedKey])) {
@@ -907,14 +910,18 @@ Cascader.propTypes = {
907
910
  showRestTagsPopover: PropTypes.bool,
908
911
  restTagsPopoverProps: PropTypes.object,
909
912
  max: PropTypes.number,
913
+ separator: PropTypes.string,
910
914
  onExceed: PropTypes.func,
911
915
  onClear: PropTypes.func,
912
916
  loadData: PropTypes.func,
913
917
  onLoad: PropTypes.func,
914
918
  loadedKeys: PropTypes.array,
915
- disableStrictly: PropTypes.bool
919
+ disableStrictly: PropTypes.bool,
920
+ leafOnly: PropTypes.bool,
921
+ enableLeafClick: PropTypes.bool
916
922
  };
917
923
  Cascader.defaultProps = {
924
+ leafOnly: false,
918
925
  arrowIcon: /*#__PURE__*/React.createElement(IconChevronDown, null),
919
926
  stopPropagation: true,
920
927
  motion: true,
@@ -931,6 +938,7 @@ Cascader.defaultProps = {
931
938
  filterLeafOnly: true,
932
939
  showRestTagsPopover: false,
933
940
  restTagsPopoverProps: {},
941
+ separator: ' / ',
934
942
  size: 'default',
935
943
  treeNodeFilterProp: 'label',
936
944
  displayProp: 'label',
@@ -939,6 +947,7 @@ Cascader.defaultProps = {
939
947
  onExceed: _noop,
940
948
  onClear: _noop,
941
949
  onDropdownVisibleChange: _noop,
942
- onListScroll: _noop
950
+ onListScroll: _noop,
951
+ enableLeafClick: false
943
952
  };
944
953
  export default Cascader;
@@ -33,6 +33,7 @@ export interface CascaderItemProps {
33
33
  emptyContent: React.ReactNode;
34
34
  loadData: (selectOptions: CascaderData[]) => Promise<void>;
35
35
  data: Array<Data | Entity>;
36
+ separator: string;
36
37
  multiple: boolean;
37
38
  checkedKeys: Set<string>;
38
39
  halfCheckedKeys: Set<string>;
@@ -50,6 +51,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
50
51
  checkedKeys: PropTypes.Requireable<object>;
51
52
  halfCheckedKeys: PropTypes.Requireable<object>;
52
53
  onItemCheckboxClick: PropTypes.Requireable<(...args: any[]) => any>;
54
+ separator: PropTypes.Requireable<string>;
53
55
  keyword: PropTypes.Requireable<string>;
54
56
  };
55
57
  static defaultProps: {
@@ -49,6 +49,11 @@ export default class Item extends PureComponent {
49
49
  } = this.props; // Prevent Checkbox's click event bubbling to trigger the li click event
50
50
 
51
51
  e.stopPropagation();
52
+
53
+ if (e.nativeEvent && typeof e.nativeEvent.stopImmediatePropagation === 'function') {
54
+ e.nativeEvent.stopImmediatePropagation();
55
+ }
56
+
52
57
  onItemCheckboxClick(item);
53
58
  };
54
59
 
@@ -112,7 +117,8 @@ export default class Item extends PureComponent {
112
117
  this.highlight = searchText => {
113
118
  const content = [];
114
119
  const {
115
- keyword
120
+ keyword,
121
+ separator
116
122
  } = this.props;
117
123
 
118
124
  _forEachInstanceProperty(searchText).call(searchText, (item, idx) => {
@@ -136,7 +142,7 @@ export default class Item extends PureComponent {
136
142
  }
137
143
 
138
144
  if (idx !== searchText.length - 1) {
139
- content.push(' / ');
145
+ content.push(separator);
140
146
  }
141
147
  });
142
148
 
@@ -308,6 +314,7 @@ Item.propTypes = {
308
314
  checkedKeys: PropTypes.object,
309
315
  halfCheckedKeys: PropTypes.object,
310
316
  onItemCheckboxClick: PropTypes.func,
317
+ separator: PropTypes.string,
311
318
  keyword: PropTypes.string
312
319
  };
313
320
  Item.defaultProps = {