@douyinfe/semi-ui 2.12.1-alpha.1 → 2.13.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 (221) hide show
  1. package/autoComplete/_story/autoComplete.stories.js +0 -1
  2. package/autoComplete/index.tsx +1 -1
  3. package/avatar/index.tsx +2 -2
  4. package/backtop/index.tsx +7 -11
  5. package/badge/index.tsx +1 -1
  6. package/banner/index.tsx +5 -5
  7. package/breadcrumb/index.tsx +3 -5
  8. package/button/Button.tsx +8 -10
  9. package/card/index.tsx +41 -43
  10. package/carousel/CarouselArrow.tsx +0 -2
  11. package/carousel/index.tsx +0 -1
  12. package/cascader/index.tsx +126 -102
  13. package/cascader/item.tsx +1 -1
  14. package/checkbox/checkbox.tsx +28 -20
  15. package/checkbox/checkboxInner.tsx +11 -1
  16. package/collapsible/index.tsx +1 -8
  17. package/datePicker/dateInput.tsx +0 -1
  18. package/datePicker/datePicker.tsx +5 -13
  19. package/dist/css/semi.css +31 -1
  20. package/dist/css/semi.min.css +1 -1
  21. package/dist/umd/semi-ui.js +5321 -3696
  22. package/dist/umd/semi-ui.js.map +1 -1
  23. package/dist/umd/semi-ui.min.js +1 -1
  24. package/dist/umd/semi-ui.min.js.map +1 -1
  25. package/divider/index.tsx +4 -8
  26. package/dropdown/index.tsx +1 -1
  27. package/empty/index.tsx +5 -13
  28. package/form/hoc/withField.tsx +1 -1
  29. package/form/label.tsx +1 -1
  30. package/grid/col.tsx +1 -1
  31. package/grid/row.tsx +1 -1
  32. package/gulpfile.js +5 -5
  33. package/iconButton/index.tsx +1 -2
  34. package/input/index.tsx +11 -38
  35. package/inputNumber/__test__/inputNumber.test.js +2 -3
  36. package/inputNumber/_story/inputNumber.stories.js +53 -0
  37. package/inputNumber/index.tsx +0 -4
  38. package/lib/cjs/_base/base.css +22 -0
  39. package/lib/cjs/autoComplete/index.js +1 -1
  40. package/lib/cjs/avatar/index.js +2 -4
  41. package/lib/cjs/backtop/index.js +1 -2
  42. package/lib/cjs/badge/index.js +1 -2
  43. package/lib/cjs/banner/index.js +4 -9
  44. package/lib/cjs/breadcrumb/index.js +3 -4
  45. package/lib/cjs/button/Button.js +3 -13
  46. package/lib/cjs/card/index.js +5 -10
  47. package/lib/cjs/carousel/CarouselArrow.js +2 -6
  48. package/lib/cjs/carousel/CarouselIndicator.d.ts +1 -1
  49. package/lib/cjs/carousel/index.d.ts +1 -1
  50. package/lib/cjs/carousel/index.js +1 -2
  51. package/lib/cjs/cascader/index.js +10 -11
  52. package/lib/cjs/cascader/item.js +1 -2
  53. package/lib/cjs/checkbox/checkbox.d.ts +3 -2
  54. package/lib/cjs/checkbox/checkbox.js +33 -15
  55. package/lib/cjs/checkbox/checkboxInner.d.ts +6 -0
  56. package/lib/cjs/checkbox/checkboxInner.js +14 -4
  57. package/lib/cjs/collapsible/index.js +1 -2
  58. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  59. package/lib/cjs/datePicker/dateInput.js +1 -2
  60. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  61. package/lib/cjs/datePicker/datePicker.js +2 -4
  62. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  63. package/lib/cjs/divider/index.js +1 -2
  64. package/lib/cjs/dropdown/index.js +1 -2
  65. package/lib/cjs/empty/index.js +4 -8
  66. package/lib/cjs/form/baseForm.d.ts +1 -1
  67. package/lib/cjs/form/field.d.ts +1 -1
  68. package/lib/cjs/form/hoc/withField.js +1 -2
  69. package/lib/cjs/form/label.js +1 -2
  70. package/lib/cjs/grid/col.js +1 -2
  71. package/lib/cjs/grid/row.js +1 -2
  72. package/lib/cjs/iconButton/index.js +1 -3
  73. package/lib/cjs/input/index.js +5 -9
  74. package/lib/cjs/inputNumber/index.js +0 -4
  75. package/lib/cjs/list/index.js +3 -6
  76. package/lib/cjs/modal/ConfirmModal.js +1 -2
  77. package/lib/cjs/modal/Modal.js +2 -6
  78. package/lib/cjs/modal/ModalContent.js +6 -13
  79. package/lib/cjs/notification/notice.js +3 -6
  80. package/lib/cjs/pagination/index.js +2 -4
  81. package/lib/cjs/popconfirm/index.js +3 -6
  82. package/lib/cjs/popover/index.d.ts +1 -0
  83. package/lib/cjs/radio/radio.d.ts +1 -1
  84. package/lib/cjs/radio/radio.js +2 -4
  85. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  86. package/lib/cjs/rating/item.js +1 -2
  87. package/lib/cjs/scrollList/index.js +3 -6
  88. package/lib/cjs/select/index.js +4 -8
  89. package/lib/cjs/select/option.js +1 -2
  90. package/lib/cjs/sideSheet/SideSheetContent.js +3 -6
  91. package/lib/cjs/skeleton/index.js +1 -3
  92. package/lib/cjs/space/index.js +1 -2
  93. package/lib/cjs/spin/index.js +3 -7
  94. package/lib/cjs/switch/index.js +4 -6
  95. package/lib/cjs/table/Table.js +3 -6
  96. package/lib/cjs/tabs/TabBar.js +1 -2
  97. package/lib/cjs/tabs/TabPane.js +2 -5
  98. package/lib/cjs/tagInput/index.d.ts +6 -1
  99. package/lib/cjs/tagInput/index.js +50 -17
  100. package/lib/cjs/timePicker/Combobox.js +1 -3
  101. package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
  102. package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
  103. package/lib/cjs/timePicker/index.d.ts +2 -2
  104. package/lib/cjs/toast/toast.js +3 -6
  105. package/lib/cjs/transfer/index.js +1 -2
  106. package/lib/cjs/tree/treeNode.js +1 -2
  107. package/lib/cjs/treeSelect/index.js +3 -6
  108. package/lib/cjs/typography/base.js +1 -2
  109. package/lib/cjs/typography/title.d.ts +1 -1
  110. package/lib/cjs/upload/index.d.ts +2 -2
  111. package/lib/cjs/upload/index.js +6 -13
  112. package/lib/es/_base/base.css +22 -0
  113. package/lib/es/autoComplete/index.js +1 -1
  114. package/lib/es/avatar/index.js +2 -4
  115. package/lib/es/backtop/index.js +1 -2
  116. package/lib/es/badge/index.js +1 -2
  117. package/lib/es/banner/index.js +4 -9
  118. package/lib/es/breadcrumb/index.js +3 -4
  119. package/lib/es/button/Button.js +3 -11
  120. package/lib/es/card/index.js +5 -10
  121. package/lib/es/carousel/CarouselArrow.js +2 -6
  122. package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
  123. package/lib/es/carousel/index.d.ts +1 -1
  124. package/lib/es/carousel/index.js +1 -2
  125. package/lib/es/cascader/index.js +10 -11
  126. package/lib/es/cascader/item.js +1 -2
  127. package/lib/es/checkbox/checkbox.d.ts +3 -2
  128. package/lib/es/checkbox/checkbox.js +33 -15
  129. package/lib/es/checkbox/checkboxInner.d.ts +6 -0
  130. package/lib/es/checkbox/checkboxInner.js +14 -4
  131. package/lib/es/collapsible/index.js +1 -2
  132. package/lib/es/datePicker/dateInput.d.ts +1 -1
  133. package/lib/es/datePicker/dateInput.js +1 -2
  134. package/lib/es/datePicker/datePicker.d.ts +1 -1
  135. package/lib/es/datePicker/datePicker.js +2 -4
  136. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  137. package/lib/es/divider/index.js +1 -2
  138. package/lib/es/dropdown/index.js +1 -2
  139. package/lib/es/empty/index.js +4 -8
  140. package/lib/es/form/baseForm.d.ts +1 -1
  141. package/lib/es/form/field.d.ts +1 -1
  142. package/lib/es/form/hoc/withField.js +1 -2
  143. package/lib/es/form/label.js +1 -2
  144. package/lib/es/grid/col.js +1 -2
  145. package/lib/es/grid/row.js +1 -2
  146. package/lib/es/iconButton/index.js +1 -3
  147. package/lib/es/input/index.js +5 -9
  148. package/lib/es/inputNumber/index.js +0 -4
  149. package/lib/es/list/index.js +3 -6
  150. package/lib/es/modal/ConfirmModal.js +1 -2
  151. package/lib/es/modal/Modal.js +2 -6
  152. package/lib/es/modal/ModalContent.js +6 -13
  153. package/lib/es/notification/notice.js +3 -6
  154. package/lib/es/pagination/index.js +2 -4
  155. package/lib/es/popconfirm/index.js +3 -6
  156. package/lib/es/popover/index.d.ts +1 -0
  157. package/lib/es/radio/radio.d.ts +1 -1
  158. package/lib/es/radio/radio.js +2 -4
  159. package/lib/es/radio/radioGroup.d.ts +1 -1
  160. package/lib/es/rating/item.js +1 -2
  161. package/lib/es/scrollList/index.js +3 -6
  162. package/lib/es/select/index.js +4 -8
  163. package/lib/es/select/option.js +1 -2
  164. package/lib/es/sideSheet/SideSheetContent.js +3 -6
  165. package/lib/es/skeleton/index.js +1 -3
  166. package/lib/es/space/index.js +1 -2
  167. package/lib/es/spin/index.js +3 -7
  168. package/lib/es/switch/index.js +4 -6
  169. package/lib/es/table/Table.js +3 -6
  170. package/lib/es/tabs/TabBar.js +1 -2
  171. package/lib/es/tabs/TabPane.js +2 -5
  172. package/lib/es/tagInput/index.d.ts +6 -1
  173. package/lib/es/tagInput/index.js +47 -17
  174. package/lib/es/timePicker/Combobox.js +1 -3
  175. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  176. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  177. package/lib/es/timePicker/index.d.ts +2 -2
  178. package/lib/es/toast/toast.js +3 -6
  179. package/lib/es/transfer/index.js +1 -2
  180. package/lib/es/tree/treeNode.js +1 -2
  181. package/lib/es/treeSelect/index.js +3 -6
  182. package/lib/es/typography/base.js +1 -2
  183. package/lib/es/typography/title.d.ts +1 -1
  184. package/lib/es/upload/index.d.ts +2 -2
  185. package/lib/es/upload/index.js +6 -13
  186. package/list/index.tsx +4 -16
  187. package/modal/ConfirmModal.tsx +1 -1
  188. package/modal/Modal.tsx +0 -2
  189. package/modal/ModalContent.tsx +14 -27
  190. package/notification/notice.tsx +4 -16
  191. package/package.json +9 -9
  192. package/pagination/index.tsx +2 -16
  193. package/popconfirm/index.tsx +3 -11
  194. package/popover/index.tsx +1 -1
  195. package/radio/radio.tsx +2 -10
  196. package/rating/item.tsx +1 -1
  197. package/scrollList/index.tsx +3 -19
  198. package/select/_story/select.stories.js +11 -0
  199. package/select/index.tsx +4 -12
  200. package/select/option.tsx +1 -5
  201. package/sideSheet/SideSheetContent.tsx +3 -3
  202. package/skeleton/index.tsx +1 -1
  203. package/space/index.tsx +1 -1
  204. package/spin/index.tsx +9 -15
  205. package/switch/index.tsx +14 -9
  206. package/table/Table.tsx +3 -5
  207. package/table/_story/v2/FixedOnHeaderRow/index.jsx +3 -0
  208. package/tabs/TabBar.tsx +1 -1
  209. package/tabs/TabPane.tsx +4 -9
  210. package/tabs/_story/tabs.stories.js +36 -0
  211. package/tag/_story/tag.stories.js +1 -1
  212. package/tagInput/index.tsx +47 -22
  213. package/timePicker/Combobox.tsx +1 -6
  214. package/toast/toast.tsx +3 -3
  215. package/transfer/index.tsx +0 -1
  216. package/tree/treeNode.tsx +1 -1
  217. package/treeSelect/index.tsx +3 -15
  218. package/typography/base.tsx +1 -1
  219. package/upload/_story/upload.stories.js +152 -0
  220. package/upload/index.tsx +38 -107
  221. package/yarn-error.log +0 -26235
