@douyinfe/semi-ui 2.12.1-alpha.2 → 2.13.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 (224) 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 +123 -101
  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 +9 -1
  20. package/dist/css/semi.min.css +1 -1
  21. package/dist/umd/semi-ui.js +5372 -3695
  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/iconButton/index.tsx +1 -2
  33. package/input/index.tsx +11 -38
  34. package/inputNumber/__test__/inputNumber.test.js +2 -3
  35. package/inputNumber/_story/inputNumber.stories.js +53 -0
  36. package/inputNumber/index.tsx +0 -4
  37. package/lib/cjs/autoComplete/index.js +1 -1
  38. package/lib/cjs/avatar/index.js +2 -4
  39. package/lib/cjs/backtop/index.js +1 -2
  40. package/lib/cjs/badge/index.js +1 -2
  41. package/lib/cjs/banner/index.js +4 -9
  42. package/lib/cjs/breadcrumb/index.js +3 -4
  43. package/lib/cjs/button/Button.d.ts +1 -1
  44. package/lib/cjs/button/Button.js +3 -13
  45. package/lib/cjs/button/index.d.ts +1 -1
  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 +6 -9
  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 +42 -10
  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.d.ts +1 -1
  109. package/lib/cjs/typography/base.js +1 -2
  110. package/lib/cjs/typography/paragraph.d.ts +1 -1
  111. package/lib/cjs/typography/text.d.ts +1 -1
  112. package/lib/cjs/typography/title.d.ts +2 -2
  113. package/lib/cjs/upload/index.d.ts +2 -2
  114. package/lib/cjs/upload/index.js +6 -13
  115. package/lib/es/autoComplete/index.js +1 -1
  116. package/lib/es/avatar/index.js +2 -4
  117. package/lib/es/backtop/index.js +1 -2
  118. package/lib/es/badge/index.js +1 -2
  119. package/lib/es/banner/index.js +4 -9
  120. package/lib/es/breadcrumb/index.js +3 -4
  121. package/lib/es/button/Button.d.ts +1 -1
  122. package/lib/es/button/Button.js +3 -11
  123. package/lib/es/button/index.d.ts +1 -1
  124. package/lib/es/card/index.js +5 -10
  125. package/lib/es/carousel/CarouselArrow.js +2 -6
  126. package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
  127. package/lib/es/carousel/index.d.ts +1 -1
  128. package/lib/es/carousel/index.js +1 -2
  129. package/lib/es/cascader/index.js +6 -9
  130. package/lib/es/cascader/item.js +1 -2
  131. package/lib/es/checkbox/checkbox.d.ts +3 -2
  132. package/lib/es/checkbox/checkbox.js +33 -15
  133. package/lib/es/checkbox/checkboxInner.d.ts +6 -0
  134. package/lib/es/checkbox/checkboxInner.js +14 -4
  135. package/lib/es/collapsible/index.js +1 -2
  136. package/lib/es/datePicker/dateInput.d.ts +1 -1
  137. package/lib/es/datePicker/dateInput.js +1 -2
  138. package/lib/es/datePicker/datePicker.d.ts +1 -1
  139. package/lib/es/datePicker/datePicker.js +2 -4
  140. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  141. package/lib/es/divider/index.js +1 -2
  142. package/lib/es/dropdown/index.js +1 -2
  143. package/lib/es/empty/index.js +4 -8
  144. package/lib/es/form/baseForm.d.ts +1 -1
  145. package/lib/es/form/field.d.ts +1 -1
  146. package/lib/es/form/hoc/withField.js +1 -2
  147. package/lib/es/form/label.js +1 -2
  148. package/lib/es/grid/col.js +1 -2
  149. package/lib/es/grid/row.js +1 -2
  150. package/lib/es/iconButton/index.js +1 -3
  151. package/lib/es/input/index.js +5 -9
  152. package/lib/es/inputNumber/index.js +0 -4
  153. package/lib/es/list/index.js +3 -6
  154. package/lib/es/modal/ConfirmModal.js +1 -2
  155. package/lib/es/modal/Modal.js +2 -6
  156. package/lib/es/modal/ModalContent.js +6 -13
  157. package/lib/es/notification/notice.js +3 -6
  158. package/lib/es/pagination/index.js +2 -4
  159. package/lib/es/popconfirm/index.js +3 -6
  160. package/lib/es/popover/index.d.ts +1 -0
  161. package/lib/es/radio/radio.d.ts +1 -1
  162. package/lib/es/radio/radio.js +2 -4
  163. package/lib/es/radio/radioGroup.d.ts +1 -1
  164. package/lib/es/rating/item.js +1 -2
  165. package/lib/es/scrollList/index.js +3 -6
  166. package/lib/es/select/index.js +4 -8
  167. package/lib/es/select/option.js +1 -2
  168. package/lib/es/sideSheet/SideSheetContent.js +3 -6
  169. package/lib/es/skeleton/index.js +1 -3
  170. package/lib/es/space/index.js +1 -2
  171. package/lib/es/spin/index.js +3 -7
  172. package/lib/es/switch/index.js +4 -6
  173. package/lib/es/table/Table.js +3 -6
  174. package/lib/es/tabs/TabBar.js +1 -2
  175. package/lib/es/tabs/TabPane.js +2 -5
  176. package/lib/es/tagInput/index.d.ts +6 -1
  177. package/lib/es/tagInput/index.js +41 -10
  178. package/lib/es/timePicker/Combobox.js +1 -3
  179. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  180. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  181. package/lib/es/timePicker/index.d.ts +2 -2
  182. package/lib/es/toast/toast.js +3 -6
  183. package/lib/es/transfer/index.js +1 -2
  184. package/lib/es/tree/treeNode.js +1 -2
  185. package/lib/es/treeSelect/index.js +3 -6
  186. package/lib/es/typography/base.d.ts +1 -1
  187. package/lib/es/typography/base.js +1 -2
  188. package/lib/es/typography/paragraph.d.ts +1 -1
  189. package/lib/es/typography/text.d.ts +1 -1
  190. package/lib/es/typography/title.d.ts +2 -2
  191. package/lib/es/upload/index.d.ts +2 -2
  192. package/lib/es/upload/index.js +6 -13
  193. package/list/index.tsx +4 -16
  194. package/modal/ConfirmModal.tsx +1 -1
  195. package/modal/Modal.tsx +0 -2
  196. package/modal/ModalContent.tsx +14 -27
  197. package/notification/notice.tsx +4 -16
  198. package/package.json +9 -9
  199. package/pagination/index.tsx +2 -16
  200. package/popconfirm/index.tsx +3 -11
  201. package/popover/index.tsx +1 -1
  202. package/radio/radio.tsx +2 -10
  203. package/rating/item.tsx +1 -1
  204. package/scrollList/index.tsx +3 -19
  205. package/select/_story/select.stories.js +11 -0
  206. package/select/index.tsx +4 -12
  207. package/select/option.tsx +1 -5
  208. package/sideSheet/SideSheetContent.tsx +3 -3
  209. package/skeleton/index.tsx +1 -1
  210. package/space/index.tsx +1 -1
  211. package/spin/index.tsx +9 -15
  212. package/switch/index.tsx +14 -9
  213. package/table/Table.tsx +3 -5
  214. package/tabs/TabBar.tsx +1 -1
  215. package/tabs/TabPane.tsx +4 -9
  216. package/tagInput/index.tsx +38 -11
  217. package/timePicker/Combobox.tsx +1 -6
  218. package/toast/toast.tsx +3 -3
  219. package/transfer/index.tsx +0 -1
  220. package/tree/treeNode.tsx +1 -1
  221. package/treeSelect/index.tsx +3 -15
  222. package/typography/base.tsx +1 -1
  223. package/upload/index.tsx +38 -107
  224. 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,18 @@ 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
