@douyinfe/semi-ui 2.2.0 → 2.3.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 (439) hide show
  1. package/_base/_story/a11y.jsx +6 -6
  2. package/_base/_story/a11y.scss +0 -1
  3. package/_base/_story/index.scss +2 -5
  4. package/_utils/hooks/usePrevFocus.ts +16 -0
  5. package/_utils/index.ts +4 -0
  6. package/anchor/_story/anchor.stories.js +1 -1
  7. package/anchor/index.tsx +5 -2
  8. package/anchor/link.tsx +29 -4
  9. package/autoComplete/index.tsx +28 -1
  10. package/avatar/_story/avatar.stories.js +4 -4
  11. package/avatar/index.tsx +6 -4
  12. package/banner/index.tsx +2 -1
  13. package/breadcrumb/_story/breadcrumb.stories.js +22 -8
  14. package/breadcrumb/index.tsx +8 -1
  15. package/breadcrumb/item.tsx +1 -1
  16. package/button/Button.tsx +4 -0
  17. package/button/__test__/button.test.js +1 -1
  18. package/button/_story/button.stories.js +10 -10
  19. package/button/buttonGroup.tsx +4 -2
  20. package/button/splitButtonGroup.tsx +5 -2
  21. package/card/_story/card.stories.js +8 -1
  22. package/card/_story/card.stories.tsx +3 -0
  23. package/card/index.tsx +5 -2
  24. package/cascader/index.tsx +33 -5
  25. package/checkbox/_story/checkbox.stories.js +19 -12
  26. package/checkbox/checkbox.tsx +40 -5
  27. package/checkbox/checkboxGroup.tsx +30 -5
  28. package/checkbox/checkboxInner.tsx +25 -2
  29. package/collapse/index.tsx +1 -1
  30. package/collapse/item.tsx +12 -7
  31. package/collapsible/index.tsx +4 -2
  32. package/configProvider/_story/configProvider.stories.tsx +27 -0
  33. package/datePicker/__test__/datePicker.test.js +108 -0
  34. package/datePicker/_story/datePicker.stories.js +146 -2
  35. package/datePicker/datePicker.tsx +24 -0
  36. package/datePicker/monthsGrid.tsx +2 -1
  37. package/dist/css/semi.css +34 -7
  38. package/dist/css/semi.min.css +1 -1
  39. package/dist/umd/semi-ui.js +2768 -1501
  40. package/dist/umd/semi-ui.js.map +1 -1
  41. package/dist/umd/semi-ui.min.js +1 -1
  42. package/dist/umd/semi-ui.min.js.map +1 -1
  43. package/dropdown/dropdownItem.tsx +1 -1
  44. package/dropdown/dropdownMenu.tsx +1 -1
  45. package/empty/index.tsx +4 -4
  46. package/form/_story/FormApi/formApiDemo.jsx +3 -2
  47. package/form/_story/Validate/validateDemo.jsx +1 -1
  48. package/form/_story/demo.jsx +12 -3
  49. package/form/_story/form.stories.js +0 -7
  50. package/form/baseForm.tsx +2 -0
  51. package/form/errorMessage.tsx +13 -2
  52. package/form/hoc/withField.tsx +37 -8
  53. package/form/index.tsx +0 -2
  54. package/form/interface.ts +2 -0
  55. package/form/label.tsx +4 -2
  56. package/input/index.tsx +49 -4
  57. package/input/inputGroup.tsx +9 -4
  58. package/input/textarea.tsx +25 -6
  59. package/inputNumber/_story/inputNumber.stories.js +12 -0
  60. package/inputNumber/index.tsx +33 -2
  61. package/layout/Sider.tsx +6 -2
  62. package/layout/index.tsx +4 -3
  63. package/lib/cjs/_utils/hooks/usePrevFocus.d.ts +2 -0
  64. package/lib/cjs/_utils/hooks/usePrevFocus.js +30 -0
  65. package/lib/cjs/_utils/index.d.ts +1 -0
  66. package/lib/cjs/_utils/index.js +6 -1
  67. package/lib/cjs/anchor/index.d.ts +2 -0
  68. package/lib/cjs/anchor/index.js +6 -1
  69. package/lib/cjs/anchor/link.d.ts +4 -1
  70. package/lib/cjs/anchor/link.js +39 -5
  71. package/lib/cjs/autoComplete/index.d.ts +17 -0
  72. package/lib/cjs/autoComplete/index.js +21 -2
  73. package/lib/cjs/avatar/index.d.ts +4 -3
  74. package/lib/cjs/avatar/index.js +15 -11
  75. package/lib/cjs/banner/index.js +4 -2
  76. package/lib/cjs/breadcrumb/index.d.ts +3 -0
  77. package/lib/cjs/breadcrumb/index.js +10 -4
  78. package/lib/cjs/breadcrumb/item.js +2 -2
  79. package/lib/cjs/button/Button.d.ts +2 -0
  80. package/lib/cjs/button/Button.js +4 -2
  81. package/lib/cjs/button/buttonGroup.d.ts +3 -0
  82. package/lib/cjs/button/buttonGroup.js +8 -4
  83. package/lib/cjs/button/index.d.ts +1 -0
  84. package/lib/cjs/button/splitButtonGroup.d.ts +3 -0
  85. package/lib/cjs/button/splitButtonGroup.js +5 -2
  86. package/lib/cjs/card/index.d.ts +3 -0
  87. package/lib/cjs/card/index.js +3 -1
  88. package/lib/cjs/cascader/index.d.ts +14 -0
  89. package/lib/cjs/cascader/index.js +35 -7
  90. package/lib/cjs/checkbox/checkbox.d.ts +21 -1
  91. package/lib/cjs/checkbox/checkbox.js +51 -17
  92. package/lib/cjs/checkbox/checkboxGroup.d.ts +13 -1
  93. package/lib/cjs/checkbox/checkboxGroup.js +16 -3
  94. package/lib/cjs/checkbox/checkboxInner.d.ts +15 -0
  95. package/lib/cjs/checkbox/checkboxInner.js +20 -3
  96. package/lib/cjs/collapse/item.d.ts +2 -1
  97. package/lib/cjs/collapse/item.js +12 -2
  98. package/lib/cjs/collapsible/index.d.ts +1 -0
  99. package/lib/cjs/collapsible/index.js +4 -2
  100. package/lib/cjs/datePicker/datePicker.d.ts +12 -0
  101. package/lib/cjs/datePicker/datePicker.js +22 -3
  102. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -0
  103. package/lib/cjs/datePicker/monthsGrid.js +2 -1
  104. package/lib/cjs/dropdown/dropdownItem.js +3 -1
  105. package/lib/cjs/dropdown/dropdownMenu.js +4 -1
  106. package/lib/cjs/form/baseForm.d.ts +9 -0
  107. package/lib/cjs/form/baseForm.js +3 -1
  108. package/lib/cjs/form/errorMessage.d.ts +4 -0
  109. package/lib/cjs/form/errorMessage.js +21 -3
  110. package/lib/cjs/form/field.d.ts +7 -0
  111. package/lib/cjs/form/hoc/withField.js +49 -16
  112. package/lib/cjs/form/index.d.ts +0 -1
  113. package/lib/cjs/form/interface.d.ts +2 -0
  114. package/lib/cjs/form/label.d.ts +2 -0
  115. package/lib/cjs/form/label.js +5 -2
  116. package/lib/cjs/input/index.d.ts +16 -0
  117. package/lib/cjs/input/index.js +51 -15
  118. package/lib/cjs/input/inputGroup.d.ts +2 -1
  119. package/lib/cjs/input/inputGroup.js +11 -1
  120. package/lib/cjs/input/textarea.js +12 -1
  121. package/lib/cjs/inputNumber/index.d.ts +21 -12
  122. package/lib/cjs/inputNumber/index.js +37 -3
  123. package/lib/cjs/layout/Sider.d.ts +4 -0
  124. package/lib/cjs/layout/Sider.js +4 -1
  125. package/lib/cjs/layout/index.js +2 -0
  126. package/lib/cjs/list/item.js +0 -1
  127. package/lib/cjs/modal/Modal.js +2 -0
  128. package/lib/cjs/modal/ModalContent.d.ts +3 -1
  129. package/lib/cjs/modal/ModalContent.js +47 -5
  130. package/lib/cjs/navigation/Item.d.ts +4 -2
  131. package/lib/cjs/navigation/Item.js +25 -5
  132. package/lib/cjs/navigation/SubNav.d.ts +4 -2
  133. package/lib/cjs/navigation/SubNav.js +8 -1
  134. package/lib/cjs/navigation/index.js +2 -0
  135. package/lib/cjs/notification/notice.d.ts +1 -1
  136. package/lib/cjs/notification/notice.js +32 -22
  137. package/lib/cjs/pagination/index.js +16 -6
  138. package/lib/cjs/popover/index.js +7 -3
  139. package/lib/cjs/progress/index.d.ts +8 -0
  140. package/lib/cjs/progress/index.js +42 -9
  141. package/lib/cjs/radio/radio.d.ts +6 -1
  142. package/lib/cjs/radio/radio.js +17 -5
  143. package/lib/cjs/radio/radioGroup.d.ts +16 -1
  144. package/lib/cjs/radio/radioGroup.js +18 -3
  145. package/lib/cjs/radio/radioInner.d.ts +6 -1
  146. package/lib/cjs/radio/radioInner.js +11 -3
  147. package/lib/cjs/rating/index.d.ts +14 -0
  148. package/lib/cjs/rating/index.js +14 -3
  149. package/lib/cjs/rating/item.d.ts +2 -0
  150. package/lib/cjs/rating/item.js +6 -1
  151. package/lib/cjs/select/index.d.ts +16 -0
  152. package/lib/cjs/select/index.js +65 -19
  153. package/lib/cjs/select/option.js +28 -22
  154. package/lib/cjs/sideSheet/SideSheetContent.d.ts +1 -0
  155. package/lib/cjs/sideSheet/SideSheetContent.js +4 -1
  156. package/lib/cjs/sideSheet/index.d.ts +1 -0
  157. package/lib/cjs/sideSheet/index.js +2 -1
  158. package/lib/cjs/slider/index.d.ts +2 -1
  159. package/lib/cjs/slider/index.js +64 -17
  160. package/lib/cjs/spin/icon.js +3 -4
  161. package/lib/cjs/steps/basicStep.d.ts +3 -0
  162. package/lib/cjs/steps/basicStep.js +23 -25
  163. package/lib/cjs/steps/basicSteps.d.ts +1 -0
  164. package/lib/cjs/steps/basicSteps.js +2 -1
  165. package/lib/cjs/steps/fillStep.d.ts +3 -0
  166. package/lib/cjs/steps/fillStep.js +19 -4
  167. package/lib/cjs/steps/fillSteps.d.ts +1 -0
  168. package/lib/cjs/steps/fillSteps.js +2 -1
  169. package/lib/cjs/steps/navStep.d.ts +3 -0
  170. package/lib/cjs/steps/navStep.js +22 -25
  171. package/lib/cjs/steps/navSteps.d.ts +1 -0
  172. package/lib/cjs/steps/navSteps.js +2 -1
  173. package/lib/cjs/switch/index.d.ts +12 -0
  174. package/lib/cjs/switch/index.js +19 -4
  175. package/lib/cjs/table/Body/BaseRow.js +35 -3
  176. package/lib/cjs/table/Body/index.js +9 -1
  177. package/lib/cjs/table/ColumnFilter.js +4 -0
  178. package/lib/cjs/table/ColumnSelection.d.ts +3 -0
  179. package/lib/cjs/table/ColumnSelection.js +6 -2
  180. package/lib/cjs/table/ColumnSorter.js +19 -3
  181. package/lib/cjs/table/CustomExpandIcon.js +7 -1
  182. package/lib/cjs/table/Table.d.ts +2 -0
  183. package/lib/cjs/table/Table.js +31 -15
  184. package/lib/cjs/table/TableCell.d.ts +2 -0
  185. package/lib/cjs/table/TableCell.js +6 -2
  186. package/lib/cjs/table/TableHeaderRow.js +8 -2
  187. package/lib/cjs/tabs/TabBar.js +11 -3
  188. package/lib/cjs/tabs/TabPane.js +3 -1
  189. package/lib/cjs/tabs/index.js +0 -1
  190. package/lib/cjs/tagInput/index.d.ts +4 -1
  191. package/lib/cjs/tagInput/index.js +29 -3
  192. package/lib/cjs/timePicker/TimePicker.d.ts +12 -0
  193. package/lib/cjs/timePicker/TimePicker.js +9 -1
  194. package/lib/cjs/timePicker/index.d.ts +6 -0
  195. package/lib/cjs/timeline/index.d.ts +1 -1
  196. package/lib/cjs/timeline/index.js +1 -0
  197. package/lib/cjs/timeline/item.js +4 -2
  198. package/lib/cjs/toast/toast.js +2 -0
  199. package/lib/cjs/tooltip/TriangleArrow.js +1 -0
  200. package/lib/cjs/tooltip/TriangleArrowVertical.js +1 -0
  201. package/lib/cjs/tooltip/index.d.ts +16 -12
  202. package/lib/cjs/tooltip/index.js +55 -39
  203. package/lib/cjs/transfer/index.d.ts +1 -1
  204. package/lib/cjs/transfer/index.js +35 -17
  205. package/lib/cjs/tree/index.d.ts +1 -0
  206. package/lib/cjs/tree/index.js +15 -6
  207. package/lib/cjs/tree/treeNode.d.ts +12 -4
  208. package/lib/cjs/tree/treeNode.js +44 -4
  209. package/lib/cjs/treeSelect/index.d.ts +16 -0
  210. package/lib/cjs/treeSelect/index.js +60 -12
  211. package/lib/cjs/typography/base.js +18 -7
  212. package/lib/cjs/typography/copyable.js +6 -1
  213. package/lib/cjs/upload/fileCard.js +26 -7
  214. package/lib/cjs/upload/index.js +19 -4
  215. package/lib/es/_utils/hooks/usePrevFocus.d.ts +2 -0
  216. package/lib/es/_utils/hooks/usePrevFocus.js +15 -0
  217. package/lib/es/_utils/index.d.ts +1 -0
  218. package/lib/es/_utils/index.js +4 -1
  219. package/lib/es/anchor/index.d.ts +2 -0
  220. package/lib/es/anchor/index.js +6 -1
  221. package/lib/es/anchor/link.d.ts +4 -1
  222. package/lib/es/anchor/link.js +38 -5
  223. package/lib/es/autoComplete/index.d.ts +17 -0
  224. package/lib/es/autoComplete/index.js +21 -2
  225. package/lib/es/avatar/index.d.ts +4 -3
  226. package/lib/es/avatar/index.js +15 -11
  227. package/lib/es/banner/index.js +4 -2
  228. package/lib/es/breadcrumb/index.d.ts +3 -0
  229. package/lib/es/breadcrumb/index.js +10 -4
  230. package/lib/es/breadcrumb/item.js +2 -2
  231. package/lib/es/button/Button.d.ts +2 -0
  232. package/lib/es/button/Button.js +4 -2
  233. package/lib/es/button/buttonGroup.d.ts +3 -0
  234. package/lib/es/button/buttonGroup.js +8 -4
  235. package/lib/es/button/index.d.ts +1 -0
  236. package/lib/es/button/splitButtonGroup.d.ts +3 -0
  237. package/lib/es/button/splitButtonGroup.js +5 -2
  238. package/lib/es/card/index.d.ts +3 -0
  239. package/lib/es/card/index.js +3 -1
  240. package/lib/es/cascader/index.d.ts +14 -0
  241. package/lib/es/cascader/index.js +35 -7
  242. package/lib/es/checkbox/checkbox.d.ts +21 -1
  243. package/lib/es/checkbox/checkbox.js +50 -17
  244. package/lib/es/checkbox/checkboxGroup.d.ts +13 -1
  245. package/lib/es/checkbox/checkboxGroup.js +18 -5
  246. package/lib/es/checkbox/checkboxInner.d.ts +15 -0
  247. package/lib/es/checkbox/checkboxInner.js +20 -3
  248. package/lib/es/collapse/item.d.ts +2 -1
  249. package/lib/es/collapse/item.js +11 -2
  250. package/lib/es/collapsible/index.d.ts +1 -0
  251. package/lib/es/collapsible/index.js +4 -2
  252. package/lib/es/datePicker/datePicker.d.ts +12 -0
  253. package/lib/es/datePicker/datePicker.js +22 -3
  254. package/lib/es/datePicker/monthsGrid.d.ts +1 -0
  255. package/lib/es/datePicker/monthsGrid.js +2 -1
  256. package/lib/es/dropdown/dropdownItem.js +3 -1
  257. package/lib/es/dropdown/dropdownMenu.js +4 -1
  258. package/lib/es/form/baseForm.d.ts +9 -0
  259. package/lib/es/form/baseForm.js +3 -1
  260. package/lib/es/form/errorMessage.d.ts +4 -0
  261. package/lib/es/form/errorMessage.js +21 -3
  262. package/lib/es/form/field.d.ts +7 -0
  263. package/lib/es/form/hoc/withField.js +48 -15
  264. package/lib/es/form/index.d.ts +0 -1
  265. package/lib/es/form/index.js +0 -1
  266. package/lib/es/form/interface.d.ts +2 -0
  267. package/lib/es/form/label.d.ts +2 -0
  268. package/lib/es/form/label.js +5 -2
  269. package/lib/es/input/index.d.ts +16 -0
  270. package/lib/es/input/index.js +51 -15
  271. package/lib/es/input/inputGroup.d.ts +2 -1
  272. package/lib/es/input/inputGroup.js +11 -1
  273. package/lib/es/input/textarea.js +12 -1
  274. package/lib/es/inputNumber/index.d.ts +21 -12
  275. package/lib/es/inputNumber/index.js +38 -3
  276. package/lib/es/layout/Sider.d.ts +4 -0
  277. package/lib/es/layout/Sider.js +4 -1
  278. package/lib/es/layout/index.js +2 -0
  279. package/lib/es/list/item.js +0 -1
  280. package/lib/es/modal/Modal.js +2 -0
  281. package/lib/es/modal/ModalContent.d.ts +3 -1
  282. package/lib/es/modal/ModalContent.js +46 -5
  283. package/lib/es/navigation/Item.d.ts +4 -2
  284. package/lib/es/navigation/Item.js +25 -5
  285. package/lib/es/navigation/SubNav.d.ts +4 -2
  286. package/lib/es/navigation/SubNav.js +8 -1
  287. package/lib/es/navigation/index.js +2 -0
  288. package/lib/es/notification/notice.d.ts +1 -1
  289. package/lib/es/notification/notice.js +33 -24
  290. package/lib/es/pagination/index.js +16 -6
  291. package/lib/es/popover/index.js +7 -3
  292. package/lib/es/progress/index.d.ts +8 -0
  293. package/lib/es/progress/index.js +42 -9
  294. package/lib/es/radio/radio.d.ts +6 -1
  295. package/lib/es/radio/radio.js +16 -5
  296. package/lib/es/radio/radioGroup.d.ts +16 -1
  297. package/lib/es/radio/radioGroup.js +18 -3
  298. package/lib/es/radio/radioInner.d.ts +6 -1
  299. package/lib/es/radio/radioInner.js +11 -3
  300. package/lib/es/rating/index.d.ts +14 -0
  301. package/lib/es/rating/index.js +14 -3
  302. package/lib/es/rating/item.d.ts +2 -0
  303. package/lib/es/rating/item.js +6 -1
  304. package/lib/es/select/index.d.ts +16 -0
  305. package/lib/es/select/index.js +63 -17
  306. package/lib/es/select/option.js +28 -22
  307. package/lib/es/sideSheet/SideSheetContent.d.ts +1 -0
  308. package/lib/es/sideSheet/SideSheetContent.js +4 -1
  309. package/lib/es/sideSheet/index.d.ts +1 -0
  310. package/lib/es/sideSheet/index.js +2 -1
  311. package/lib/es/slider/index.d.ts +2 -1
  312. package/lib/es/slider/index.js +63 -16
  313. package/lib/es/spin/icon.js +3 -4
  314. package/lib/es/steps/basicStep.d.ts +3 -0
  315. package/lib/es/steps/basicStep.js +23 -23
  316. package/lib/es/steps/basicSteps.d.ts +1 -0
  317. package/lib/es/steps/basicSteps.js +2 -1
  318. package/lib/es/steps/fillStep.d.ts +3 -0
  319. package/lib/es/steps/fillStep.js +19 -4
  320. package/lib/es/steps/fillSteps.d.ts +1 -0
  321. package/lib/es/steps/fillSteps.js +2 -1
  322. package/lib/es/steps/navStep.d.ts +3 -0
  323. package/lib/es/steps/navStep.js +22 -23
  324. package/lib/es/steps/navSteps.d.ts +1 -0
  325. package/lib/es/steps/navSteps.js +2 -1
  326. package/lib/es/switch/index.d.ts +12 -0
  327. package/lib/es/switch/index.js +19 -4
  328. package/lib/es/table/Body/BaseRow.js +35 -3
  329. package/lib/es/table/Body/index.js +9 -2
  330. package/lib/es/table/ColumnFilter.js +4 -0
  331. package/lib/es/table/ColumnSelection.d.ts +3 -0
  332. package/lib/es/table/ColumnSelection.js +6 -2
  333. package/lib/es/table/ColumnSorter.js +17 -3
  334. package/lib/es/table/CustomExpandIcon.js +6 -1
  335. package/lib/es/table/Table.d.ts +2 -0
  336. package/lib/es/table/Table.js +31 -15
  337. package/lib/es/table/TableCell.d.ts +2 -0
  338. package/lib/es/table/TableCell.js +6 -2
  339. package/lib/es/table/TableHeaderRow.js +8 -2
  340. package/lib/es/tabs/TabBar.js +11 -3
  341. package/lib/es/tabs/TabPane.js +3 -1
  342. package/lib/es/tabs/index.js +0 -1
  343. package/lib/es/tagInput/index.d.ts +4 -1
  344. package/lib/es/tagInput/index.js +29 -3
  345. package/lib/es/timePicker/TimePicker.d.ts +12 -0
  346. package/lib/es/timePicker/TimePicker.js +9 -1
  347. package/lib/es/timePicker/index.d.ts +6 -0
  348. package/lib/es/timeline/index.d.ts +1 -1
  349. package/lib/es/timeline/index.js +1 -0
  350. package/lib/es/timeline/item.js +4 -2
  351. package/lib/es/toast/toast.js +2 -0
  352. package/lib/es/tooltip/TriangleArrow.js +1 -0
  353. package/lib/es/tooltip/TriangleArrowVertical.js +1 -0
  354. package/lib/es/tooltip/index.d.ts +16 -12
  355. package/lib/es/tooltip/index.js +53 -39
  356. package/lib/es/transfer/index.d.ts +1 -1
  357. package/lib/es/transfer/index.js +35 -17
  358. package/lib/es/tree/index.d.ts +1 -0
  359. package/lib/es/tree/index.js +15 -6
  360. package/lib/es/tree/treeNode.d.ts +12 -4
  361. package/lib/es/tree/treeNode.js +44 -4
  362. package/lib/es/treeSelect/index.d.ts +16 -0
  363. package/lib/es/treeSelect/index.js +57 -10
  364. package/lib/es/typography/base.js +17 -7
  365. package/lib/es/typography/copyable.js +5 -1
  366. package/lib/es/upload/fileCard.js +26 -7
  367. package/lib/es/upload/index.js +19 -4
  368. package/list/item.tsx +0 -1
  369. package/modal/Modal.tsx +2 -0
  370. package/modal/ModalContent.tsx +35 -5
  371. package/navigation/Item.tsx +15 -0
  372. package/navigation/SubNav.tsx +13 -1
  373. package/navigation/index.tsx +1 -1
  374. package/notification/notice.tsx +19 -14
  375. package/package.json +8 -8
  376. package/pagination/index.tsx +9 -5
  377. package/popover/index.tsx +5 -0
  378. package/progress/_story/progress.stories.js +18 -18
  379. package/progress/index.tsx +58 -20
  380. package/radio/radio.tsx +12 -2
  381. package/radio/radioGroup.tsx +29 -3
  382. package/radio/radioInner.tsx +10 -1
  383. package/rating/index.tsx +19 -2
  384. package/rating/item.tsx +6 -0
  385. package/select/__test__/select.test.js +45 -0
  386. package/select/_story/select.stories.js +29 -0
  387. package/select/index.tsx +52 -4
  388. package/select/option.tsx +3 -0
  389. package/sideSheet/SideSheetContent.tsx +6 -4
  390. package/sideSheet/index.tsx +3 -2
  391. package/slider/__test__/slider.test.js +9 -0
  392. package/slider/_story/slider.stories.js +1 -1
  393. package/slider/index.tsx +44 -7
  394. package/spin/icon.tsx +4 -3
  395. package/steps/basicStep.tsx +15 -4
  396. package/steps/basicSteps.tsx +3 -2
  397. package/steps/fillStep.tsx +27 -12
  398. package/steps/fillSteps.tsx +2 -0
  399. package/steps/navStep.tsx +15 -4
  400. package/steps/navSteps.tsx +3 -2
  401. package/switch/_story/switch.stories.js +20 -19
  402. package/switch/_story/switch.stories.tsx +13 -13
  403. package/switch/index.tsx +23 -5
  404. package/table/Body/BaseRow.tsx +25 -1
  405. package/table/Body/index.tsx +7 -2
  406. package/table/ColumnFilter.tsx +7 -1
  407. package/table/ColumnSelection.tsx +4 -1
  408. package/table/ColumnSorter.tsx +18 -1
  409. package/table/CustomExpandIcon.tsx +5 -0
  410. package/table/Table.tsx +26 -13
  411. package/table/TableCell.tsx +11 -1
  412. package/table/TableHeaderRow.tsx +16 -2
  413. package/table/__test__/table.test.js +46 -0
  414. package/tabs/TabBar.tsx +8 -5
  415. package/tabs/TabPane.tsx +3 -1
  416. package/tabs/index.tsx +0 -1
  417. package/tagInput/__test__/tagInput.test.js +46 -0
  418. package/tagInput/_story/tagInput.stories.js +2 -2
  419. package/tagInput/index.tsx +31 -8
  420. package/timePicker/TimePicker.tsx +14 -1
  421. package/timeline/_story/timeline.stories.js +1 -1
  422. package/timeline/index.tsx +2 -2
  423. package/timeline/item.tsx +2 -1
  424. package/toast/toast.tsx +2 -0
  425. package/tooltip/TriangleArrow.tsx +1 -1
  426. package/tooltip/TriangleArrowVertical.tsx +1 -1
  427. package/tooltip/_story/tooltip.stories.js +562 -514
  428. package/tooltip/index.tsx +51 -33
  429. package/transfer/index.tsx +32 -28
  430. package/tree/_story/tree.stories.js +3 -3
  431. package/tree/index.tsx +10 -2
  432. package/tree/treeNode.tsx +46 -10
  433. package/treeSelect/__test__/treeMultiple.test.js +5 -0
  434. package/treeSelect/_story/treeSelect.stories.js +12 -0
  435. package/treeSelect/index.tsx +58 -7
  436. package/typography/base.tsx +7 -1
  437. package/typography/copyable.tsx +10 -1
  438. package/upload/fileCard.tsx +14 -16
  439. package/upload/index.tsx +10 -6