@@ -122,7 +122,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
122
122
  PropTypes.shape({
123
123
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
124
124
  label: PropTypes.any,
125
- })
125
+ }),
126
126
  ),
127
127
  treeNodeFilterProp: PropTypes.string,
128
128
  suffix: PropTypes.node,
@@ -199,7 +199,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
199
199
  onDropdownVisibleChange: noop,
200
200
  onListScroll: noop,
201
201
  enableLeafClick: false,
202
- 'aria-label': 'Cascader',
202
+ 'aria-label': 'Cascader'
203
203
  };
204
204
 
205
205
  options: any;
@@ -247,7 +247,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
247
247
  /* Keys of loading item */
248
248
  loadingKeys: new Set(),
249
249
  /* Mark whether this rendering has triggered asynchronous loading of data */
250
- loading: false,
250
+ loading: false
251
251
  };
252
252
  this.options = {};
253
253
  this.isEmpty = false;
@@ -274,9 +274,10 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
274
274
  }
275
275
  },
276
276
  };
277
- const cascaderAdapter: Pick<
278
- CascaderAdapter,
279
- 'registerClickOutsideHandler' | 'unregisterClickOutsideHandler' | 'rePositionDropdown'
277
+ const cascaderAdapter: Pick<CascaderAdapter,
278
+ 'registerClickOutsideHandler'
279
+ | 'unregisterClickOutsideHandler'
280
+ | 'rePositionDropdown'
280
281
  > = {
281
282
  registerClickOutsideHandler: cb => {
282
283
  const clickOutsideHandler = (e: Event) => {
@@ -367,10 +368,17 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
367
368
  }
368
369
 
369
370
  static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState) {
370
- const { multiple, value, defaultValue, onChangeWithObject, leafOnly, autoMergeValue } = props;
371
+ const {
372
+ multiple,
373
+ value,
374
+ defaultValue,
375
+ onChangeWithObject,
376
+ leafOnly,
377
+ autoMergeValue,
378
+ } = props;
371
379
  const { prevProps } = prevState;
372
380
  let keyEntities = prevState.keyEntities || {};
373
- const newState: Partial<CascaderState> = {};
381
+ const newState: Partial<CascaderState> = { };
374
382
  const needUpdate = (name: string) => {
375
383
  const firstInProps = isEmpty(prevProps) && name in props;
376
384
  const nameHasChange = prevProps && !isEqual(prevProps[name], props[name]);
@@ -400,18 +408,20 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
400
408
  const realValue = needUpdate('value') ? value : defaultValue;
401
409
  // eslint-disable-next-line max-depth
402
410
  if (Array.isArray(realValue)) {
403
- normallizedValue = Array.isArray(realValue[0])
404
- ? (realValue as SimpleValueType[][])
405
- : ([realValue] as SimpleValueType[][]);
411
+ normallizedValue = Array.isArray(realValue[0]) ?
412
+ realValue as SimpleValueType[][] :
413
+ [realValue] as SimpleValueType[][];
406
414
  } else {
407
- normallizedValue = [[realValue]];
415
+ if (realValue !== undefined) {
416
+ normallizedValue = [[realValue]];
417
+ }
408
418
  }
409
419
  // formatValuePath is used to save value of valuePath
410
420
  const formatValuePath: (string | number)[][] = [];
411
421
  normallizedValue.forEach((valueItem: SimpleValueType[]) => {
412
- const formatItem: (string | number)[] = onChangeWithObject
413
- ? (valueItem as CascaderData[]).map(i => i.value)
414
- : (valueItem as (string | number)[]);
422
+ const formatItem: (string | number)[] = onChangeWithObject ?
423
+ (valueItem as CascaderData[]).map(i => i?.value) :
424
+ valueItem as (string | number)[];
415
425
  formatValuePath.push(formatItem);
416
426
  });
417
427
  // formatKeys is used to save key of value
@@ -472,9 +482,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
472
482
  renderTagItem = (value: string | Array<string>, idx: number, type: string) => {
473
483
  const { keyEntities, disabledKeys } = this.state;
474
484
  const { size, disabled, displayProp, displayRender, disableStrictly } = this.props;
475
- const nodeKey = type === strings.IS_VALUE ? findKeysForValues(value, keyEntities)[0] : value;
476
- const isDsiabled =
477
- disabled || keyEntities[nodeKey].data.disabled || (disableStrictly && disabledKeys.has(nodeKey));
485
+ const nodeKey = type === strings.IS_VALUE ?
486
+ findKeysForValues(value, keyEntities)[0] :
487
+ value;
488
+ const isDsiabled = disabled ||
489
+ keyEntities[nodeKey].data.disabled ||
490
+ (disableStrictly && disabledKeys.has(nodeKey));
478
491
  if (!isEmpty(keyEntities) && !isEmpty(keyEntities[nodeKey])) {
479
492
  const tagCls = cls(`${prefixcls}-selection-tag`, {
480
493
  [`${prefixcls}-selection-tag-disabled`]: isDsiabled,
@@ -482,7 +495,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
482
495
  // custom render tags
483
496
  if (isFunction(displayRender)) {
484
497
  return displayRender(keyEntities[nodeKey], idx);
485
- // default render tags
498
+ // default render tags
486
499
  } else {
487
500
  return (
488
501
  <Tag
@@ -506,11 +519,25 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
506
519
  };
507
520
 
508
521
  renderTagInput() {
509
- const { size, disabled, placeholder, maxTagCount, showRestTagsPopover, restTagsPopoverProps } = this.props;
510
- const { inputValue, checkedKeys, keyEntities, resolvedCheckedKeys } = this.state;
522
+ const {
523
+ size,
524
+ disabled,
525
+ placeholder,
526
+ maxTagCount,
527
+ showRestTagsPopover,
528
+ restTagsPopoverProps,
529
+ } = this.props;
530
+ const {
531
+ inputValue,
532
+ checkedKeys,
533
+ keyEntities,
534
+ resolvedCheckedKeys
535
+ } = this.state;
511
536
  const tagInputcls = cls(`${prefixcls}-tagInput-wrapper`);
512
537
  const tagValue: Array<Array<string>> = [];
513
- const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
538
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
539
+ ? checkedKeys
540
+ : resolvedCheckedKeys;
514
541
  [...realKeys].forEach(checkedKey => {
515
542
  if (!isEmpty(keyEntities[checkedKey])) {
516
543
  tagValue.push(keyEntities[checkedKey].valuePath);
@@ -523,7 +550,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
523
550
  disabled={disabled}
524
551
  size={size}
525
552
  // TODO Modify logic, not modify type
526
- value={(tagValue as unknown) as string[]}
553
+ value={tagValue as unknown as string[]}
527
554
  showRestTagsPopover={showRestTagsPopover}
528
555
  restTagsPopoverProps={restTagsPopoverProps}
529
556
  maxTagCount={maxTagCount}
@@ -531,7 +558,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
531
558
  inputValue={inputValue}
532
559
  onInputChange={this.handleInputChange}
533
560
  // TODO Modify logic, not modify type
534
- onRemove={v => this.handleTagRemove(null, (v as unknown) as (string | number)[])}
561
+ onRemove={v => this.handleTagRemove(null, v as unknown as (string | number)[])}
535
562
  placeholder={placeholder}
536
563
  />
537
564
  );
@@ -553,7 +580,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
553
580
  });
554
581
  return (
555
582
  <div className={wrappercls}>
556
- <Input ref={this.inputRef as any} size={size} {...inputProps} />
583
+ <Input
584
+ ref={this.inputRef as any}
585
+ size={size}
586
+ {...inputProps}
587
+ />
557
588
  </div>
558
589
  );
559
590
  }
@@ -583,7 +614,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
583
614
  checkedKeys,
584
615
  halfCheckedKeys,
585
616
  loadedKeys,
586
- loadingKeys,
617
+ loadingKeys
587
618
  } = this.state;
588
619
  const {
589
620
  filterTreeNode,
@@ -595,7 +626,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
595
626
  topSlot,
596
627
  bottomSlot,
597
628
  showNext,
598
- multiple,
629
+ multiple
599
630
  } = this.props;
600
631
  const searchable = Boolean(filterTreeNode) && isSearching;
601
632
  const popoverCls = cls(dropdownClassName, `${prefixcls}-popover`);
@@ -632,29 +663,37 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
632
663
  renderPlusN = (hiddenTag: Array<ReactNode>) => {
633
664
  const { disabled, showRestTagsPopover, restTagsPopoverProps } = this.props;
634
665
  const plusNCls = cls(`${prefixcls}-selection-n`, {
635
- [`${prefixcls}-selection-n-disabled`]: disabled,
666
+ [`${prefixcls}-selection-n-disabled`]: disabled
636
667
  });
637
- const renderPlusNChildren = <span className={plusNCls}>+{hiddenTag.length}</span>;
638
- return showRestTagsPopover && !disabled ? (
639
- <Popover
640
- content={hiddenTag}
641
- showArrow
642
- trigger="hover"
643
- position="top"
644
- autoAdjustOverflow
645
- {...restTagsPopoverProps}
646
- >
647
- {renderPlusNChildren}
648
- </Popover>
649
- ) : (
650
- renderPlusNChildren
668
+ const renderPlusNChildren = (
669
+ <span className={plusNCls}>
670
+ +{hiddenTag.length}
671
+ </span>
672
+ );
673
+ return (
674
+ showRestTagsPopover && !disabled ?
675
+ (
676
+ <Popover
677
+ content={hiddenTag}
678
+ showArrow
679
+ trigger="hover"
680
+ position="top"
681
+ autoAdjustOverflow
682
+ {...restTagsPopoverProps}
683
+ >
684
+ {renderPlusNChildren}
685
+ </Popover>
686
+ ) :
687
+ renderPlusNChildren
651
688
  );
652
689
  };
653
690
 
654
691
  renderMultipleTags = () => {
655
692
  const { autoMergeValue, maxTagCount } = this.props;
656
693
  const { checkedKeys, resolvedCheckedKeys } = this.state;
657
- const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
694
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
695
+ ? checkedKeys
696
+ : resolvedCheckedKeys;
658
697
  const displayTag: Array<ReactNode> = [];
659
698
  const hiddenTag: Array<ReactNode> = [];
660
699
  [...realKeys].forEach((checkedKey, idx) => {
@@ -683,22 +722,19 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
683
722
  if (displayRender && typeof displayRender === 'function') {
684
723
  displayText = displayRender(displayPath);
685
724
  } else {
686
- displayText = displayPath.map((path: ReactNode, index: number) => (
725
+ displayText = displayPath.map((path: ReactNode, index: number)=>(
687
726
  <Fragment key={`${path}-${index}`}>
688
- {index < displayPath.length - 1 ? (
689
- <>
690
- {path}
691
- {separator}
692
- </>
693
- ) : (
694
- path
695
- )}
727
+ {
728
+ index<displayPath.length-1
729
+ ? <>{path}{separator}</>
730
+ : path
731
+ }
696
732
  </Fragment>
697
733
  ));
698
734
  }
699
735
  }
700
736
  return displayText;
701
- };
737
+ }
702
738
 
703
739
  renderSelectContent = () => {
704
740
  const { placeholder, filterTreeNode, multiple } = this.props;
@@ -729,11 +765,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
729
765
  [`${prefixcls}-suffix-text`]: suffix && isString(suffix),
730
766
  [`${prefixcls}-suffix-icon`]: isSemiIcon(suffix),
731
767
  });
732
- return (
733
- <div className={suffixWrapperCls} x-semi-prop="suffix">
734
- {suffix}
735
- </div>
736
- );
768
+ return <div className={suffixWrapperCls}>{suffix}</div>;
737
769
  };
738
770
 
739
771
  renderPrefix = () => {
@@ -748,11 +780,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
748
780
  [`${prefixcls}-prefix-icon`]: isSemiIcon(labelNode),
749
781
  });
750
782
 
751
- return (
752
- <div className={prefixWrapperCls} id={insetLabelId} x-semi-prop="prefix,insetLabel">
753
- {labelNode}
754
- </div>
755
- );
783
+ return <div className={prefixWrapperCls} id={insetLabelId}>{labelNode}</div>;
756
784
  };
757
785
 
758
786
  renderCustomTrigger = () => {
@@ -821,7 +849,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
821
849
  className={clearCls}
822
850
  onClick={this.handleClear}
823
851
  onKeyPress={this.handleClearEnterPress}
824
- role="button"
852
+ role='button'
825
853
  tabIndex={0}
826
854
  >
827
855
  <IconClear />
@@ -837,11 +865,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
837
865
  if (showClearBtn) {
838
866
  return null;
839
867
  }
840
- return arrowIcon ? (
841
- <div className={cls(`${prefixcls}-arrow`)} x-semi-prop="arrowIcon">
842
- {arrowIcon}
843
- </div>
844
- ) : null;
868
+ return arrowIcon ? <div className={cls(`${prefixcls}-arrow`)}>{arrowIcon}</div> : null;
845
869
  };
846
870
 
847
871
  renderSelection = () => {
@@ -863,40 +887,40 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
863
887
  const { isOpen, isFocus, isInput, checkedKeys } = this.state;
864
888
  const filterable = Boolean(filterTreeNode);
865
889
  const useCustomTrigger = typeof triggerRender === 'function';
866
- const classNames = useCustomTrigger
867
- ? cls(className)
868
- : cls(prefixcls, className, {
869
- [`${prefixcls}-focus`]: isFocus || (isOpen && !isInput),
870
- [`${prefixcls}-disabled`]: disabled,
871
- [`${prefixcls}-single`]: true,
872
- [`${prefixcls}-filterable`]: filterable,
873
- [`${prefixcls}-error`]: validateStatus === 'error',
874
- [`${prefixcls}-warning`]: validateStatus === 'warning',
875
- [`${prefixcls}-small`]: size === 'small',
876
- [`${prefixcls}-large`]: size === 'large',
877
- [`${prefixcls}-with-prefix`]: prefix || insetLabel,
878
- [`${prefixcls}-with-suffix`]: suffix,
879
- });
880
- const mouseEvent = showClear
881
- ? {
882
- onMouseEnter: () => this.handleMouseOver(),
883
- onMouseLeave: () => this.handleMouseLeave(),
884
- }
885
- : {};
890
+ const classNames = useCustomTrigger ?
891
+ cls(className) :
892
+ cls(prefixcls, className, {
893
+ [`${prefixcls}-focus`]: isFocus || (isOpen && !isInput),
894
+ [`${prefixcls}-disabled`]: disabled,
895
+ [`${prefixcls}-single`]: true,
896
+ [`${prefixcls}-filterable`]: filterable,
897
+ [`${prefixcls}-error`]: validateStatus === 'error',
898
+ [`${prefixcls}-warning`]: validateStatus === 'warning',
899
+ [`${prefixcls}-small`]: size === 'small',
900
+ [`${prefixcls}-large`]: size === 'large',
901
+ [`${prefixcls}-with-prefix`]: prefix || insetLabel,
902
+ [`${prefixcls}-with-suffix`]: suffix,
903
+ });
904
+ const mouseEvent = showClear ?
905
+ {
906
+ onMouseEnter: () => this.handleMouseOver(),
907
+ onMouseLeave: () => this.handleMouseLeave(),
908
+ } :
909
+ {};
886
910
  const sectionCls = cls(`${prefixcls}-selection`, {
887
911
  [`${prefixcls}-selection-multiple`]: multiple && !isEmpty(checkedKeys),
888
912
  });
889
- const inner = useCustomTrigger
890
- ? this.renderCustomTrigger()
891
- : [
892
- <Fragment key={'prefix'}>{prefix || insetLabel ? this.renderPrefix() : null}</Fragment>,
893
- <Fragment key={'selection'}>
894
- <div className={sectionCls}>{this.renderSelectContent()}</div>
895
- </Fragment>,
896
- <Fragment key={'clearbtn'}>{this.renderClearBtn()}</Fragment>,
897
- <Fragment key={'suffix'}>{suffix ? this.renderSuffix() : null}</Fragment>,
898
- <Fragment key={'arrow'}>{this.renderArrow()}</Fragment>,
899
- ];
913
+ const inner = useCustomTrigger ?
914
+ this.renderCustomTrigger() :
915
+ [
916
+ <Fragment key={'prefix'}>{prefix || insetLabel ? this.renderPrefix() : null}</Fragment>,
917
+ <Fragment key={'selection'}>
918
+ <div className={sectionCls}>{this.renderSelectContent()}</div>
919
+ </Fragment>,
920
+ <Fragment key={'clearbtn'}>{this.renderClearBtn()}</Fragment>,
921
+ <Fragment key={'suffix'}>{suffix ? this.renderSuffix() : null}</Fragment>,
922
+ <Fragment key={'arrow'}>{this.renderArrow()}</Fragment>,
923
+ ];
900
924
  /**
901
925
  * Reasons for disabling the a11y eslint rule:
902
926
  * The following attributes(aria-controls,aria-expanded) will be automatically added by Tooltip, no need to declare here
@@ -912,12 +936,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
912
936
  aria-errormessage={this.props['aria-errormessage']}
913
937
  aria-label={this.props['aria-label']}
914
938
  aria-labelledby={this.props['aria-labelledby']}
915
- aria-describedby={this.props['aria-describedby']}
939
+ aria-describedby={this.props["aria-describedby"]}
916
940
  aria-required={this.props['aria-required']}
917
941
  id={id}
918
942
  {...mouseEvent}
919
943
  // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
920
- role="combobox"
944
+ role='combobox'
921
945
  tabIndex={0}
922
946
  >
923
947
  {inner}
package/cascader/item.tsx CHANGED
@@ -291,7 +291,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
291
291
  <LocaleConsumer componentName="Cascader">
292
292
  {(locale: Locale['Cascader']) => (
293
293
  <ul className={`${prefixcls} ${prefixcls}-empty`} key={'empty-list'}>
294
- <span className={`${prefixcls}-label`} x-semi-prop="emptyContent">
294
+ <span className={`${prefixcls}-label`}>
295
295
  {emptyContent || locale.emptyText}
296
296
  </span>
297
297
  </ul>
@@ -36,6 +36,7 @@ interface CheckboxState {
36
36
  checked: boolean;
37
37
  addonId?: string;
38
38
  extraId?: string;
39
+ focusVisible?: boolean;
39
40
  }
40
41
  class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
41
42
  static contextType = Context;
@@ -99,13 +100,17 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
99
100
  },
100
101
  setExtraId: () => {
101
102
  this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
102
- }
103
+ },
104
+ setFocusVisible: (focusVisible: boolean): void => {
105
+ this.setState({ focusVisible });
106
+ },
107
+ focusCheckboxEntity: () => {
108
+ this.focus();
109
+ },
103
110
  };
104
111
  }
105
112
 
106
113
  foundation: CheckboxFoundation;
107
- addonId: string;
108
- extraId: string;
109
114
  constructor(props: CheckboxProps) {
110
115
  super(props);
111
116
 
@@ -115,6 +120,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
115
120
  checked: props.checked || props.defaultChecked || checked,
116
121
  addonId: props.addonId,
117
122
  extraId: props.extraId,
123
+ focusVisible: false
118
124
  };
119
125
 
120
126
  this.checkboxEntity = null;
@@ -147,6 +153,14 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
147
153
 
148
154
  handleEnterPress = (e: React.KeyboardEvent<HTMLSpanElement>) => this.foundation.handleEnterPress(e);
149
155
 
156
+ handleFocusVisible = (event: React.FocusEvent) => {
157
+ this.foundation.handleFocusVisible(event);
158
+ }
159
+
160
+ handleBlur = (event: React.FocusEvent) => {
161
+ this.foundation.handleBlur();
162
+ }
163
+
150
164
  render() {
151
165
  const {
152
166
  disabled,
@@ -163,7 +177,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
163
177
  tabIndex,
164
178
  id
165
179
  } = this.props;
166
- const { checked, addonId, extraId } = this.state;
180
+ const { checked, addonId, extraId, focusVisible } = this.state;
167
181
  const props: Record<string, any> = {
168
182
  checked,
169
183
  disabled,
@@ -186,6 +200,8 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
186
200
 
187
201
  const prefix = prefixCls || css.PREFIX;
188
202
 
203
+ const focusOuter = props.isCardType || props.isPureCardType;
204
+
189
205
  const wrapper = classnames(prefix, {
190
206
  [`${prefix}-disabled`]: props.disabled,
191
207
  [`${prefix}-indeterminate`]: indeterminate,
@@ -197,32 +213,21 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
197
213
  [`${prefix}-cardType_checked`]: props.isCardType && props.checked && !props.disabled,
198
214
  [`${prefix}-cardType_checked_disabled`]: props.isCardType && props.checked && props.disabled,
199
215
  [className]: Boolean(className),
216
+ [`${prefix}-focus`]: focusVisible && focusOuter,
200
217
  });
201
218
 
202
219
  const extraCls = classnames(`${prefix}-extra`, {
203
220
  [`${prefix}-cardType_extra_noChildren`]: props.isCardType && !children,
204
221
  });
205
222
 
206
- const name = inGroup && this.context.checkboxGroup.name;
207
- const xSemiPropChildren = this.props['x-semi-children-alias'] || 'children';
208
-
209
223
  const renderContent = () => (
210
224
  <>
211
- {children ? (
212
- <span id={this.addonId} className={`${prefix}-addon`} x-semi-prop={xSemiPropChildren}>
213
- {children}
214
- </span>
215
- ) : null}
216
- {extra ? (
217
- <div id={this.extraId} className={extraCls} x-semi-prop="extra">
218
- {extra}
219
- </div>
220
- ) : null}
225
+ {children ? <span id={addonId} className={`${prefix}-addon`}>{children}</span> : null}
226
+ {extra ? <div id={extraId} className={extraCls}>{extra}</div> : null}
221
227
  </>
222
228
  );
223
229
  return (
224
230
  // label is better than span, however span is here which is to solve gitlab issue #364
225
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
226
231
  <span
227
232
  role={role}
228
233
  tabIndex={tabIndex}
@@ -238,12 +243,15 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
238
243
  <CheckboxInner
239
244
  {...this.props}
240
245
  {...props}
241
- addonId={children && this.addonId}
242
- extraId={extra && this.extraId}
246
+ addonId={children && addonId}
247
+ extraId={extra && extraId}
243
248
  isPureCardType={props.isPureCardType}
244
249
  ref={ref => {
245
250
  this.checkboxEntity = ref;
246
251
  }}
252
+ focusInner={focusVisible && !focusOuter}
253
+ onInputFocus={this.handleFocusVisible}
254
+ onInputBlur={this.handleBlur}
247
255
  />
248
256
  {
249
257
  props.isCardType ?
@@ -23,6 +23,9 @@ export interface CheckboxInnerProps {
23
23
  addonId?: string;
24
24
  extraId?: string;
25
25
  'aria-label'?: React.AriaAttributes['aria-label'];
26
+ focusInner?: boolean;
27
+ onInputFocus?: (e: any) => void;
28
+ onInputBlur?: (e: any) => void;
26
29
  }
27
30
 
28
31
  class CheckboxInner extends PureComponent<CheckboxInnerProps> {
@@ -43,6 +46,9 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
43
46
  isPureCardType: PropTypes.bool,
44
47
  addonId: PropTypes.string,
45
48
  extraId: PropTypes.string,
49
+ focusInner: PropTypes.bool,
50
+ onInputFocus: PropTypes.func,
51
+ onInputBlur: PropTypes.func,
46
52
  };
47
53
 
48
54
  static defaultProps = {
@@ -59,7 +65,7 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
59
65
  }
60
66
 
61
67
  render() {
62
- const { indeterminate, checked, disabled, prefixCls, name, isPureCardType, addonId, extraId } = this.props;
68
+ const { indeterminate, checked, disabled, prefixCls, name, isPureCardType, addonId, extraId, focusInner, onInputFocus, onInputBlur } = this.props;
63
69
  const prefix = prefixCls || css.PREFIX;
64
70
 
65
71
  const wrapper = classnames(
@@ -73,6 +79,8 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
73
79
 
74
80
  const inner = classnames({
75
81
  [`${prefix}-inner-display`]: true,
82
+ [`${prefix}-focus`]: focusInner,
83
+ [`${prefix}-focus-border`]: focusInner && !checked,
76
84
  });
77
85
 
78
86
  const icon = checked ? (
@@ -95,6 +103,8 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
95
103
  onChange: noop,
96
104
  checked: checked,
97
105
  disabled: disabled,
106
+ onFocus: onInputFocus,
107
+ onBlur: onInputBlur,
98
108
  };
99
109
 
100
110
  name && (inputProps['name'] = name);
@@ -92,14 +92,7 @@ const Collapsible = (props: CollapsibleProps) => {
92
92
  const wrapperCls = cls(`${cssClasses.PREFIX}-wrapper`, className);
93
93
  return (
94
94
  <div style={wrapperstyle} className={wrapperCls} ref={ref}>
95
- <div
96
- ref={setHeight}
97
- style={{ overflow: 'hidden' }}
98
- id={id}
99
- x-semi-prop="children"
100
- >
101
- {children}
102
- </div>
95
+ <div ref={setHeight} style={{ overflow: 'hidden' }} id={id}>{children}</div>
103
96
  </div>
104
97
  );
105
98
  };
@@ -172,7 +172,6 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
172
172
  <div
173
173
  className={`${prefixCls}-range-input-prefix`}
174
174
  onClick={e => !disabled && !rangeInputFocus && this.handleRangeStartFocus(e)}
175
- x-semi-prop="prefix,insetLabel"
176
175
  >
177
176
  {labelNode}
178
177
  </div>
@@ -653,21 +653,13 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
653
653
 
654
654
  return (
655
655
  <div ref={this.panelRef} className={wrapCls} style={dropdownStyle}>
656
- {topSlot && (
657
- <div className={`${cssClasses.PREFIX}-topSlot`} x-semi-prop="topSlot">
658
- {topSlot}
659
- </div>
660
- )}
656
+ {topSlot && <div className={`${cssClasses.PREFIX}-topSlot`}>{topSlot}</div>}
661
657
  {insetInput && <DateInput {...insetInputProps} insetInput={true} />}
662
- {this.adapter.typeIsYearOrMonth()
663
- ? this.renderYearMonthPanel(locale, localeCode)
664
- : this.renderMonthGrid(locale, localeCode, dateFnsLocale)}
658
+ {this.adapter.typeIsYearOrMonth() ?
659
+ this.renderYearMonthPanel(locale, localeCode) :
660
+ this.renderMonthGrid(locale, localeCode, dateFnsLocale)}
665
661
  {this.renderQuickControls()}
666
- {bottomSlot && (
667
- <div className={`${cssClasses.PREFIX}-bottomSlot`} x-semi-prop="bottomSlot">
668
- {bottomSlot}
669
- </div>
670
- )}
662
+ {bottomSlot && <div className={`${cssClasses.PREFIX}-bottomSlot`}>{bottomSlot}</div>}
671
663
  {this.renderFooter(locale, localeCode)}
672
664
  </div>
673
665
  );