@douyinfe/semi-ui 2.11.2 → 2.12.0-alpha.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 (206) hide show
  1. package/avatar/index.tsx +2 -2
  2. package/backtop/index.tsx +11 -7
  3. package/badge/index.tsx +1 -1
  4. package/banner/index.tsx +5 -5
  5. package/breadcrumb/index.tsx +5 -3
  6. package/button/Button.tsx +10 -8
  7. package/card/index.tsx +43 -41
  8. package/carousel/CarouselArrow.tsx +2 -0
  9. package/carousel/index.tsx +1 -0
  10. package/cascader/index.tsx +101 -123
  11. package/cascader/item.tsx +1 -1
  12. package/checkbox/checkbox.tsx +13 -2
  13. package/collapsible/index.tsx +8 -1
  14. package/datePicker/dateInput.tsx +1 -0
  15. package/datePicker/datePicker.tsx +13 -5
  16. package/dist/css/semi.css +33 -0
  17. package/dist/css/semi.min.css +1 -1
  18. package/dist/umd/semi-ui.js +694 -384
  19. package/dist/umd/semi-ui.js.map +1 -1
  20. package/dist/umd/semi-ui.min.js +1 -1
  21. package/dist/umd/semi-ui.min.js.map +1 -1
  22. package/divider/index.tsx +8 -4
  23. package/dropdown/index.tsx +1 -1
  24. package/empty/index.tsx +13 -5
  25. package/form/_story/FormSubmit/index.tsx +45 -0
  26. package/form/_story/form.stories.js +2 -1
  27. package/form/hoc/withField.tsx +1 -1
  28. package/form/label.tsx +1 -1
  29. package/grid/col.tsx +1 -1
  30. package/grid/row.tsx +1 -1
  31. package/iconButton/index.tsx +2 -1
  32. package/input/index.tsx +38 -11
  33. package/lib/cjs/avatar/index.js +4 -2
  34. package/lib/cjs/backtop/index.js +2 -1
  35. package/lib/cjs/badge/index.js +2 -1
  36. package/lib/cjs/banner/index.js +9 -4
  37. package/lib/cjs/breadcrumb/index.js +4 -3
  38. package/lib/cjs/button/Button.js +13 -3
  39. package/lib/cjs/card/index.js +10 -5
  40. package/lib/cjs/carousel/CarouselArrow.js +6 -2
  41. package/lib/cjs/carousel/index.js +2 -1
  42. package/lib/cjs/cascader/index.js +9 -6
  43. package/lib/cjs/cascader/item.js +2 -1
  44. package/lib/cjs/checkbox/checkbox.js +8 -4
  45. package/lib/cjs/collapsible/index.js +2 -1
  46. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  47. package/lib/cjs/datePicker/dateInput.js +2 -1
  48. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  49. package/lib/cjs/datePicker/datePicker.js +4 -2
  50. package/lib/cjs/datePicker/monthsGrid.d.ts +2 -2
  51. package/lib/cjs/divider/index.js +2 -1
  52. package/lib/cjs/dropdown/index.js +2 -1
  53. package/lib/cjs/empty/index.js +8 -4
  54. package/lib/cjs/form/baseForm.d.ts +1 -1
  55. package/lib/cjs/form/field.d.ts +1 -1
  56. package/lib/cjs/form/hoc/withField.js +2 -1
  57. package/lib/cjs/form/label.js +2 -1
  58. package/lib/cjs/grid/col.js +2 -1
  59. package/lib/cjs/grid/row.js +2 -1
  60. package/lib/cjs/iconButton/index.js +3 -1
  61. package/lib/cjs/input/index.js +9 -5
  62. package/lib/cjs/list/index.js +6 -3
  63. package/lib/cjs/modal/ConfirmModal.js +2 -1
  64. package/lib/cjs/modal/Modal.js +6 -2
  65. package/lib/cjs/modal/ModalContent.js +13 -6
  66. package/lib/cjs/notification/notice.js +6 -3
  67. package/lib/cjs/pagination/index.js +4 -2
  68. package/lib/cjs/popconfirm/index.js +6 -3
  69. package/lib/cjs/radio/radio.d.ts +1 -1
  70. package/lib/cjs/radio/radio.js +4 -2
  71. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  72. package/lib/cjs/rating/item.js +2 -1
  73. package/lib/cjs/scrollList/index.js +6 -3
  74. package/lib/cjs/select/index.js +9 -5
  75. package/lib/cjs/select/option.js +2 -1
  76. package/lib/cjs/sideSheet/SideSheetContent.js +6 -3
  77. package/lib/cjs/skeleton/index.js +3 -1
  78. package/lib/cjs/slider/index.js +9 -5
  79. package/lib/cjs/space/index.js +2 -1
  80. package/lib/cjs/spin/index.js +7 -3
  81. package/lib/cjs/switch/index.js +6 -4
  82. package/lib/cjs/table/Table.d.ts +1 -1
  83. package/lib/cjs/table/Table.js +6 -3
  84. package/lib/cjs/tabs/TabBar.d.ts +1 -0
  85. package/lib/cjs/tabs/TabBar.js +10 -2
  86. package/lib/cjs/tabs/TabPane.js +7 -3
  87. package/lib/cjs/tabs/index.js +2 -1
  88. package/lib/cjs/tabs/interface.d.ts +1 -0
  89. package/lib/cjs/tag/index.d.ts +2 -0
  90. package/lib/cjs/tag/index.js +60 -11
  91. package/lib/cjs/tag/interface.d.ts +1 -0
  92. package/lib/cjs/tagInput/index.js +7 -4
  93. package/lib/cjs/timePicker/Combobox.js +3 -1
  94. package/lib/cjs/toast/toast.js +6 -3
  95. package/lib/cjs/transfer/index.js +2 -1
  96. package/lib/cjs/tree/treeNode.js +2 -1
  97. package/lib/cjs/treeSelect/index.js +9 -6
  98. package/lib/cjs/typography/base.js +2 -1
  99. package/lib/cjs/typography/title.d.ts +1 -1
  100. package/lib/cjs/upload/index.d.ts +1 -1
  101. package/lib/cjs/upload/index.js +13 -6
  102. package/lib/es/avatar/index.js +4 -2
  103. package/lib/es/backtop/index.js +2 -1
  104. package/lib/es/badge/index.js +2 -1
  105. package/lib/es/banner/index.js +9 -4
  106. package/lib/es/breadcrumb/index.js +4 -3
  107. package/lib/es/button/Button.js +11 -3
  108. package/lib/es/card/index.js +10 -5
  109. package/lib/es/carousel/CarouselArrow.js +6 -2
  110. package/lib/es/carousel/index.js +2 -1
  111. package/lib/es/cascader/index.js +9 -6
  112. package/lib/es/cascader/item.js +2 -1
  113. package/lib/es/checkbox/checkbox.js +8 -4
  114. package/lib/es/collapsible/index.js +2 -1
  115. package/lib/es/datePicker/dateInput.d.ts +1 -1
  116. package/lib/es/datePicker/dateInput.js +2 -1
  117. package/lib/es/datePicker/datePicker.d.ts +1 -1
  118. package/lib/es/datePicker/datePicker.js +4 -2
  119. package/lib/es/datePicker/monthsGrid.d.ts +2 -2
  120. package/lib/es/divider/index.js +2 -1
  121. package/lib/es/dropdown/index.js +2 -1
  122. package/lib/es/empty/index.js +8 -4
  123. package/lib/es/form/baseForm.d.ts +1 -1
  124. package/lib/es/form/field.d.ts +1 -1
  125. package/lib/es/form/hoc/withField.js +2 -1
  126. package/lib/es/form/label.js +2 -1
  127. package/lib/es/grid/col.js +2 -1
  128. package/lib/es/grid/row.js +2 -1
  129. package/lib/es/iconButton/index.js +3 -1
  130. package/lib/es/input/index.js +9 -5
  131. package/lib/es/list/index.js +6 -3
  132. package/lib/es/modal/ConfirmModal.js +2 -1
  133. package/lib/es/modal/Modal.js +6 -2
  134. package/lib/es/modal/ModalContent.js +13 -6
  135. package/lib/es/notification/notice.js +6 -3
  136. package/lib/es/pagination/index.js +4 -2
  137. package/lib/es/popconfirm/index.js +6 -3
  138. package/lib/es/radio/radio.d.ts +1 -1
  139. package/lib/es/radio/radio.js +4 -2
  140. package/lib/es/radio/radioGroup.d.ts +1 -1
  141. package/lib/es/rating/item.js +2 -1
  142. package/lib/es/scrollList/index.js +6 -3
  143. package/lib/es/select/index.js +9 -5
  144. package/lib/es/select/option.js +2 -1
  145. package/lib/es/sideSheet/SideSheetContent.js +6 -3
  146. package/lib/es/skeleton/index.js +3 -1
  147. package/lib/es/slider/index.js +9 -5
  148. package/lib/es/space/index.js +2 -1
  149. package/lib/es/spin/index.js +7 -3
  150. package/lib/es/switch/index.js +6 -4
  151. package/lib/es/table/Table.d.ts +1 -1
  152. package/lib/es/table/Table.js +6 -3
  153. package/lib/es/tabs/TabBar.d.ts +1 -0
  154. package/lib/es/tabs/TabBar.js +10 -2
  155. package/lib/es/tabs/TabPane.js +7 -3
  156. package/lib/es/tabs/index.js +2 -1
  157. package/lib/es/tabs/interface.d.ts +1 -0
  158. package/lib/es/tag/index.d.ts +2 -0
  159. package/lib/es/tag/index.js +56 -9
  160. package/lib/es/tag/interface.d.ts +1 -0
  161. package/lib/es/tagInput/index.js +7 -4
  162. package/lib/es/timePicker/Combobox.js +3 -1
  163. package/lib/es/toast/toast.js +6 -3
  164. package/lib/es/transfer/index.js +2 -1
  165. package/lib/es/tree/treeNode.js +2 -1
  166. package/lib/es/treeSelect/index.js +8 -5
  167. package/lib/es/typography/base.js +2 -1
  168. package/lib/es/typography/title.d.ts +1 -1
  169. package/lib/es/upload/index.d.ts +1 -1
  170. package/lib/es/upload/index.js +13 -6
  171. package/list/index.tsx +16 -4
  172. package/modal/ConfirmModal.tsx +1 -1
  173. package/modal/Modal.tsx +2 -0
  174. package/modal/ModalContent.tsx +33 -21
  175. package/notification/notice.tsx +16 -4
  176. package/package.json +9 -9
  177. package/pagination/index.tsx +16 -2
  178. package/popconfirm/index.tsx +11 -3
  179. package/radio/radio.tsx +10 -2
  180. package/rating/item.tsx +1 -1
  181. package/scrollList/index.tsx +19 -3
  182. package/select/index.tsx +13 -6
  183. package/select/option.tsx +5 -1
  184. package/sideSheet/SideSheetContent.tsx +3 -3
  185. package/skeleton/index.tsx +1 -1
  186. package/slider/index.tsx +5 -3
  187. package/space/index.tsx +1 -1
  188. package/spin/index.tsx +15 -9
  189. package/switch/index.tsx +9 -14
  190. package/table/Table.tsx +5 -3
  191. package/table/_story/v2/index.js +2 -1
  192. package/table/_story/v2/radioRowSelection.tsx +107 -0
  193. package/tabs/TabBar.tsx +8 -1
  194. package/tabs/TabPane.tsx +10 -4
  195. package/tabs/index.tsx +2 -1
  196. package/tabs/interface.ts +1 -0
  197. package/tag/index.tsx +32 -2
  198. package/tag/interface.ts +1 -0
  199. package/tagInput/index.tsx +3 -2
  200. package/timePicker/Combobox.tsx +6 -1
  201. package/toast/toast.tsx +3 -3
  202. package/transfer/index.tsx +1 -0
  203. package/tree/treeNode.tsx +1 -1
  204. package/treeSelect/index.tsx +16 -4
  205. package/typography/base.tsx +1 -1
  206. package/upload/index.tsx +107 -38