package/slider/index.tsx CHANGED
@@ -78,6 +78,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
78
78
  private dragging: boolean[];
79
79
  private eventListenerSet: Set<() => void>;
80
80
  private chooseMovePos: 'min' | 'max';
81
+ foundation: SliderFoundation;
81
82
 
82
83
  constructor(props: SliderProps) {
83
84
  super(props);
@@ -281,7 +282,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
281
282
  }
282
283
 
283
284
  renderHandle = () => {
284
- const { vertical, range, tooltipVisible, tipFormatter } = this.props;
285
+ const { vertical, range, tooltipVisible, tipFormatter, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-valuetext': ariaValueText, getAriaValueText, disabled } = this.props;
285
286
  const { chooseMovePos, isDrag, isInRenderTree } = this.state;
286
287
  const stylePos = vertical ? 'top' : 'left';
287
288
  const percentInfo = this.foundation.getMinAndMaxPercent(this.state.currentValue);
@@ -299,6 +300,15 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
299
300
  const maxClass = cls(cssClasses.HANDLE, {
300
301
  [`${cssClasses.HANDLE}-clicked`]: chooseMovePos === 'max' && isDrag,
301
302
  });
303
+ const {min, max, currentValue} = this.state;
304
+
305
+ const commonAria = {
306
+ 'aria-label': ariaLabel,
307
+ 'aria-labelledby': ariaLabelledby,
308
+ 'aria-disabled': disabled
309
+ };
310
+ vertical && Object.assign(commonAria, {'aria-orientation': 'vertical'});
311
+
302
312
  const handleContents = !range ? (
303
313
  <Tooltip
304
314
  content={tipChildren.min}
@@ -338,6 +348,14 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
338
348
  onTouchEnd={e => {
339
349
  this.foundation.onHandleUp(e);
340
350
  }}
351
+ onFocus={e => this.foundation.onFocus(e, 'min')}
352
+ role="slider"
353
+ tabIndex={0}
354
+ {...commonAria}
355
+ aria-valuenow={currentValue as number}
356
+ aria-valuemax={max}
357
+ aria-valuemin={min}
358
+ aria-valuetext={getAriaValueText ? getAriaValueText(currentValue as number) : ariaValueText}
341
359
  />
342
360
  </Tooltip>
343
361
  ) : (
@@ -379,6 +397,14 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
379
397
  onTouchEnd={e => {
380
398
  this.foundation.onHandleUp(e);
381
399
  }}
400
+ onFocus={e => this.foundation.onFocus(e, 'min')}
401
+ role="slider"
402
+ tabIndex={0}
403
+ {...commonAria}
404
+ aria-valuenow={currentValue[0]}
405
+ aria-valuetext={getAriaValueText ? getAriaValueText(currentValue[0]) : ariaValueText}
406
+ aria-valuemax={currentValue[1]}
407
+ aria-valuemin={min}
382
408
  />
383
409
  </Tooltip>
384
410
  <Tooltip
@@ -418,6 +444,14 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
418
444
  onTouchEnd={e => {
419
445
  this.foundation.onHandleUp(e);
420
446
  }}
447
+ onFocus={e => this.foundation.onFocus(e, 'min')}
448
+ role="slider"
449
+ tabIndex={0}
450
+ {...commonAria}
451
+ aria-valuenow={currentValue[1]}
452
+ aria-valuetext={getAriaValueText ? getAriaValueText(currentValue[1]) : ariaValueText}
453
+ aria-valuemax={max}
454
+ aria-valuemin={currentValue[0]}
421
455
  />
422
456
  </Tooltip>
423
457
  </React.Fragment>
@@ -440,7 +474,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
440
474
  top: range ? `${minPercent * 100}%` : 0,
441
475
  };
442
476
  trackStyle = included ? trackStyle : {};
443
- return (
477
+ return (// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
444
478
  <div className={cssClasses.TRACK} style={trackStyle} onClick={e => this.foundation.handleWrapClick(e)}>
445
479
  {/* {this.renderTrack} */}
446
480
  </div>
@@ -462,6 +496,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
462
496
  return activeResult ? (
463
497
  <span
464
498
  key={mark}
499
+ onClick={e => this.foundation.handleWrapClick(e)}
465
500
  className={markClass}
466
501
  style={{ [stylePos]: `calc(${markPercent * 100}% - 2px)` }}
467
502
  />
@@ -522,11 +557,13 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
522
557
  onMouseEnter={() => this.foundation.handleWrapperEnter()}
523
558
  onMouseLeave={() => this.foundation.handleWrapperLeave()}
524
559
  >
525
- <div
526
- className={`${prefixCls}-rail`}
527
- onClick={e => this.foundation.handleWrapClick(e)}
528
- style={this.props.railStyle}
529
- />
560
+ {// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
561
+ <div
562
+ className={`${prefixCls}-rail`}
563
+ onClick={e => this.foundation.handleWrapClick(e)}
564
+ style={this.props.railStyle}
565
+ />
566
+ }
530
567
  {this.renderTrack()}
531
568
  {this.renderStepDot()}
532
569
  <div>{this.renderHandle()}</div>
package/spin/icon.tsx CHANGED
@@ -29,6 +29,8 @@ function Icon(props: IconProps = {}) {
29
29
  viewBox="0 0 36 36"
30
30
  version="1.1"
31
31
  xmlns="http://www.w3.org/2000/svg"
32
+ aria-hidden
33
+ data-icon="spin"
32
34
  >
33
35
  <defs>
34
36
  <linearGradient x1="0%" y1="100%" x2="100%" y2="100%" id={id}>
@@ -37,11 +39,10 @@ function Icon(props: IconProps = {}) {
37
39
  <stop stopColor="currentColor" offset="100%" />
38
40
  </linearGradient>
39
41
  </defs>
40
- <g id="Artboard" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
41
- <rect id="Rectangle" fillOpacity="0.01" fill="#FFFFFF" x="0" y="0" width="36" height="36" />
42
+ <g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
43
+ <rect fillOpacity="0.01" fill="#FFFFFF" x="0" y="0" width="36" height="36" />
42
44
  <path
43
45
  d="M34,18 C34,9.163444 26.836556,2 18,2 C11.6597233,2 6.18078805,5.68784135 3.59122325,11.0354951"
44
- id="Path"
45
46
  stroke={`url(#${id})`}
46
47
  strokeWidth="4"
47
48
  strokeLinecap="round"
@@ -21,6 +21,9 @@ export interface BasicStepProps {
21
21
  done?: boolean;
22
22
  onChange?: () => void;
23
23
  onClick?: React.MouseEventHandler<HTMLDivElement>;
24
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
25
+ "role"?: React.AriaRole;
26
+ "aria-label"?: React.AriaAttributes["aria-label"];
24
27
  }
25
28
  export enum stepSizeMapIconSize {
26
29
  small = 'large',
@@ -42,7 +45,7 @@ const BasicStep = (props: BasicStepProps) => {
42
45
  stepNumber,
43
46
  onClick,
44
47
  onChange,
45
- ...restProps
48
+ onKeyDown,
46
49
  } = props;
47
50
  const renderIcon = () => {
48
51
  let inner, progress;
@@ -82,18 +85,26 @@ const BasicStep = (props: BasicStepProps) => {
82
85
 
83
86
  return inner ? <span className={cls}>{inner}</span> : null;
84
87
  };
85
- const classString = classnames(prefixCls, className, `${prefixCls}-${status}`, {
88
+ const classString = classnames(prefixCls, `${prefixCls}-${status}`, {
86
89
  [`${prefixCls}-active`]: active,
87
90
  [`${prefixCls}-done`]: done
88
- });
91
+ }, className);
89
92
  const handleClick = (e: React.MouseEvent) => {
90
93
  if (isFunction(onClick)) {
91
94
  onClick(e);
92
95
  }
93
96
  onChange();
94
97
  };
98
+ const handleKeyDown = (e) => {
99
+ if (e.key === 'Enter') {
100
+ if (isFunction(onKeyDown)) {
101
+ onKeyDown(e);
102
+ }
103
+ onChange();
104
+ }
105
+ };
95
106
  return (
96
- <div {...restProps} className={classString} style={style} onClick={e => handleClick(e)}>
107
+ <div role={props["role"]} aria-label={props["aria-label"]} tabIndex={0} aria-current="step" className={classString} style={style} onClick={e => handleClick(e)} onKeyDown={handleKeyDown}>
97
108
  <div className={`${prefixCls}-container`}>
98
109
  <div className={`${prefixCls}-left`}>{renderIcon()}</div>
99
110
  <div className={`${prefixCls}-content`}>
@@ -18,6 +18,7 @@ export interface BasicStepsProps {
18
18
  hasLine?: boolean;
19
19
  children?: React.ReactNode;
20
20
  onChange?: (current: number) => void;
21
+ "aria-label"?: string;
21
22
  }
22
23
 
23
24
  const Steps = (props: BasicStepsProps) => {
@@ -70,7 +71,7 @@ const Steps = (props: BasicStepsProps) => {
70
71
  return cloneElement(child, { ...childProps });
71
72
  });
72
73
  return content;
73
- }, [children, initial, prefixCls, direction, status, current, size]);
74
+ }, [children, initial, prefixCls, direction, status, current, size, onChange]);
74
75
 
75
76
  const wrapperCls = cls(className, {
76
77
  [`${prefixCls}-basic`]: true,
@@ -80,7 +81,7 @@ const Steps = (props: BasicStepsProps) => {
80
81
  });
81
82
 
82
83
  return (
83
- <div className={wrapperCls} style={style}>
84
+ <div aria-label={props["aria-label"]} className={wrapperCls} style={style}>
84
85
  {inner}
85
86
  </div>
86
87
  );
@@ -18,10 +18,13 @@ export interface FillStepProps {
18
18
  stepNumber?: string;
19
19
  onChange?: () => void;
20
20
  onClick?: React.MouseEventHandler<HTMLDivElement>;
21
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
22
+ "role"?: React.AriaRole;
23
+ "aria-label"?: React.AriaAttributes["aria-label"];
21
24
  }
22
25
 
23
26
  const FillStep = (props: FillStepProps) => {
24
- const { prefixCls, className, title, description, status, style, onClick, icon, onChange, stepNumber } = props;
27
+ const { prefixCls, className, title, description, status, style, onClick, icon, onChange, stepNumber, onKeyDown } = props;
25
28
  const renderIcon = () => {
26
29
  let inner, progress;
27
30
 
@@ -51,10 +54,10 @@ const FillStep = (props: FillStepProps) => {
51
54
  }
52
55
  }
53
56
  const cls = classnames({
54
- [`${prefixCls }-left`]: true,
55
- [`${prefixCls }-icon`]: 'icon' in props,
56
- [`${prefixCls }-plain`]: !('icon' in props),
57
- [`${prefixCls }-icon-process`]: progress,
57
+ [`${prefixCls}-left`]: true,
58
+ [`${prefixCls}-icon`]: 'icon' in props,
59
+ [`${prefixCls}-plain`]: !('icon' in props),
60
+ [`${prefixCls}-icon-process`]: progress,
58
61
  });
59
62
 
60
63
  return inner ? <div className={cls}>{inner}</div> : null;
@@ -65,26 +68,38 @@ const FillStep = (props: FillStepProps) => {
65
68
  }
66
69
  onChange();
67
70
  };
71
+ const handleKeyDown = (e) => {
72
+ if (e.key === 'Enter') {
73
+ if (isFunction(onKeyDown)) {
74
+ onKeyDown(e);
75
+ }
76
+ onChange();
77
+ }
78
+ };
68
79
  return (
69
80
  <div
81
+ role={props["role"]}
82
+ aria-label={props["aria-label"]}
83
+ aria-current="step"
84
+ tabIndex={0}
70
85
  className={classnames({
71
- [className]: Boolean(className),
72
86
  [prefixCls]: true,
73
87
  [`${prefixCls}-${status}`]: Boolean(status),
74
- [`${prefixCls }-clickable`]: onClick,
75
- })}
88
+ [`${prefixCls}-clickable`]: onClick,
89
+ }, className)}
76
90
  style={style}
77
91
  onClick={e => {
78
92
  handleClick(e);
79
93
  }}
94
+ onKeyDown={handleKeyDown}
80
95
  >
81
96
  {renderIcon()}
82
- <div className={`${prefixCls }-content`}>
83
- <div className={`${prefixCls }-title`} title={typeof title === 'string' ? title : null}>
84
- <span className={`${prefixCls }-title-text`}>{title}</span>
97
+ <div className={`${prefixCls}-content`}>
98
+ <div className={`${prefixCls}-title`} title={typeof title === 'string' ? title : null}>
99
+ <span className={`${prefixCls}-title-text`}>{title}</span>
85
100
  </div>
86
101
  <div
87
- className={`${prefixCls }-description`}
102
+ className={`${prefixCls}-description`}
88
103
  title={typeof description === 'string' ? description : null}
89
104
  >
90
105
  {description}
@@ -16,6 +16,7 @@ export interface FillStepsProps {
16
16
  style?: React.CSSProperties;
17
17
  children?: React.ReactNode;
18
18
  onChange?: (current: number) => void;
19
+ "aria-label"?: string;
19
20
  }
20
21
 
21
22
  const Steps = (props: FillStepsProps) => {
@@ -66,6 +67,7 @@ const Steps = (props: FillStepsProps) => {
66
67
  <div
67
68
  className={wrapperCls}
68
69
  style={style}
70
+ aria-label={props["aria-label"]}
69
71
  >
70
72
  <Row type="flex" justify="start">
71
73
  {inner}
package/steps/navStep.tsx CHANGED
@@ -15,21 +15,32 @@ export interface NavStepProps {
15
15
  prefixCls?: string;
16
16
  onChange?: () => void;
17
17
  onClick?: React.MouseEventHandler<HTMLDivElement>;
18
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
19
+ "role"?: React.AriaRole;
20
+ "aria-label"?: React.AriaAttributes["aria-label"];
18
21
  }
19
22
 
20
23
  const NavStep = (props: NavStepProps) => {
21
- const { prefixCls, className, title, style, active, index, total, onClick, onChange, ...restProps } = props;
22
- const classString = classnames(prefixCls, className, {
24
+ const { prefixCls, className, title, style, active, index, total, onClick, onKeyDown, onChange } = props;
25
+ const classString = classnames(prefixCls, {
23
26
  [`${prefixCls}-active`]: active
24
- });
27
+ }, className);
25
28
  const handleClick = (e: React.MouseEvent) => {
26
29
  if (isFunction(onClick)) {
27
30
  onClick(e);
28
31
  }
29
32
  onChange();
30
33
  };
34
+ const handleKeyDown = (e) => {
35
+ if (e.key === 'Enter') {
36
+ if (isFunction(onKeyDown)) {
37
+ onKeyDown(e);
38
+ }
39
+ onChange();
40
+ }
41
+ };
31
42
  return (
32
- <div {...restProps} className={classString} style={style} onClick={e => handleClick(e)}>
43
+ <div role={props["role"]} aria-label={props["aria-label"]} aria-current="step" tabIndex={0} className={classString} style={style} onClick={e => handleClick(e)} onKeyDown={handleKeyDown}>
33
44
  <div className={`${prefixCls}-container`}>
34
45
  <div className={`${prefixCls}-content`}>
35
46
  <div className={`${prefixCls}-title`}>
@@ -13,6 +13,7 @@ export interface NavStepsProps {
13
13
  size?: Size;
14
14
  children?: React.ReactNode;
15
15
  onChange?: (current: number) => void;
16
+ "aria-label"?: string;
16
17
  }
17
18
 
18
19
  const Steps = (props: NavStepsProps) => {
@@ -38,7 +39,7 @@ const Steps = (props: NavStepsProps) => {
38
39
  return cloneElement(child, { ...childProps });
39
40
  });
40
41
  return content;
41
- }, [children, prefixCls, current, size]);
42
+ }, [children, prefixCls, current, size, initial, onChange]);
42
43
 
43
44
  const wrapperCls = cls(className, {
44
45
  [`${prefixCls}-nav`]: true,
@@ -46,7 +47,7 @@ const Steps = (props: NavStepsProps) => {
46
47
  });
47
48
 
48
49
  return (
49
- <div className={wrapperCls} style={style}>
50
+ <div aria-label={props["aria-label"]} className={wrapperCls} style={style}>
50
51
  {inner}
51
52
  </div>
52
53
  );
@@ -9,8 +9,8 @@ export default {
9
9
 
10
10
  export const _Switch = () => (
11
11
  <div>
12
- <Switch onChange={(v, e) => console.log(v)}></Switch>
13
- <Switch defaultChecked={true} onChange={(v, e) => console.log(v)}></Switch>
12
+ <Switch onChange={(v, e) => console.log(v)} aria-label='power-switch'></Switch>
13
+ <Switch defaultChecked={true} onChange={(v, e) => console.log(v)} aria-label='mode-switch'></Switch>
14
14
  </div>
15
15
  );
16
16
 
@@ -20,9 +20,9 @@ _Switch.story = {
20
20
 
21
21
  export const SwitchSize = () => (
22
22
  <div>
23
- <Switch onChange={(v, e) => console.log(v)}></Switch>
24
- <Switch onChange={(v, e) => console.log(v)} size="small"></Switch>
25
- <Switch onChange={(v, e) => console.log(v)} size="large"></Switch>
23
+ <Switch onChange={(v, e) => console.log(v)} aria-label='power-switch'></Switch>
24
+ <Switch onChange={(v, e) => console.log(v)} size="small" aria-label='power-switch'></Switch>
25
+ <Switch onChange={(v, e) => console.log(v)} size="large" aria-label='power-switch'></Switch>
26
26
  </div>
27
27
  );
28
28
 
@@ -32,20 +32,20 @@ SwitchSize.story = {
32
32
 
33
33
  export const SwitchCheckedTextUncheckedText = () => (
34
34
  <div>
35
- <Switch defaultChecked checkedText="开" uncheckedText="关" />
36
- <Switch checkedText={'|'} uncheckedText="〇" />
35
+ <Switch defaultChecked checkedText="开" uncheckedText="关" aria-label='power-switch'/>
36
+ <Switch checkedText={'|'} uncheckedText="〇" aria-label='power-switch'/>
37
37
  <br />
38
38
  <br />
39
- <Switch checkedText="开" uncheckedText="关" />
40
- <Switch defaultChecked checkedText="|" uncheckedText="〇" />
39
+ <Switch checkedText="开" uncheckedText="关" aria-label='power-switch'/>
40
+ <Switch defaultChecked checkedText="|" uncheckedText="〇" aria-label='power-switch'/>
41
41
  <br />
42
42
  <br />
43
- <Switch checkedText="开" uncheckedText="关" size="large" />
44
- <Switch checkedText="|" uncheckedText="〇" size="large" />
43
+ <Switch checkedText="开" uncheckedText="关" size="large" aria-label='power-switch'/>
44
+ <Switch checkedText="|" uncheckedText="〇" size="large" aria-label='power-switch'/>
45
45
  <br />
46
46
  <br />
47
- <Switch defaultChecked checkedText="开" uncheckedText="关" size="large" />
48
- <Switch defaultChecked checkedText="|" uncheckedText="〇" size="large" />
47
+ <Switch defaultChecked checkedText="开" uncheckedText="关" size="large" aria-label='power-switch'/>
48
+ <Switch defaultChecked checkedText="|" uncheckedText="〇" size="large" aria-label='power-switch'/>
49
49
  </div>
50
50
  );
51
51
 
@@ -55,9 +55,9 @@ SwitchCheckedTextUncheckedText.story = {
55
55
 
56
56
  export const SwitchDisabled = () => (
57
57
  <>
58
- <Switch disabled>disabled</Switch>
58
+ <Switch disabled aria-label='power-switch'>disabled</Switch>
59
59
 
60
- <Switch disabled checked={true} onChange={(v, e) => console.log(v)}></Switch>
60
+ <Switch disabled checked={true} onChange={(v, e) => console.log(v)} aria-label='power-switch'></Switch>
61
61
  </>
62
62
  );
63
63
 
@@ -67,7 +67,7 @@ SwitchDisabled.story = {
67
67
 
68
68
  const ControledSwitch = () => {
69
69
  const [checked, onChange] = useState(true);
70
- return <Switch checked={checked} onChange={(v, e) => onChange(v)} />;
70
+ return <Switch checked={checked} onChange={(v, e) => onChange(v)} aria-label='power-switch'/>;
71
71
  };
72
72
  export const SwitchCheckedOnChange = () => <ControledSwitch />;
73
73
 
@@ -82,7 +82,7 @@ const UnControledSwitch = () => {
82
82
  return (
83
83
  <>
84
84
  {/* <Switch onChange={onChange} defaultChecked={false}/> */}
85
- <Switch onChange={onChange} defaultChecked={true} />
85
+ <Switch onChange={onChange} defaultChecked={true} aria-label='power-switch'/>
86
86
  </>
87
87
  );
88
88
  };
@@ -137,15 +137,16 @@ class LoadingDemo extends React.Component {
137
137
  <Switch
138
138
  checked={this.state.checked}
139
139
  onChange={this.onChange}
140
+ aria-label='power-switch'
140
141
  loading={this.state.loading}
141
142
  ></Switch>
142
143
  <br />
143
144
  <br />
144
145
  <hr />
145
- <Switch loading disabled />
146
+ <Switch loading disabled aria-label='power-switch'/>
146
147
  <br />
147
148
  <br />
148
- <Switch loading disabled defaultChecked />
149
+ <Switch loading disabled defaultChecked aria-label='power-switch'/>
149
150
  <br />
150
151
  <br />
151
152
  </>
@@ -13,9 +13,9 @@ const stories = storiesOf('Switch', module);
13
13
 
14
14
  stories.add('switch', () => (
15
15
  <div>
16
- <Switch onChange={(v, e) => console.log(v)}>
16
+ <Switch onChange={(v, e) => console.log(v)} aria-label='power-switch'>
17
17
  </Switch>
18
- <Switch defaultChecked={true} onChange={(v, e) => console.log(v)}>
18
+ <Switch defaultChecked={true} onChange={(v, e) => console.log(v)} aria-label='power-switch'>
19
19
  </Switch>
20
20
  </div>
21
21
  ));
@@ -24,24 +24,24 @@ stories.add('switch', () => (
24
24
  stories.add('switch size', () => (
25
25
  <div>
26
26
  <Switch onChange={(v, e) => console.log(v)}></Switch>
27
- <Switch onChange={(v, e) => console.log(v)} size='small'></Switch>
28
- <Switch onChange={(v, e) => console.log(v)} size='large'></Switch>
27
+ <Switch onChange={(v, e) => console.log(v)} size='small' aria-label='power-switch'></Switch>
28
+ <Switch onChange={(v, e) => console.log(v)} size='large' aria-label='power-switch'></Switch>
29
29
  </div>
30
30
  ));
31
31
 
32
32
  stories.add('switch checkedText & uncheckedText', () => (
33
33
  <div>
34
- <Switch defaultChecked checkedText='开' uncheckedText='关' />
34
+ <Switch defaultChecked checkedText='开' uncheckedText='关' aria-label='power-switch'/>
35
35
  <Switch checkedText={'|'} uncheckedText='〇' />
36
36
  <br/><br/>
37
37
  <Switch checkedText='开' uncheckedText='关' />
38
- <Switch defaultChecked checkText='|' uncheckedText='〇' />
38
+ <Switch defaultChecked checkedText='|' uncheckedText='〇' aria-label='power-switch'/>
39
39
  <br/><br/>
40
- <Switch checkedText='开' uncheckedText='关' size='large' />
41
- <Switch checedkText='|' uncheckedText='〇' size='large' />
40
+ <Switch checkedText='开' uncheckedText='关' size='large' aria-label='power-switch'/>
41
+ <Switch checkedText='|' uncheckedText='〇' size='large' aria-label='power-switch'/>
42
42
  <br/><br/>
43
- <Switch defaultChecked checkedText='开' uncheckedText='关' size='large' />
44
- <Switch defaultChecked checkedText='|' uncheckedText='〇' size='large' />
43
+ <Switch defaultChecked checkedText='开' uncheckedText='关' size='large' aria-label='power-switch'/>
44
+ <Switch defaultChecked checkedText='|' uncheckedText='〇' size='large' aria-label='power-switch'/>
45
45
  </div>
46
46
  ));
47
47
 
@@ -51,7 +51,7 @@ stories.add('switch disabled', () => (
51
51
  disabled
52
52
  </Switch>
53
53
 
54
- <Switch disabled checked={true} onChange={(v, e) => console.log(v)}>
54
+ <Switch disabled checked={true} onChange={(v, e) => console.log(v)} aria-label='power-switch'>
55
55
  </Switch>
56
56
  </>
57
57
  ));
@@ -79,8 +79,8 @@ const UnControledSwitch = () => {
79
79
  stories.add('switch defaultChecked + onChange', () => <UnControledSwitch/>);
80
80
 
81
81
  class LoadingDemo extends React.Component {
82
- constructor() {
83
- super()
82
+ constructor(props) {
83
+ super(props);
84
84
  this.state = {
85
85
  checked: true,
86
86
  loading:false
package/switch/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable max-len */
1
+ /* eslint-disable max-len, jsx-a11y/role-supports-aria-props */
2
2
  import React from 'react';
3
3
  import cls from 'classnames';
4
4
  import PropTypes from 'prop-types';
@@ -9,8 +9,12 @@ import '@douyinfe/semi-foundation/switch/switch.scss';
9
9
 
10
10
  import { noop } from 'lodash';
11
11
  import Spin from '../spin';
12
-
13
12
  export interface SwitchProps {
13
+ 'aria-label'?: React.AriaAttributes['aria-label'];
14
+ 'aria-describedby'?: React.AriaAttributes['aria-describedby'];
15
+ 'aria-errormessage'?: React.AriaAttributes['aria-errormessage'];
16
+ 'aria-invalid'?: React.AriaAttributes['aria-invalid'];
17
+ 'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
14
18
  defaultChecked?: boolean;
15
19
  checked?: boolean;
16
20
  disabled?: boolean;
@@ -23,7 +27,8 @@ export interface SwitchProps {
23
27
  size?: 'large' | 'default' | 'small';
24
28
  checkedText?: React.ReactNode;
25
29
  uncheckedText?: React.ReactNode;
26
- }
30
+ id?: string;
31
+ }
27
32
 
28
33
  export interface SwitchState {
29
34
  nativeControlChecked: boolean;
@@ -32,6 +37,11 @@ export interface SwitchState {
32
37
 
33
38
  class Switch extends BaseComponent<SwitchProps, SwitchState> {
34
39
  static propTypes = {
40
+ 'aria-label': PropTypes.string,
41
+ 'aria-labelledby': PropTypes.string,
42
+ 'aria-invalid': PropTypes.bool,
43
+ 'aria-errormessage': PropTypes.string,
44
+ 'aria-describedby': PropTypes.string,
35
45
  className: PropTypes.string,
36
46
  checked: PropTypes.bool,
37
47
  checkedText: PropTypes.node,
@@ -44,6 +54,7 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
44
54
  style: PropTypes.object,
45
55
  size: PropTypes.oneOf<SwitchProps['size']>(strings.SIZE_MAP),
46
56
  uncheckedText: PropTypes.node,
57
+ id: PropTypes.string,
47
58
  };
48
59
 
49
60
  static defaultProps: Partial<SwitchProps> = {
@@ -102,7 +113,7 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
102
113
 
103
114
  render() {
104
115
  const { nativeControlChecked, nativeControlDisabled } = this.state;
105
- const { className, style, onMouseEnter, onMouseLeave, size, checkedText, uncheckedText, loading } = this.props;
116
+ const { className, style, onMouseEnter, onMouseLeave, size, checkedText, uncheckedText, loading, id } = this.props;
106
117
  const wrapperCls = cls(className, {
107
118
  [cssClasses.PREFIX]: true,
108
119
  [cssClasses.CHECKED]: nativeControlChecked,
@@ -130,7 +141,7 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
130
141
  size={size === 'default' ? 'middle' : size}
131
142
  />
132
143
  )
133
- : <div className={cssClasses.KNOB} />
144
+ : <div className={cssClasses.KNOB} aria-hidden={true} />
134
145
  }
135
146
  {showCheckedText ? (
136
147
  <div className={cssClasses.CHECKED_TEXT}>
@@ -145,6 +156,13 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
145
156
  <input
146
157
  {...switchProps}
147
158
  ref={this.switchRef}
159
+ id={id}
160
+ aria-checked={nativeControlChecked}
161
+ aria-invalid={this.props['aria-invalid']}
162
+ aria-errormessage={this.props['aria-errormessage']}
163
+ aria-label={this.props['aria-label']}
164
+ aria-labelledby={this.props['aria-labelledby']}
165
+ aria-describedby={this.props["aria-describedby"]}
148
166
  onChange={e => this.foundation.handleChange(e.target.checked, e)}
149
167
  />
150
168
  </div>