415
  normallizedValue = [[realValue]];
408
416
  }
409
417
  // formatValuePath is used to save value of valuePath
410
418
  const formatValuePath: (string | number)[][] = [];
411
419
  normallizedValue.forEach((valueItem: SimpleValueType[]) => {
412
- const formatItem: (string | number)[] = onChangeWithObject
413
- ? (valueItem as CascaderData[]).map(i => i.value)
414
- : (valueItem as (string | number)[]);
420
+ const formatItem: (string | number)[] = onChangeWithObject ?
421
+ (valueItem as CascaderData[]).map(i => i.value) :
422
+ valueItem as (string | number)[];
415
423
  formatValuePath.push(formatItem);
416
424
  });
417
425
  // formatKeys is used to save key of value
@@ -472,9 +480,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
472
480
  renderTagItem = (value: string | Array<string>, idx: number, type: string) => {
473
481
  const { keyEntities, disabledKeys } = this.state;
474
482
  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));
483
+ const nodeKey = type === strings.IS_VALUE ?
484
+ findKeysForValues(value, keyEntities)[0] :
485
+ value;
486
+ const isDsiabled = disabled ||
487
+ keyEntities[nodeKey].data.disabled ||
488
+ (disableStrictly && disabledKeys.has(nodeKey));
478
489
  if (!isEmpty(keyEntities) && !isEmpty(keyEntities[nodeKey])) {
479
490
  const tagCls = cls(`${prefixcls}-selection-tag`, {
480
491
  [`${prefixcls}-selection-tag-disabled`]: isDsiabled,
@@ -482,7 +493,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
482
493
  // custom render tags
483
494
  if (isFunction(displayRender)) {
484
495
  return displayRender(keyEntities[nodeKey], idx);
485
- // default render tags
496
+ // default render tags
486
497
  } else {
487
498
  return (
488
499
  <Tag
@@ -506,11 +517,25 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
506
517
  };
507
518
 
508
519
  renderTagInput() {
509
- const { size, disabled, placeholder, maxTagCount, showRestTagsPopover, restTagsPopoverProps } = this.props;
510
- const { inputValue, checkedKeys, keyEntities, resolvedCheckedKeys } = this.state;
520
+ const {
521
+ size,
522
+ disabled,
523
+ placeholder,
524
+ maxTagCount,
525
+ showRestTagsPopover,
526
+ restTagsPopoverProps,
527
+ } = this.props;
528
+ const {
529
+ inputValue,
530
+ checkedKeys,
531
+ keyEntities,
532
+ resolvedCheckedKeys
533
+ } = this.state;
511
534
  const tagInputcls = cls(`${prefixcls}-tagInput-wrapper`);
512
535
  const tagValue: Array<Array<string>> = [];
513
- const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
536
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
537
+ ? checkedKeys
538
+ : resolvedCheckedKeys;
514
539
  [...realKeys].forEach(checkedKey => {
515
540
  if (!isEmpty(keyEntities[checkedKey])) {
516
541
  tagValue.push(keyEntities[checkedKey].valuePath);
@@ -523,7 +548,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
523
548
  disabled={disabled}
524
549
  size={size}
525
550
  // TODO Modify logic, not modify type
526
- value={(tagValue as unknown) as string[]}
551
+ value={tagValue as unknown as string[]}
527
552
  showRestTagsPopover={showRestTagsPopover}
528
553
  restTagsPopoverProps={restTagsPopoverProps}
529
554
  maxTagCount={maxTagCount}
@@ -531,7 +556,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
531
556
  inputValue={inputValue}
532
557
  onInputChange={this.handleInputChange}
533
558
  // TODO Modify logic, not modify type
534
- onRemove={v => this.handleTagRemove(null, (v as unknown) as (string | number)[])}
559
+ onRemove={v => this.handleTagRemove(null, v as unknown as (string | number)[])}
535
560
  placeholder={placeholder}
536
561
  />
537
562
  );
@@ -553,7 +578,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
553
578
  });
554
579
  return (
555
580
  <div className={wrappercls}>
556
- <Input ref={this.inputRef as any} size={size} {...inputProps} />
581
+ <Input
582
+ ref={this.inputRef as any}
583
+ size={size}
584
+ {...inputProps}
585
+ />
557
586
  </div>
558
587
  );
559
588
  }
@@ -583,7 +612,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
583
612
  checkedKeys,
584
613
  halfCheckedKeys,
585
614
  loadedKeys,
586
- loadingKeys,
615
+ loadingKeys
587
616
  } = this.state;
588
617
  const {
589
618
  filterTreeNode,
@@ -595,7 +624,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
595
624
  topSlot,
596
625
  bottomSlot,
597
626
  showNext,
598
- multiple,
627
+ multiple
599
628
  } = this.props;
600
629
  const searchable = Boolean(filterTreeNode) && isSearching;
601
630
  const popoverCls = cls(dropdownClassName, `${prefixcls}-popover`);
@@ -632,29 +661,37 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
632
661
  renderPlusN = (hiddenTag: Array<ReactNode>) => {
633
662
  const { disabled, showRestTagsPopover, restTagsPopoverProps } = this.props;
634
663
  const plusNCls = cls(`${prefixcls}-selection-n`, {
635
- [`${prefixcls}-selection-n-disabled`]: disabled,
664
+ [`${prefixcls}-selection-n-disabled`]: disabled
636
665
  });
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
666
+ const renderPlusNChildren = (
667
+ <span className={plusNCls}>
668
+ +{hiddenTag.length}
669
+ </span>
670
+ );
671
+ return (
672
+ showRestTagsPopover && !disabled ?
673
+ (
674
+ <Popover
675
+ content={hiddenTag}
676
+ showArrow
677
+ trigger="hover"
678
+ position="top"
679
+ autoAdjustOverflow
680
+ {...restTagsPopoverProps}
681
+ >
682
+ {renderPlusNChildren}
683
+ </Popover>
684
+ ) :
685
+ renderPlusNChildren
651
686
  );
652
687
  };
653
688
 
654
689
  renderMultipleTags = () => {
655
690
  const { autoMergeValue, maxTagCount } = this.props;
656
691
  const { checkedKeys, resolvedCheckedKeys } = this.state;
657
- const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
692
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
693
+ ? checkedKeys
694
+ : resolvedCheckedKeys;
658
695
  const displayTag: Array<ReactNode> = [];
659
696
  const hiddenTag: Array<ReactNode> = [];
660
697
  [...realKeys].forEach((checkedKey, idx) => {
@@ -683,22 +720,19 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
683
720
  if (displayRender && typeof displayRender === 'function') {
684
721
  displayText = displayRender(displayPath);
685
722
  } else {
686
- displayText = displayPath.map((path: ReactNode, index: number) => (
723
+ displayText = displayPath.map((path: ReactNode, index: number)=>(
687
724
  <Fragment key={`${path}-${index}`}>
688
- {index < displayPath.length - 1 ? (
689
- <>
690
- {path}
691
- {separator}
692
- </>
693
- ) : (
694
- path
695
- )}
725
+ {
726
+ index<displayPath.length-1
727
+ ? <>{path}{separator}</>
728
+ : path
729
+ }
696
730
  </Fragment>
697
731
  ));
698
732
  }
699
733
  }
700
734
  return displayText;
701
- };
735
+ }
702
736
 
703
737
  renderSelectContent = () => {
704
738
  const { placeholder, filterTreeNode, multiple } = this.props;
@@ -729,11 +763,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
729
763
  [`${prefixcls}-suffix-text`]: suffix && isString(suffix),
730
764
  [`${prefixcls}-suffix-icon`]: isSemiIcon(suffix),
731
765
  });
732
- return (
733
- <div className={suffixWrapperCls} x-semi-prop="suffix">
734
- {suffix}
735
- </div>
736
- );
766
+ return <div className={suffixWrapperCls}>{suffix}</div>;
737
767
  };
738
768
 
739
769
  renderPrefix = () => {
@@ -748,11 +778,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
748
778
  [`${prefixcls}-prefix-icon`]: isSemiIcon(labelNode),
749
779
  });
750
780
 
751
- return (
752
- <div className={prefixWrapperCls} id={insetLabelId} x-semi-prop="prefix,insetLabel">
753
- {labelNode}
754
- </div>
755
- );
781
+ return <div className={prefixWrapperCls} id={insetLabelId}>{labelNode}</div>;
756
782
  };
757
783
 
758
784
  renderCustomTrigger = () => {
@@ -821,7 +847,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
821
847
  className={clearCls}
822
848
  onClick={this.handleClear}
823
849
  onKeyPress={this.handleClearEnterPress}
824
- role="button"
850
+ role='button'
825
851
  tabIndex={0}
826
852
  >
827
853
  <IconClear />
@@ -837,11 +863,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
837
863
  if (showClearBtn) {
838
864
  return null;
839
865
  }
840
- return arrowIcon ? (
841
- <div className={cls(`${prefixcls}-arrow`)} x-semi-prop="arrowIcon">
842
- {arrowIcon}
843
- </div>
844
- ) : null;
866
+ return arrowIcon ? <div className={cls(`${prefixcls}-arrow`)}>{arrowIcon}</div> : null;
845
867
  };
846
868
 
847
869
  renderSelection = () => {
@@ -863,40 +885,40 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
863
885
  const { isOpen, isFocus, isInput, checkedKeys } = this.state;
864
886
  const filterable = Boolean(filterTreeNode);
865
887
  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
- : {};
888
+ const classNames = useCustomTrigger ?
889
+ cls(className) :
890
+ cls(prefixcls, className, {
891
+ [`${prefixcls}-focus`]: isFocus || (isOpen && !isInput),
892
+ [`${prefixcls}-disabled`]: disabled,
893
+ [`${prefixcls}-single`]: true,
894
+ [`${prefixcls}-filterable`]: filterable,
895
+ [`${prefixcls}-error`]: validateStatus === 'error',
896
+ [`${prefixcls}-warning`]: validateStatus === 'warning',
897
+ [`${prefixcls}-small`]: size === 'small',
898
+ [`${prefixcls}-large`]: size === 'large',
899
+ [`${prefixcls}-with-prefix`]: prefix || insetLabel,
900
+ [`${prefixcls}-with-suffix`]: suffix,
901
+ });
902
+ const mouseEvent = showClear ?
903
+ {
904
+ onMouseEnter: () => this.handleMouseOver(),
905
+ onMouseLeave: () => this.handleMouseLeave(),
906
+ } :
907
+ {};
886
908
  const sectionCls = cls(`${prefixcls}-selection`, {
887
909
  [`${prefixcls}-selection-multiple`]: multiple && !isEmpty(checkedKeys),
888
910
  });
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
- ];
911
+ const inner = useCustomTrigger ?
912
+ this.renderCustomTrigger() :
913
+ [
914
+ <Fragment key={'prefix'}>{prefix || insetLabel ? this.renderPrefix() : null}</Fragment>,
915
+ <Fragment key={'selection'}>
916
+ <div className={sectionCls}>{this.renderSelectContent()}</div>
917
+ </Fragment>,
918
+ <Fragment key={'clearbtn'}>{this.renderClearBtn()}</Fragment>,
919
+ <Fragment key={'suffix'}>{suffix ? this.renderSuffix() : null}</Fragment>,
920
+ <Fragment key={'arrow'}>{this.renderArrow()}</Fragment>,
921
+ ];
900
922
  /**
901
923
  * Reasons for disabling the a11y eslint rule:
902
924
  * The following attributes(aria-controls,aria-expanded) will be automatically added by Tooltip, no need to declare here
@@ -912,12 +934,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
912
934
  aria-errormessage={this.props['aria-errormessage']}
913
935
  aria-label={this.props['aria-label']}
914
936
  aria-labelledby={this.props['aria-labelledby']}
915
- aria-describedby={this.props['aria-describedby']}
937
+ aria-describedby={this.props["aria-describedby"]}
916
938
  aria-required={this.props['aria-required']}
917
939
  id={id}
918
940
  {...mouseEvent}
919
941
  // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
920
- role="combobox"
942
+ role='combobox'
921
943
  tabIndex={0}
922
944
  >
923
945
  {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
  );
package/dist/css/semi.css CHANGED
@@ -3443,7 +3443,9 @@ body[theme-mode=dark], body .semi-always-dark {
3443
3443
  font-size: 16px;
3444
3444
  }
3445
3445
  .semi-checkbox-inner-pureCardType {
3446
- display: none;
3446
+ opacity: 0;
3447
+ width: 0;
3448
+ margin-right: 0 !important;
3447
3449
  }
3448
3450
  .semi-checkbox-inner-checked .semi-checkbox-inner-display {
3449
3451
  background: var(--semi-color-primary);
@@ -3622,6 +3624,12 @@ body[theme-mode=dark], body .semi-always-dark {
3622
3624
  color: var(--semi-color-text-2);
3623
3625
  margin-top: 4px;
3624
3626
  }
3627
+ .semi-checkbox-focus {
3628
+ outline: 2px solid var(--semi-color-primary-light-active);
3629
+ }
3630
+ .semi-checkbox-focus-border {
3631
+ box-shadow: inset 0 0 0 1px var(--semi-color-focus-border);
3632
+ }
3625
3633
 
3626
3634
  .semi-checkboxGroup {
3627
3635
  font-size: 14px;