@@ -216,7 +216,14 @@ export default class Pagination extends BaseComponent<PaginationProps, Paginatio
216
216
  [`${prefixCls}-item-disabled`]: prevDisabled,
217
217
  });
218
218
  return (
219
- <li role="button" aria-disabled={prevDisabled ? true : false} aria-label="Previous" onClick={e => !prevDisabled && this.foundation.goPrev(e)} className={preClassName}>
219
+ <li
220
+ role="button"
221
+ aria-disabled={prevDisabled ? true : false}
222
+ aria-label="Previous"
223
+ onClick={e => !prevDisabled && this.foundation.goPrev(e)}
224
+ className={preClassName}
225
+ x-semi-prop="prevText"
226
+ >
220
227
  {prevText || <IconChevronLeft size="large" />}
221
228
  </li>
222
229
  );
@@ -231,7 +238,14 @@ export default class Pagination extends BaseComponent<PaginationProps, Paginatio
231
238
  [`${prefixCls}-next`]: true,
232
239
  });
233
240
  return (
234
- <li role="button" aria-disabled={nextDisabled ? true : false} aria-label="Next" onClick={e => !nextDisabled && this.foundation.goNext(e)} className={nextClassName}>
241
+ <li
242
+ role="button"
243
+ aria-disabled={nextDisabled ? true : false}
244
+ aria-label="Next"
245
+ onClick={e => !nextDisabled && this.foundation.goNext(e)}
246
+ className={nextClassName}
247
+ x-semi-prop="prevText"
248
+ >
235
249
  {nextText || <IconChevronRight size="large" />}
236
250
  </li>
237
251
  );
@@ -174,12 +174,20 @@ export default class Popconfirm extends BaseComponent<PopconfirmProps, Popconfir
174
174
  <div className={popCardCls} onClick={this.stopImmediatePropagation} style={style}>
175
175
  <div className={`${prefixCls}-inner`}>
176
176
  <div className={`${prefixCls}-header`}>
177
- <i className={`${prefixCls}-header-icon`}>
177
+ <i className={`${prefixCls}-header-icon`} x-semi-prop="icon">
178
178
  {React.isValidElement(icon) ? icon : null}
179
179
  </i>
180
180
  <div className={`${prefixCls}-header-body`}>
181
- {showTitle ? <div className={`${prefixCls}-header-title`}>{title}</div> : null}
182
- {showContent ? <div className={`${prefixCls}-header-content`}>{content}</div> : null}
181
+ {showTitle ? (
182
+ <div className={`${prefixCls}-header-title`} x-semi-prop="title">
183
+ {title}
184
+ </div>
185
+ ) : null}
186
+ {showContent ? (
187
+ <div className={`${prefixCls}-header-content`} x-semi-prop="content">
188
+ {content}
189
+ </div>
190
+ ) : null}
183
191
  </div>
184
192
  <Button
185
193
  className={`${prefixCls}-btn-close`}
package/radio/radio.tsx CHANGED
@@ -228,8 +228,16 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
228
228
  }, addonClassName);
229
229
  const renderContent = () => (
230
230
  <>
231
- {children ? <span className={addonCls} style={addonStyle} id={addonId}>{children}</span> : null}
232
- {extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={extraId}>{extra}</div> : null}
231
+ {children ? (
232
+ <span className={addonCls} style={addonStyle} id={this.addonId} x-semi-prop="children">
233
+ {children}
234
+ </span>
235
+ ) : null}
236
+ {extra && !isButtonRadio ? (
237
+ <div className={`${prefix}-extra`} id={this.extraId} x-semi-prop="extra">
238
+ {extra}
239
+ </div>
240
+ ) : null}
233
241
  </>
234
242
  );
235
243
  return (
package/rating/item.tsx CHANGED
@@ -110,7 +110,7 @@ export default class Item extends PureComponent<RatingItemProps> {
110
110
  className={`${prefixCls}-wrapper`}
111
111
  >
112
112
  <div className={`${prefixCls}-first`} style={{ width: `${firstWidth * 100}%` }}>{content}</div>
113
- <div className={`${prefixCls}-second`}>{content}</div>
113
+ <div className={`${prefixCls}-second`} x-semi-prop="character">{content}</div>
114
114
  </div>
115
115
  </li>
116
116
  );
@@ -49,14 +49,30 @@ class ScrollList extends BaseComponent<ScrollListProps, {}> {
49
49
  <div className={clsWrapper} style={style}>
50
50
  {header ? (
51
51
  <div className={clsHeader}>
52
- <div className={`${clsHeader}-title`}>{header}</div>
52
+ <div
53
+ className={`${clsHeader}-title`}
54
+ x-semi-prop={this.props['x-semi-header-alias'] || "header"}
55
+ >
56
+ {header}
57
+ </div>
53
58
  <div className={`${clsWrapper}-line`} />
54
59
  </div>
55
60
  ) : null}
56
- <div className={`${clsWrapper}-body`} style={{ height: bodyHeight ? bodyHeight : '' }}>
61
+ <div
62
+ className={`${clsWrapper}-body`}
63
+ style={{ height: bodyHeight ? bodyHeight : '' }}
64
+ x-semi-prop="children"
65
+ >
57
66
  {children}
58
67
  </div>
59
- {footer ? <div className={`${clsWrapper}-footer`}>{footer}</div> : null}
68
+ {footer ? (
69
+ <div
70
+ className={`${clsWrapper}-footer`}
71
+ x-semi-prop={this.props['x-semi-footer-alias'] || "footer"}
72
+ >
73
+ {footer}
74
+ </div>
75
+ ) : null}
60
76
  </div>
61
77
  );
62
78
  }
package/select/index.tsx CHANGED
@@ -842,8 +842,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
842
842
  onScroll={e => this.foundation.handleListScroll(e)}
843
843
  >
844
844
  {innerTopSlot}
845
- {!loading ? listContent : this.renderLoading()}
846
- {isEmpty && !loading ? this.renderEmpty() : null}
845
+ {loading ? this.renderLoading() : isEmpty ? this.renderEmpty() : listContent}
847
846
  {innerBottomSlot}
848
847
  </div>
849
848
  {outerBottomSlot}
@@ -879,7 +878,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
879
878
  return (
880
879
  <>
881
880
  <div className={contentWrapperCls}>
882
- {<span className={spanCls}>{renderText || renderText === 0 ? renderText : placeholder}</span>}
881
+ {
882
+ <span className={spanCls} x-semi-prop="placeholder">
883
+ {renderText || renderText === 0 ? renderText : placeholder}
884
+ </span>
885
+ }
883
886
  {filterable && showInput ? this.renderInput() : null}
884
887
  </div>
885
888
  </>
@@ -1007,7 +1010,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
1007
1010
  [`${prefixcls}-suffix-text`]: suffix && isString(suffix),
1008
1011
  [`${prefixcls}-suffix-icon`]: isSemiIcon(suffix),
1009
1012
  });
1010
- return <div className={suffixWrapperCls}>{suffix}</div>;
1013
+ return <div className={suffixWrapperCls} x-semi-prop="suffix">{suffix}</div>;
1011
1014
  }
1012
1015
 
1013
1016
  renderPrefix() {
@@ -1021,7 +1024,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
1021
1024
  [`${prefixcls}-prefix-icon`]: isSemiIcon(labelNode),
1022
1025
  });
1023
1026
 
1024
- return <div className={prefixWrapperCls} id={insetLabelId}>{labelNode}</div>;
1027
+ return (
1028
+ <div className={prefixWrapperCls} id={insetLabelId} x-semi-prop="prefix,insetLabel">
1029
+ {labelNode}
1030
+ </div>
1031
+ );
1025
1032
  }
1026
1033
 
1027
1034
  renderSelection() {
@@ -1068,7 +1075,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
1068
1075
  (selections.size || inputValue) && !disabled && (isHovering || isOpen);
1069
1076
 
1070
1077
  const arrowContent = showArrow ? (
1071
- <div className={`${prefixcls}-arrow`}>
1078
+ <div className={`${prefixcls}-arrow`} x-semi-prop="arrowIcon">
1072
1079
  {arrowIcon}
1073
1080
  </div>
1074
1081
  ) : (
package/select/option.tsx CHANGED
@@ -105,7 +105,11 @@ class Option extends PureComponent<OptionProps> {
105
105
  }
106
106
  return (
107
107
  <LocaleConsumer<Locale['Select']> componentName="Select">
108
- {(locale: Locale['Select']) => <div className={optionClassName}>{emptyContent || locale.emptyText}</div>}
108
+ {(locale: Locale['Select']) => (
109
+ <div className={optionClassName} x-semi-prop="emptyContent">
110
+ {emptyContent || locale.emptyText}
111
+ </div>
112
+ )}
109
113
  </LocaleConsumer>
110
114
  );
111
115
  }
@@ -88,7 +88,7 @@ export default class SideSheetContent extends React.PureComponent<SideSheetConte
88
88
  let header, closer;
89
89
  if (title) {
90
90
  header = (
91
- <div className={`${prefixCls}-title`}>
91
+ <div className={`${prefixCls}-title`} x-semi-prop="title">
92
92
  {this.props.title}
93
93
  </div>
94
94
  );
@@ -140,11 +140,11 @@ export default class SideSheetContent extends React.PureComponent<SideSheetConte
140
140
  >
141
141
  <div className={`${prefixCls}-content`}>
142
142
  {header}
143
- <div className={`${prefixCls}-body`} style={props.bodyStyle}>
143
+ <div className={`${prefixCls}-body`} style={props.bodyStyle} x-semi-prop="children">
144
144
  {props.children}
145
145
  </div>
146
146
  {props.footer ? (
147
- <div className={`${prefixCls}-footer`}>
147
+ <div className={`${prefixCls}-footer`} x-semi-prop="footer">
148
148
  {props.footer}
149
149
  </div>
150
150
  ) : null}
@@ -48,7 +48,7 @@ class Skeleton extends PureComponent<SkeletonProps> {
48
48
  let content;
49
49
  if (loading) {
50
50
  content = (
51
- <div className={skCls} style={style} {...others}>
51
+ <div className={skCls} style={style} {...others} x-semi-prop="placeholder">
52
52
  {placeholder}
53
53
  </div>
54
54
  );
package/slider/index.tsx CHANGED
@@ -479,7 +479,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
479
479
  };
480
480
  trackStyle = included ? trackStyle : {};
481
481
  return (// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
482
- <div className={cssClasses.TRACK} style={trackStyle} onClick={e => this.foundation.handleWrapClick(e)}>
482
+ <div className={cssClasses.TRACK} style={trackStyle} onClick={this.foundation.handleWrapClick}>
483
483
  {/* {this.renderTrack} */}
484
484
  </div>
485
485
  );
@@ -501,7 +501,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
501
501
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
502
502
  <span
503
503
  key={mark}
504
- onClick={e => this.foundation.handleWrapClick(e)}
504
+ onClick={this.foundation.handleWrapClick}
505
505
  className={markClass}
506
506
  style={{ [stylePos]: `calc(${markPercent * 100}% - 2px)` }}
507
507
  />
@@ -522,10 +522,12 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
522
522
  const activeResult = this.foundation.isMarkActive(Number(mark));
523
523
  const markPercent = (Number(mark) - min) / (max - min);
524
524
  return activeResult ? (
525
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
525
526
  <span
526
527
  key={mark}
527
528
  className={cls(`${prefixCls}-mark${(vertical && verticalReverse) ? '-reverse' : ''}`)}
528
529
  style={{ [stylePos]: `${markPercent * 100}%` }}
530
+ onClick={this.foundation.handleWrapClick}
529
531
  >
530
532
  {marks[mark]}
531
533
  </span>
@@ -565,7 +567,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
565
567
  {// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
566
568
  <div
567
569
  className={`${prefixCls}-rail`}
568
- onClick={e => this.foundation.handleWrapClick(e)}
570
+ onClick={this.foundation.handleWrapClick}
569
571
  style={this.props.railStyle}
570
572
  />
571
573
  }
package/space/index.tsx CHANGED
@@ -85,7 +85,7 @@ class Space extends PureComponent<SpaceProps> {
85
85
  });
86
86
  const childrenNodes = flatten(children);
87
87
  return (
88
- <div className={classNames} style={realStyle}>
88
+ <div className={classNames} style={realStyle} x-semi-prop="children">
89
89
  {childrenNodes}
90
90
  </div>
91
91
  );
package/spin/index.tsx CHANGED
@@ -95,14 +95,18 @@ class Spin extends BaseComponent<SpinProps, SpinState> {
95
95
  [`${prefixCls}-animate`]: loading,
96
96
  });
97
97
 
98
- return (
99
- loading ? (
100
- <div className={`${prefixCls}-wrapper`}>
101
- {indicator ? <div className={spinIconCls}>{indicator}</div> : <SpinIcon />}
102
- {tip ? <div>{tip}</div> : null}
103
- </div>
104
- ) : null
105
- );
98
+ return loading ? (
99
+ <div className={`${prefixCls}-wrapper`}>
100
+ {indicator ? (
101
+ <div className={spinIconCls} x-semi-prop="indicator">
102
+ {indicator}
103
+ </div>
104
+ ) : (
105
+ <SpinIcon />
106
+ )}
107
+ {tip ? <div x-semi-prop="tip">{tip}</div> : null}
108
+ </div>
109
+ ) : null;
106
110
  }
107
111
 
108
112
  render() {
@@ -122,7 +126,9 @@ class Spin extends BaseComponent<SpinProps, SpinState> {
122
126
  return (
123
127
  <div className={spinCls} style={style}>
124
128
  {this.renderSpin()}
125
- <div className={`${prefixCls}-children`} style={childStyle}>{children}</div>
129
+ <div className={`${prefixCls}-children`} style={childStyle} x-semi-prop="children">
130
+ {children}
131
+ </div>
126
132
  </div>
127
133
  );
128
134
  }
package/switch/index.tsx CHANGED
@@ -146,23 +146,18 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
146
146
  const showUncheckedText = uncheckedText && !nativeControlChecked && size !== 'small';
147
147
  return (
148
148
  <div className={wrapperCls} style={style} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
149
- {
150
- loading
151
- ? (
152
- <Spin
153
- wrapperClassName={cssClasses.LOADING_SPIN}
154
- size={size === 'default' ? 'middle' : size}
155
- />
156
- )
157
- : <div className={cssClasses.KNOB} aria-hidden={true} />
158
- }
149
+ {loading ? (
150
+ <Spin wrapperClassName={cssClasses.LOADING_SPIN} size={size === 'default' ? 'middle' : size} />
151
+ ) : (
152
+ <div className={cssClasses.KNOB} aria-hidden={true} />
153
+ )}
159
154
  {showCheckedText ? (
160
- <div className={cssClasses.CHECKED_TEXT}>
155
+ <div className={cssClasses.CHECKED_TEXT} x-semi-prop="checkedText">
161
156
  {checkedText}
162
157
  </div>
163
158
  ) : null}
164
159
  {showUncheckedText ? (
165
- <div className={cssClasses.UNCHECKED_TEXT}>
160
+ <div className={cssClasses.UNCHECKED_TEXT} x-semi-prop="uncheckedText">
166
161
  {uncheckedText}
167
162
  </div>
168
163
  ) : null}
@@ -170,13 +165,13 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
170
165
  {...switchProps}
171
166
  ref={this.switchRef}
172
167
  id={id}
173
- role='switch'
168
+ role="switch"
174
169
  aria-checked={nativeControlChecked}
175
170
  aria-invalid={this.props['aria-invalid']}
176
171
  aria-errormessage={this.props['aria-errormessage']}
177
172
  aria-label={this.props['aria-label']}
178
173
  aria-labelledby={this.props['aria-labelledby']}
179
- aria-describedby={this.props["aria-describedby"]}
174
+ aria-describedby={this.props['aria-describedby']}
180
175
  aria-disabled={this.props['disabled']}
181
176
  onChange={e => this.foundation.handleChange(e.target.checked, e)}
182
177
  onFocus={e => this.handleFocusVisible(e)}
package/table/Table.tsx CHANGED
@@ -1015,7 +1015,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
1015
1015
  }
1016
1016
 
1017
1017
  return isValidElement(title) || typeof title === 'string' ? (
1018
- <div className={`${prefixCls}-title`}>{title}</div>
1018
+ <div className={`${prefixCls}-title`} x-semi-prop="title">{title}</div>
1019
1019
  ) : null;
1020
1020
  };
1021
1021
 
@@ -1032,7 +1032,9 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
1032
1032
  <LocaleConsumer componentName="Table" key={'emptyText'}>
1033
1033
  {(locale: TableLocale, localeCode: string) => (
1034
1034
  <div className={wrapCls}>
1035
- <div className={`${prefixCls}-empty`}>{empty || locale.emptyText}</div>
1035
+ <div className={`${prefixCls}-empty`} x-semi-prop="empty">
1036
+ {empty || locale.emptyText}
1037
+ </div>
1036
1038
  </div>
1037
1039
  )}
1038
1040
  </LocaleConsumer>
@@ -1048,7 +1050,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
1048
1050
  }
1049
1051
 
1050
1052
  return isValidElement(footer) || typeof footer === 'string' ? (
1051
- <div className={`${prefixCls}-footer`} key="footer">
1053
+ <div className={`${prefixCls}-footer`} key="footer" x-semi-prop="footer">
1052
1054
  {footer}
1053
1055
  </div>
1054
1056
  ) : null;
@@ -5,4 +5,5 @@ export { default as FixedHeaderMerge } from './FixedHeaderMerge';
5
5
  export { default as FixedResizable } from './FixedResizable';
6
6
  export { default as FixedExpandedRow } from './FixedExpandedRow';
7
7
  export { default as FixedMemoryLeak } from './FixedMemoryLeak';
8
- export { default as FixedOnHeaderRow } from './FixedOnHeaderRow';
8
+ export { default as FixedOnHeaderRow } from './FixedOnHeaderRow';
9
+ export { default as RadioRowSelection } from './radioRowSelection';
@@ -0,0 +1,107 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import { Table, Avatar, Radio } from '@douyinfe/semi-ui';
3
+ import { IconMore } from '@douyinfe/semi-icons';
4
+
5
+ App.storyName = '行选择 - 单选';
6
+ export default function App() {
7
+ const [selectedRowKey, setSelectedRowKey] = useState();
8
+ const columns = [
9
+ {
10
+ title: '',
11
+ dataIndex: 'selection',
12
+ width: 20,
13
+ render: (text, record, index) => {
14
+ return (
15
+ <Radio checked={selectedRowKey === record.key} onChange={() => setSelectedRowKey(record.key)} />
16
+ );
17
+ },
18
+ },
19
+ {
20
+ title: '标题',
21
+ dataIndex: 'name',
22
+ width: 400,
23
+ render: (text, record, index) => {
24
+ return (
25
+ <div>
26
+ <Avatar
27
+ size="small"
28
+ shape="square"
29
+ src={record.nameIconSrc}
30
+ style={{ marginRight: 12 }}
31
+ ></Avatar>
32
+ {text}
33
+ </div>
34
+ );
35
+ },
36
+ },
37
+ {
38
+ title: '大小',
39
+ dataIndex: 'size',
40
+ },
41
+ {
42
+ title: '所有者',
43
+ dataIndex: 'owner',
44
+ render: (text, record, index) => {
45
+ return (
46
+ <div>
47
+ <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>
48
+ {typeof text === 'string' && text.slice(0, 1)}
49
+ </Avatar>
50
+ {text}
51
+ </div>
52
+ );
53
+ },
54
+ },
55
+ {
56
+ title: '更新日期',
57
+ dataIndex: 'updateTime',
58
+ },
59
+ {
60
+ title: '',
61
+ dataIndex: 'operate',
62
+ render: () => {
63
+ return <IconMore />;
64
+ },
65
+ },
66
+ ];
67
+ const data = useMemo(() => ([
68
+ {
69
+ key: '1',
70
+ name: 'Semi Design 设计稿.fig',
71
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png',
72
+ size: '2M',
73
+ owner: '姜鹏志',
74
+ updateTime: '2020-02-02 05:13',
75
+ avatarBg: 'grey',
76
+ },
77
+ {
78
+ key: '2',
79
+ name: 'Semi Design 分享演示文稿',
80
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
81
+ size: '2M',
82
+ owner: '郝宣',
83
+ updateTime: '2020-01-17 05:31',
84
+ avatarBg: 'red',
85
+ },
86
+ {
87
+ key: '3',
88
+ name: '设计文档',
89
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
90
+ size: '34KB',
91
+ owner: 'Zoey Edwards',
92
+ updateTime: '2020-01-26 11:01',
93
+ avatarBg: 'light-blue',
94
+ },
95
+ {
96
+ key: '4',
97
+ name: 'Semi Pro 设计稿.fig',
98
+ nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png',
99
+ size: '2M',
100
+ owner: '姜鹏志',
101
+ updateTime: '2020-02-02 05:13',
102
+ avatarBg: 'grey',
103
+ }
104
+ ]), []);
105
+
106
+ return <Table columns={columns} dataSource={data} pagination={{ pageSize: 3 }} />;
107
+ }
package/tabs/TabBar.tsx CHANGED
@@ -70,7 +70,7 @@ class TabBar extends React.Component<TabBarProps, TabBarState> {
70
70
  if (tabBarExtraContent) {
71
71
  const tabBarStyle = { ...tabBarExtraContentDefaultStyle, ...tabBarExtraContentStyle };
72
72
  return (
73
- <div className={extraCls} style={tabBarStyle}>
73
+ <div className={extraCls} style={tabBarStyle} x-semi-prop="tabBarExtraContent">
74
74
  {tabBarExtraContent}
75
75
  </div>
76
76
  );
@@ -88,6 +88,10 @@ class TabBar extends React.Component<TabBarProps, TabBarState> {
88
88
  }
89
89
  };
90
90
 
91
+ handleKeyDown = (event: React.KeyboardEvent, itemKey: string, closable: boolean) => {
92
+ this.props.handleKeyDown(event, itemKey, closable);
93
+ }
94
+
91
95
  renderTabItem = (panel: PlainTab): ReactNode => {
92
96
  const { size, type, deleteTabItem } = this.props;
93
97
  const panelIcon = panel.icon ? this.renderIcon(panel.icon) : null;
@@ -110,9 +114,12 @@ class TabBar extends React.Component<TabBarProps, TabBarState> {
110
114
  <div
111
115
  role="tab"
112
116
  id={`semiTab${key}`}
117
+ data-tabkey={`semiTab${key}`}
113
118
  aria-controls={`semiTabPanel${key}`}
114
119
  aria-disabled={panel.disabled ? 'true' : 'false'}
115
120
  aria-selected={isSelected ? 'true' : 'false'}
121
+ tabIndex={isSelected ? 0 : -1}
122
+ onKeyDown={e => this.handleKeyDown(e, key, panel.closable)}
116
123
  {...events}
117
124
  className={className}
118
125
  key={this._getItemKey(key)}
package/tabs/TabPane.tsx CHANGED
@@ -96,7 +96,9 @@ class TabPane extends PureComponent<TabPaneProps> {
96
96
  className={classNames}
97
97
  style={style}
98
98
  aria-hidden={active ? 'false' : 'true'}
99
+ tabIndex={0}
99
100
  {...getDataAttr(restProps)}
101
+ x-semi-prop="children"
100
102
  >
101
103
  {motion ? (
102
104
  <TabPaneTransition
@@ -106,14 +108,18 @@ class TabPane extends PureComponent<TabPaneProps> {
106
108
  state={active ? 'enter' : 'leave'}
107
109
  >
108
110
  {(transitionStyle): ReactNode => (
109
- <div className={`${cssClasses.TABS_PANE_MOTION_OVERLAY}`} style={{ ...transitionStyle }}>
111
+ <div
112
+ className={`${cssClasses.TABS_PANE_MOTION_OVERLAY}`}
113
+ style={{ ...transitionStyle }}
114
+ x-semi-prop="children"
115
+ >
110
116
  {shouldRender ? children : null}
111
117
  </div>
112
118
  )}
113
119
  </TabPaneTransition>
114
- ) : (
115
- shouldRender ? children : null
116
- )}
120
+ ) : shouldRender ? (
121
+ children
122
+ ) : null}
117
123
  </div>
118
124
  );
119
125
  }
package/tabs/index.tsx CHANGED
@@ -266,7 +266,8 @@ class Tabs extends BaseComponent<TabsProps, TabsState> {
266
266
  tabBarExtraContent,
267
267
  tabPosition,
268
268
  type,
269
- deleteTabItem: this.deleteTabItem
269
+ deleteTabItem: this.deleteTabItem,
270
+ handleKeyDown: this.foundation.handleKeyDown
270
271
  } as TabBarProps;
271
272
 
272
273
  const tabBar = renderTabBar ? renderTabBar(tabBarProps, TabBar) : <TabBar {...tabBarProps} />;
package/tabs/interface.ts CHANGED
@@ -53,6 +53,7 @@ export interface TabBarProps {
53
53
  dropdownStyle?: CSSProperties;
54
54
  closable?: boolean;
55
55
  deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
56
+ handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
56
57
  }
57
58
 
58
59
  export interface TabPaneProps {