@douyinfe/semi-ui 2.2.2 → 2.3.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 (434) hide show
  1. package/_base/_story/a11y.jsx +6 -6
  2. package/_utils/hooks/usePrevFocus.ts +16 -0
  3. package/_utils/index.ts +4 -0
  4. package/anchor/_story/anchor.stories.js +1 -1
  5. package/anchor/index.tsx +5 -2
  6. package/anchor/link.tsx +29 -4
  7. package/autoComplete/index.tsx +28 -1
  8. package/avatar/_story/avatar.stories.js +4 -4
  9. package/avatar/avatarGroup.tsx +1 -1
  10. package/avatar/index.tsx +10 -4
  11. package/banner/index.tsx +2 -1
  12. package/breadcrumb/_story/breadcrumb.stories.js +22 -8
  13. package/breadcrumb/index.tsx +8 -1
  14. package/breadcrumb/item.tsx +1 -1
  15. package/button/Button.tsx +4 -0
  16. package/button/__test__/button.test.js +1 -1
  17. package/button/_story/button.stories.js +10 -10
  18. package/button/buttonGroup.tsx +4 -2
  19. package/button/splitButtonGroup.tsx +5 -2
  20. package/card/_story/card.stories.js +8 -1
  21. package/card/_story/card.stories.tsx +3 -0
  22. package/card/index.tsx +5 -2
  23. package/cascader/index.tsx +33 -5
  24. package/checkbox/_story/checkbox.stories.js +21 -14
  25. package/checkbox/checkbox.tsx +40 -5
  26. package/checkbox/checkboxGroup.tsx +30 -5
  27. package/checkbox/checkboxInner.tsx +25 -2
  28. package/collapse/index.tsx +2 -2
  29. package/collapse/item.tsx +15 -8
  30. package/collapsible/index.tsx +4 -2
  31. package/configProvider/_story/configProvider.stories.tsx +27 -0
  32. package/datePicker/datePicker.tsx +19 -0
  33. package/dist/css/semi.css +8 -3
  34. package/dist/css/semi.min.css +1 -1
  35. package/dist/umd/semi-ui.js +2470 -1242
  36. package/dist/umd/semi-ui.js.map +1 -1
  37. package/dist/umd/semi-ui.min.js +1 -1
  38. package/dist/umd/semi-ui.min.js.map +1 -1
  39. package/dropdown/dropdownItem.tsx +1 -1
  40. package/dropdown/dropdownMenu.tsx +1 -1
  41. package/empty/index.tsx +5 -5
  42. package/form/_story/FormApi/formApiDemo.jsx +3 -2
  43. package/form/_story/Validate/validateDemo.jsx +1 -1
  44. package/form/_story/demo.jsx +12 -3
  45. package/form/_story/form.stories.js +0 -7
  46. package/form/baseForm.tsx +2 -0
  47. package/form/errorMessage.tsx +13 -2
  48. package/form/hoc/withField.tsx +37 -8
  49. package/form/index.tsx +0 -2
  50. package/form/interface.ts +2 -0
  51. package/form/label.tsx +4 -2
  52. package/input/index.tsx +49 -4
  53. package/input/inputGroup.tsx +9 -4
  54. package/input/textarea.tsx +25 -6
  55. package/inputNumber/index.tsx +28 -1
  56. package/layout/Sider.tsx +6 -2
  57. package/layout/index.tsx +4 -3
  58. package/lib/cjs/_utils/hooks/usePrevFocus.d.ts +2 -0
  59. package/lib/cjs/_utils/hooks/usePrevFocus.js +30 -0
  60. package/lib/cjs/_utils/index.d.ts +1 -0
  61. package/lib/cjs/_utils/index.js +6 -1
  62. package/lib/cjs/anchor/index.d.ts +2 -0
  63. package/lib/cjs/anchor/index.js +6 -1
  64. package/lib/cjs/anchor/link.d.ts +4 -1
  65. package/lib/cjs/anchor/link.js +39 -5
  66. package/lib/cjs/autoComplete/index.d.ts +17 -0
  67. package/lib/cjs/autoComplete/index.js +21 -2
  68. package/lib/cjs/avatar/avatarGroup.js +2 -1
  69. package/lib/cjs/avatar/index.d.ts +4 -3
  70. package/lib/cjs/avatar/index.js +20 -11
  71. package/lib/cjs/banner/index.js +4 -2
  72. package/lib/cjs/breadcrumb/index.d.ts +3 -0
  73. package/lib/cjs/breadcrumb/index.js +10 -4
  74. package/lib/cjs/breadcrumb/item.js +2 -2
  75. package/lib/cjs/button/Button.d.ts +2 -0
  76. package/lib/cjs/button/Button.js +4 -2
  77. package/lib/cjs/button/buttonGroup.d.ts +3 -0
  78. package/lib/cjs/button/buttonGroup.js +8 -4
  79. package/lib/cjs/button/index.d.ts +1 -0
  80. package/lib/cjs/button/splitButtonGroup.d.ts +3 -0
  81. package/lib/cjs/button/splitButtonGroup.js +5 -2
  82. package/lib/cjs/card/index.d.ts +3 -0
  83. package/lib/cjs/card/index.js +3 -1
  84. package/lib/cjs/cascader/index.d.ts +14 -0
  85. package/lib/cjs/cascader/index.js +35 -7
  86. package/lib/cjs/checkbox/checkbox.d.ts +21 -1
  87. package/lib/cjs/checkbox/checkbox.js +51 -17
  88. package/lib/cjs/checkbox/checkboxGroup.d.ts +13 -1
  89. package/lib/cjs/checkbox/checkboxGroup.js +16 -3
  90. package/lib/cjs/checkbox/checkboxInner.d.ts +15 -0
  91. package/lib/cjs/checkbox/checkboxInner.js +20 -3
  92. package/lib/cjs/collapse/index.js +2 -1
  93. package/lib/cjs/collapse/item.d.ts +2 -1
  94. package/lib/cjs/collapse/item.js +17 -3
  95. package/lib/cjs/collapsible/index.d.ts +1 -0
  96. package/lib/cjs/collapsible/index.js +4 -2
  97. package/lib/cjs/datePicker/datePicker.d.ts +12 -0
  98. package/lib/cjs/datePicker/datePicker.js +14 -1
  99. package/lib/cjs/dropdown/dropdownItem.js +3 -1
  100. package/lib/cjs/dropdown/dropdownMenu.js +4 -1
  101. package/lib/cjs/empty/index.js +2 -1
  102. package/lib/cjs/form/baseForm.d.ts +9 -0
  103. package/lib/cjs/form/baseForm.js +3 -1
  104. package/lib/cjs/form/errorMessage.d.ts +4 -0
  105. package/lib/cjs/form/errorMessage.js +21 -3
  106. package/lib/cjs/form/field.d.ts +7 -0
  107. package/lib/cjs/form/hoc/withField.js +49 -16
  108. package/lib/cjs/form/index.d.ts +0 -1
  109. package/lib/cjs/form/interface.d.ts +2 -0
  110. package/lib/cjs/form/label.d.ts +2 -0
  111. package/lib/cjs/form/label.js +5 -2
  112. package/lib/cjs/input/index.d.ts +16 -0
  113. package/lib/cjs/input/index.js +51 -15
  114. package/lib/cjs/input/inputGroup.d.ts +2 -1
  115. package/lib/cjs/input/inputGroup.js +11 -1
  116. package/lib/cjs/input/textarea.js +12 -1
  117. package/lib/cjs/inputNumber/index.d.ts +8 -0
  118. package/lib/cjs/inputNumber/index.js +32 -2
  119. package/lib/cjs/layout/Sider.d.ts +4 -0
  120. package/lib/cjs/layout/Sider.js +4 -1
  121. package/lib/cjs/layout/index.js +2 -0
  122. package/lib/cjs/list/item.js +0 -1
  123. package/lib/cjs/modal/Modal.js +2 -0
  124. package/lib/cjs/modal/ModalContent.d.ts +3 -1
  125. package/lib/cjs/modal/ModalContent.js +47 -5
  126. package/lib/cjs/navigation/Item.d.ts +4 -2
  127. package/lib/cjs/navigation/Item.js +25 -5
  128. package/lib/cjs/navigation/SubNav.d.ts +4 -2
  129. package/lib/cjs/navigation/SubNav.js +8 -1
  130. package/lib/cjs/navigation/index.js +2 -0
  131. package/lib/cjs/notification/notice.d.ts +1 -1
  132. package/lib/cjs/notification/notice.js +32 -22
  133. package/lib/cjs/pagination/index.js +16 -6
  134. package/lib/cjs/popover/index.js +7 -3
  135. package/lib/cjs/progress/index.d.ts +8 -0
  136. package/lib/cjs/progress/index.js +42 -9
  137. package/lib/cjs/radio/radio.d.ts +6 -1
  138. package/lib/cjs/radio/radio.js +17 -5
  139. package/lib/cjs/radio/radioGroup.d.ts +16 -1
  140. package/lib/cjs/radio/radioGroup.js +18 -3
  141. package/lib/cjs/radio/radioInner.d.ts +6 -1
  142. package/lib/cjs/radio/radioInner.js +11 -3
  143. package/lib/cjs/rating/index.d.ts +14 -0
  144. package/lib/cjs/rating/index.js +14 -3
  145. package/lib/cjs/rating/item.d.ts +2 -0
  146. package/lib/cjs/rating/item.js +6 -1
  147. package/lib/cjs/select/index.d.ts +16 -0
  148. package/lib/cjs/select/index.js +65 -19
  149. package/lib/cjs/select/option.js +28 -22
  150. package/lib/cjs/sideSheet/SideSheetContent.d.ts +1 -0
  151. package/lib/cjs/sideSheet/SideSheetContent.js +12 -5
  152. package/lib/cjs/sideSheet/index.d.ts +1 -0
  153. package/lib/cjs/sideSheet/index.js +2 -1
  154. package/lib/cjs/slider/index.d.ts +2 -1
  155. package/lib/cjs/slider/index.js +64 -17
  156. package/lib/cjs/spin/icon.js +2 -4
  157. package/lib/cjs/steps/basicStep.d.ts +3 -0
  158. package/lib/cjs/steps/basicStep.js +23 -25
  159. package/lib/cjs/steps/basicSteps.d.ts +1 -0
  160. package/lib/cjs/steps/basicSteps.js +2 -1
  161. package/lib/cjs/steps/fillStep.d.ts +3 -0
  162. package/lib/cjs/steps/fillStep.js +19 -4
  163. package/lib/cjs/steps/fillSteps.d.ts +1 -0
  164. package/lib/cjs/steps/fillSteps.js +2 -1
  165. package/lib/cjs/steps/navStep.d.ts +3 -0
  166. package/lib/cjs/steps/navStep.js +22 -25
  167. package/lib/cjs/steps/navSteps.d.ts +1 -0
  168. package/lib/cjs/steps/navSteps.js +2 -1
  169. package/lib/cjs/switch/index.d.ts +12 -0
  170. package/lib/cjs/switch/index.js +19 -4
  171. package/lib/cjs/table/Body/BaseRow.js +35 -3
  172. package/lib/cjs/table/Body/index.js +9 -1
  173. package/lib/cjs/table/ColumnFilter.js +4 -0
  174. package/lib/cjs/table/ColumnSelection.d.ts +3 -0
  175. package/lib/cjs/table/ColumnSelection.js +6 -2
  176. package/lib/cjs/table/ColumnSorter.js +19 -3
  177. package/lib/cjs/table/CustomExpandIcon.js +7 -1
  178. package/lib/cjs/table/Table.d.ts +2 -0
  179. package/lib/cjs/table/Table.js +31 -15
  180. package/lib/cjs/table/TableCell.d.ts +2 -0
  181. package/lib/cjs/table/TableCell.js +6 -2
  182. package/lib/cjs/table/TableHeaderRow.js +8 -2
  183. package/lib/cjs/tabs/TabBar.js +11 -3
  184. package/lib/cjs/tabs/TabPane.js +3 -1
  185. package/lib/cjs/tabs/index.js +0 -1
  186. package/lib/cjs/tagInput/index.d.ts +4 -1
  187. package/lib/cjs/tagInput/index.js +29 -3
  188. package/lib/cjs/timePicker/TimePicker.d.ts +12 -0
  189. package/lib/cjs/timePicker/TimePicker.js +9 -1
  190. package/lib/cjs/timePicker/index.d.ts +6 -0
  191. package/lib/cjs/timeline/index.d.ts +1 -1
  192. package/lib/cjs/timeline/index.js +1 -0
  193. package/lib/cjs/timeline/item.js +4 -2
  194. package/lib/cjs/toast/toast.js +2 -0
  195. package/lib/cjs/tooltip/TriangleArrow.js +1 -0
  196. package/lib/cjs/tooltip/TriangleArrowVertical.js +1 -0
  197. package/lib/cjs/tooltip/index.d.ts +16 -12
  198. package/lib/cjs/tooltip/index.js +55 -39
  199. package/lib/cjs/transfer/index.js +32 -14
  200. package/lib/cjs/tree/index.d.ts +1 -0
  201. package/lib/cjs/tree/index.js +15 -6
  202. package/lib/cjs/tree/treeNode.d.ts +12 -4
  203. package/lib/cjs/tree/treeNode.js +44 -4
  204. package/lib/cjs/treeSelect/index.d.ts +16 -0
  205. package/lib/cjs/treeSelect/index.js +60 -12
  206. package/lib/cjs/typography/base.js +18 -7
  207. package/lib/cjs/typography/copyable.js +6 -1
  208. package/lib/cjs/upload/fileCard.js +23 -4
  209. package/lib/cjs/upload/index.js +19 -4
  210. package/lib/es/_utils/hooks/usePrevFocus.d.ts +2 -0
  211. package/lib/es/_utils/hooks/usePrevFocus.js +15 -0
  212. package/lib/es/_utils/index.d.ts +1 -0
  213. package/lib/es/_utils/index.js +4 -1
  214. package/lib/es/anchor/index.d.ts +2 -0
  215. package/lib/es/anchor/index.js +6 -1
  216. package/lib/es/anchor/link.d.ts +4 -1
  217. package/lib/es/anchor/link.js +38 -5
  218. package/lib/es/autoComplete/index.d.ts +17 -0
  219. package/lib/es/autoComplete/index.js +21 -2
  220. package/lib/es/avatar/avatarGroup.js +2 -1
  221. package/lib/es/avatar/index.d.ts +4 -3
  222. package/lib/es/avatar/index.js +20 -11
  223. package/lib/es/banner/index.js +4 -2
  224. package/lib/es/breadcrumb/index.d.ts +3 -0
  225. package/lib/es/breadcrumb/index.js +10 -4
  226. package/lib/es/breadcrumb/item.js +2 -2
  227. package/lib/es/button/Button.d.ts +2 -0
  228. package/lib/es/button/Button.js +4 -2
  229. package/lib/es/button/buttonGroup.d.ts +3 -0
  230. package/lib/es/button/buttonGroup.js +8 -4
  231. package/lib/es/button/index.d.ts +1 -0
  232. package/lib/es/button/splitButtonGroup.d.ts +3 -0
  233. package/lib/es/button/splitButtonGroup.js +5 -2
  234. package/lib/es/card/index.d.ts +3 -0
  235. package/lib/es/card/index.js +3 -1
  236. package/lib/es/cascader/index.d.ts +14 -0
  237. package/lib/es/cascader/index.js +35 -7
  238. package/lib/es/checkbox/checkbox.d.ts +21 -1
  239. package/lib/es/checkbox/checkbox.js +50 -17
  240. package/lib/es/checkbox/checkboxGroup.d.ts +13 -1
  241. package/lib/es/checkbox/checkboxGroup.js +18 -5
  242. package/lib/es/checkbox/checkboxInner.d.ts +15 -0
  243. package/lib/es/checkbox/checkboxInner.js +20 -3
  244. package/lib/es/collapse/index.js +2 -1
  245. package/lib/es/collapse/item.d.ts +2 -1
  246. package/lib/es/collapse/item.js +16 -3
  247. package/lib/es/collapsible/index.d.ts +1 -0
  248. package/lib/es/collapsible/index.js +4 -2
  249. package/lib/es/datePicker/datePicker.d.ts +12 -0
  250. package/lib/es/datePicker/datePicker.js +14 -1
  251. package/lib/es/dropdown/dropdownItem.js +3 -1
  252. package/lib/es/dropdown/dropdownMenu.js +4 -1
  253. package/lib/es/empty/index.js +2 -1
  254. package/lib/es/form/baseForm.d.ts +9 -0
  255. package/lib/es/form/baseForm.js +3 -1
  256. package/lib/es/form/errorMessage.d.ts +4 -0
  257. package/lib/es/form/errorMessage.js +21 -3
  258. package/lib/es/form/field.d.ts +7 -0
  259. package/lib/es/form/hoc/withField.js +48 -15
  260. package/lib/es/form/index.d.ts +0 -1
  261. package/lib/es/form/index.js +0 -1
  262. package/lib/es/form/interface.d.ts +2 -0
  263. package/lib/es/form/label.d.ts +2 -0
  264. package/lib/es/form/label.js +5 -2
  265. package/lib/es/input/index.d.ts +16 -0
  266. package/lib/es/input/index.js +51 -15
  267. package/lib/es/input/inputGroup.d.ts +2 -1
  268. package/lib/es/input/inputGroup.js +11 -1
  269. package/lib/es/input/textarea.js +12 -1
  270. package/lib/es/inputNumber/index.d.ts +8 -0
  271. package/lib/es/inputNumber/index.js +33 -2
  272. package/lib/es/layout/Sider.d.ts +4 -0
  273. package/lib/es/layout/Sider.js +4 -1
  274. package/lib/es/layout/index.js +2 -0
  275. package/lib/es/list/item.js +0 -1
  276. package/lib/es/modal/Modal.js +2 -0
  277. package/lib/es/modal/ModalContent.d.ts +3 -1
  278. package/lib/es/modal/ModalContent.js +46 -5
  279. package/lib/es/navigation/Item.d.ts +4 -2
  280. package/lib/es/navigation/Item.js +25 -5
  281. package/lib/es/navigation/SubNav.d.ts +4 -2
  282. package/lib/es/navigation/SubNav.js +8 -1
  283. package/lib/es/navigation/index.js +2 -0
  284. package/lib/es/notification/notice.d.ts +1 -1
  285. package/lib/es/notification/notice.js +33 -24
  286. package/lib/es/pagination/index.js +16 -6
  287. package/lib/es/popover/index.js +7 -3
  288. package/lib/es/progress/index.d.ts +8 -0
  289. package/lib/es/progress/index.js +42 -9
  290. package/lib/es/radio/radio.d.ts +6 -1
  291. package/lib/es/radio/radio.js +16 -5
  292. package/lib/es/radio/radioGroup.d.ts +16 -1
  293. package/lib/es/radio/radioGroup.js +18 -3
  294. package/lib/es/radio/radioInner.d.ts +6 -1
  295. package/lib/es/radio/radioInner.js +11 -3
  296. package/lib/es/rating/index.d.ts +14 -0
  297. package/lib/es/rating/index.js +14 -3
  298. package/lib/es/rating/item.d.ts +2 -0
  299. package/lib/es/rating/item.js +6 -1
  300. package/lib/es/select/index.d.ts +16 -0
  301. package/lib/es/select/index.js +63 -17
  302. package/lib/es/select/option.js +28 -22
  303. package/lib/es/sideSheet/SideSheetContent.d.ts +1 -0
  304. package/lib/es/sideSheet/SideSheetContent.js +12 -5
  305. package/lib/es/sideSheet/index.d.ts +1 -0
  306. package/lib/es/sideSheet/index.js +2 -1
  307. package/lib/es/slider/index.d.ts +2 -1
  308. package/lib/es/slider/index.js +63 -16
  309. package/lib/es/spin/icon.js +2 -4
  310. package/lib/es/steps/basicStep.d.ts +3 -0
  311. package/lib/es/steps/basicStep.js +23 -23
  312. package/lib/es/steps/basicSteps.d.ts +1 -0
  313. package/lib/es/steps/basicSteps.js +2 -1
  314. package/lib/es/steps/fillStep.d.ts +3 -0
  315. package/lib/es/steps/fillStep.js +19 -4
  316. package/lib/es/steps/fillSteps.d.ts +1 -0
  317. package/lib/es/steps/fillSteps.js +2 -1
  318. package/lib/es/steps/navStep.d.ts +3 -0
  319. package/lib/es/steps/navStep.js +22 -23
  320. package/lib/es/steps/navSteps.d.ts +1 -0
  321. package/lib/es/steps/navSteps.js +2 -1
  322. package/lib/es/switch/index.d.ts +12 -0
  323. package/lib/es/switch/index.js +19 -4
  324. package/lib/es/table/Body/BaseRow.js +35 -3
  325. package/lib/es/table/Body/index.js +9 -2
  326. package/lib/es/table/ColumnFilter.js +4 -0
  327. package/lib/es/table/ColumnSelection.d.ts +3 -0
  328. package/lib/es/table/ColumnSelection.js +6 -2
  329. package/lib/es/table/ColumnSorter.js +17 -3
  330. package/lib/es/table/CustomExpandIcon.js +6 -1
  331. package/lib/es/table/Table.d.ts +2 -0
  332. package/lib/es/table/Table.js +31 -15
  333. package/lib/es/table/TableCell.d.ts +2 -0
  334. package/lib/es/table/TableCell.js +6 -2
  335. package/lib/es/table/TableHeaderRow.js +8 -2
  336. package/lib/es/tabs/TabBar.js +11 -3
  337. package/lib/es/tabs/TabPane.js +3 -1
  338. package/lib/es/tabs/index.js +0 -1
  339. package/lib/es/tagInput/index.d.ts +4 -1
  340. package/lib/es/tagInput/index.js +29 -3
  341. package/lib/es/timePicker/TimePicker.d.ts +12 -0
  342. package/lib/es/timePicker/TimePicker.js +9 -1
  343. package/lib/es/timePicker/index.d.ts +6 -0
  344. package/lib/es/timeline/index.d.ts +1 -1
  345. package/lib/es/timeline/index.js +1 -0
  346. package/lib/es/timeline/item.js +4 -2
  347. package/lib/es/toast/toast.js +2 -0
  348. package/lib/es/tooltip/TriangleArrow.js +1 -0
  349. package/lib/es/tooltip/TriangleArrowVertical.js +1 -0
  350. package/lib/es/tooltip/index.d.ts +16 -12
  351. package/lib/es/tooltip/index.js +53 -39
  352. package/lib/es/transfer/index.js +32 -14
  353. package/lib/es/tree/index.d.ts +1 -0
  354. package/lib/es/tree/index.js +15 -6
  355. package/lib/es/tree/treeNode.d.ts +12 -4
  356. package/lib/es/tree/treeNode.js +44 -4
  357. package/lib/es/treeSelect/index.d.ts +16 -0
  358. package/lib/es/treeSelect/index.js +57 -10
  359. package/lib/es/typography/base.js +17 -7
  360. package/lib/es/typography/copyable.js +5 -1
  361. package/lib/es/upload/fileCard.js +23 -4
  362. package/lib/es/upload/index.js +19 -4
  363. package/list/item.tsx +0 -1
  364. package/modal/Modal.tsx +2 -0
  365. package/modal/ModalContent.tsx +35 -5
  366. package/navigation/Item.tsx +15 -0
  367. package/navigation/SubNav.tsx +13 -1
  368. package/navigation/index.tsx +1 -1
  369. package/notification/notice.tsx +19 -14
  370. package/package.json +8 -8
  371. package/pagination/index.tsx +9 -5
  372. package/popover/index.tsx +5 -0
  373. package/progress/_story/progress.stories.js +18 -18
  374. package/progress/index.tsx +58 -20
  375. package/radio/radio.tsx +12 -2
  376. package/radio/radioGroup.tsx +29 -3
  377. package/radio/radioInner.tsx +10 -1
  378. package/rating/index.tsx +19 -2
  379. package/rating/item.tsx +6 -0
  380. package/select/__test__/select.test.js +45 -0
  381. package/select/_story/select.stories.js +29 -0
  382. package/select/index.tsx +52 -4
  383. package/select/option.tsx +3 -0
  384. package/sideSheet/SideSheetContent.tsx +13 -9
  385. package/sideSheet/index.tsx +3 -2
  386. package/slider/__test__/slider.test.js +9 -0
  387. package/slider/_story/slider.stories.js +1 -1
  388. package/slider/index.tsx +44 -7
  389. package/spin/icon.tsx +3 -3
  390. package/steps/basicStep.tsx +15 -4
  391. package/steps/basicSteps.tsx +3 -2
  392. package/steps/fillStep.tsx +27 -12
  393. package/steps/fillSteps.tsx +2 -0
  394. package/steps/navStep.tsx +15 -4
  395. package/steps/navSteps.tsx +3 -2
  396. package/switch/_story/switch.stories.js +20 -19
  397. package/switch/_story/switch.stories.tsx +13 -13
  398. package/switch/index.tsx +23 -5
  399. package/table/Body/BaseRow.tsx +25 -1
  400. package/table/Body/index.tsx +7 -2
  401. package/table/ColumnFilter.tsx +7 -1
  402. package/table/ColumnSelection.tsx +4 -1
  403. package/table/ColumnSorter.tsx +18 -1
  404. package/table/CustomExpandIcon.tsx +5 -0
  405. package/table/Table.tsx +26 -13
  406. package/table/TableCell.tsx +11 -1
  407. package/table/TableHeaderRow.tsx +16 -2
  408. package/table/__test__/table.test.js +46 -0
  409. package/tabs/TabBar.tsx +8 -5
  410. package/tabs/TabPane.tsx +3 -1
  411. package/tabs/index.tsx +0 -1
  412. package/tagInput/__test__/tagInput.test.js +46 -0
  413. package/tagInput/_story/tagInput.stories.js +2 -2
  414. package/tagInput/index.tsx +31 -8
  415. package/timePicker/TimePicker.tsx +14 -1
  416. package/timeline/_story/timeline.stories.js +1 -1
  417. package/timeline/index.tsx +2 -2
  418. package/timeline/item.tsx +2 -1
  419. package/toast/toast.tsx +2 -0
  420. package/tooltip/TriangleArrow.tsx +1 -1
  421. package/tooltip/TriangleArrowVertical.tsx +1 -1
  422. package/tooltip/_story/tooltip.stories.js +562 -514
  423. package/tooltip/index.tsx +50 -33
  424. package/transfer/index.tsx +29 -25
  425. package/tree/_story/tree.stories.js +3 -3
  426. package/tree/index.tsx +10 -2
  427. package/tree/treeNode.tsx +46 -10
  428. package/treeSelect/__test__/treeMultiple.test.js +5 -0
  429. package/treeSelect/_story/treeSelect.stories.js +12 -0
  430. package/treeSelect/index.tsx +58 -7
  431. package/typography/base.tsx +7 -1
  432. package/typography/copyable.tsx +10 -1
  433. package/upload/fileCard.tsx +13 -15
  434. package/upload/index.tsx +10 -6
package/tooltip/index.tsx CHANGED
@@ -12,6 +12,7 @@ import { ArrayElement } from '@douyinfe/semi-foundation/utils/type';
12
12
  import { convertDOMRectToObject, DOMRectLikeType } from '@douyinfe/semi-foundation/utils/dom';
13
13
  import TooltipFoundation, { TooltipAdapter, Position, PopupContainerDOMRect } from '@douyinfe/semi-foundation/tooltip/foundation';
14
14
  import { strings, cssClasses, numbers } from '@douyinfe/semi-foundation/tooltip/constants';
15
+ import { getUuidv4 } from '@douyinfe/semi-foundation/utils/uuid';
15
16
  import '@douyinfe/semi-foundation/tooltip/tooltip.scss';
16
17
 
17
18
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
@@ -56,6 +57,7 @@ export interface TooltipProps extends BaseProps {
56
57
  showArrow?: boolean | React.ReactNode;
57
58
  zIndex?: number;
58
59
  rePosKey?: string | number;
60
+ role?: string;
59
61
  arrowBounding?: ArrowBounding;
60
62
  transformFromCenter?: boolean;
61
63
  arrowPointAtCenter?: boolean;
@@ -77,6 +79,8 @@ interface TooltipState {
77
79
  isInsert: boolean;
78
80
  placement: Position;
79
81
  transitionStyle: Record<string, any>;
82
+ isPositionUpdated: boolean;
83
+ id: string;
80
84
  }
81
85
 
82
86
  const prefix = cssClasses.PREFIX;
@@ -117,26 +121,28 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
117
121
  arrowPointAtCenter: PropTypes.bool,
118
122
  stopPropagation: PropTypes.bool,
119
123
  // private
124
+ role: PropTypes.string,
120
125
  wrapWhenSpecial: PropTypes.bool, // when trigger has special status such as "disabled" or "loading", wrap span
121
126
  };
122
127
 
123
128
  static defaultProps = {
124
- transformFromCenter: true,
129
+ arrowBounding: numbers.ARROW_BOUNDING,
130
+ autoAdjustOverflow: true,
125
131
  arrowPointAtCenter: true,
126
- wrapWhenSpecial: true,
127
- motion: true,
128
- zIndex: numbers.DEFAULT_Z_INDEX,
129
132
  trigger: 'hover',
133
+ transformFromCenter: true,
130
134
  position: 'top',
131
135
  prefixCls: prefix,
132
- autoAdjustOverflow: true,
136
+ role: 'tooltip',
133
137
  mouseEnterDelay: numbers.MOUSE_ENTER_DELAY,
134
138
  mouseLeaveDelay: numbers.MOUSE_LEAVE_DELAY,
139
+ motion: true,
135
140
  onVisibleChange: noop,
136
141
  onClickOutSide: noop,
137
142
  spacing: numbers.SPACING,
138
143
  showArrow: true,
139
- arrowBounding: numbers.ARROW_BOUNDING,
144
+ wrapWhenSpecial: true,
145
+ zIndex: numbers.DEFAULT_Z_INDEX,
140
146
  };
141
147
 
142
148
  eventManager: Event;
@@ -167,6 +173,8 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
167
173
  isInsert: false,
168
174
  placement: props.position || 'top',
169
175
  transitionStyle: {},
176
+ isPositionUpdated: false,
177
+ id: getUuidv4(), // auto generate id, will be used by children.aria-descriptionby & content.id, improve a11y
170
178
  };
171
179
  this.foundation = new TooltipFoundation(this.adapter);
172
180
  this.eventManager = new Event();
@@ -197,18 +205,15 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
197
205
  containerStyle: { ...this.state.containerStyle, ...containerStyle },
198
206
  },
199
207
  () => {
200
- /**
201
- * Dangerous: remove setTimeout from here fix #1301
202
- * setTimeout may emit portalInserted event after hiding portal
203
- * Hiding portal will remove portalInserted event listener(normal process)
204
- * then portal can't hide because _togglePortalVisible(false) will found isVisible=false and nowVisible=false(bug here)
205
- */
206
- this.eventManager.emit('portalInserted');
208
+ setTimeout(() => {
209
+ // waiting child component mounted
210
+ this.eventManager.emit('portalInserted');
211
+ }, 0);
207
212
  }
208
213
  );
209
214
  },
210
215
  removePortal: () => {
211
- this.setState({ isInsert: false });
216
+ this.setState({ isInsert: false, isPositionUpdated: false });
212
217
  },
213
218
  getEventName: () => ({
214
219
  mouseEnter: 'onMouseEnter',
@@ -275,7 +280,11 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
275
280
  getDocumentElementBounding: () => document.documentElement.getBoundingClientRect(),
276
281
  setPosition: ({ position, ...style }: { position: Position }) => {
277
282
  this.setState(
278
- { containerStyle: { ...this.state.containerStyle, ...style }, placement: position },
283
+ {
284
+ containerStyle: { ...this.state.containerStyle, ...style },
285
+ placement: position,
286
+ isPositionUpdated: true
287
+ },
279
288
  () => {
280
289
  this.eventManager.emit('positionUpdated');
281
290
  }
@@ -422,16 +431,10 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
422
431
  return false;
423
432
  };
424
433
 
425
- willEnter = () => {
426
- this.foundation.calcPosition();
427
- /**
428
- * Dangerous: remove setState in motion fix #1379
429
- * because togglePortalVisible callback function will use visible state to notifyVisibleChange
430
- * if visible state is old value, then notifyVisibleChange function will not be called
431
- * we should ensure that after calling togglePortalVisible, callback function can get right visible value
432
- */
433
- // this.setState({ visible: true });
434
- };
434
+ // willEnter = () => {
435
+ // this.foundation.calcPosition();
436
+ // this.setState({ visible: true });
437
+ // };
435
438
 
436
439
  didLeave = () => {
437
440
  this.adapter.unregisterClickOutsideHandler();
@@ -489,8 +492,8 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
489
492
  };
490
493
 
491
494
  renderPortal = () => {
492
- const { containerStyle = {}, visible, portalEventSet, placement, transitionState } = this.state;
493
- const { prefixCls, content, showArrow, style, motion, zIndex } = this.props;
495
+ const { containerStyle = {}, visible, portalEventSet, placement, transitionState, id, isPositionUpdated } = this.state;
496
+ const { prefixCls, content, showArrow, style, motion, role, zIndex } = this.props;
494
497
  const { className: propClassName } = this.props;
495
498
  const direction = this.context.direction;
496
499
  const className = classNames(propClassName, {
@@ -502,22 +505,24 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
502
505
  const icon = this.renderIcon();
503
506
  const portalInnerStyle = omit(containerStyle, motion ? ['transformOrigin'] : undefined);
504
507
  const transformOrigin = get(containerStyle, 'transformOrigin');
505
- const inner = motion ? (
506
- <TooltipTransition position={placement} willEnter={this.willEnter} didLeave={this.didLeave} motion={motion}>
508
+ const inner = motion && isPositionUpdated ? (
509
+ <TooltipTransition position={placement} didLeave={this.didLeave} motion={motion}>
507
510
  {
508
511
  transitionState === 'enter' ?
509
512
  ({ animateCls, animateStyle, animateEvents }) => (
510
513
  <div
511
514
  className={classNames(className, animateCls)}
512
515
  style={{
513
- visibility: 'visible',
516
+ // visibility: 'visible',
514
517
  ...animateStyle,
515
518
  transformOrigin,
516
519
  ...style,
517
520
  }}
518
521
  {...portalEventSet}
519
522
  {...animateEvents}
523
+ role={role}
520
524
  x-placement={placement}
525
+ id={id}
521
526
  >
522
527
  {content}
523
528
  {icon}
@@ -580,8 +585,8 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
580
585
  };
581
586
 
582
587
  render() {
583
- const { isInsert, triggerEventSet } = this.state;
584
- const { wrapWhenSpecial } = this.props;
588
+ const { isInsert, triggerEventSet, visible, id } = this.state;
589
+ const { wrapWhenSpecial, role } = this.props;
585
590
  let { children } = this.props;
586
591
  const childrenStyle = { ...get(children, 'props.style') };
587
592
  const extraStyle: React.CSSProperties = {};
@@ -605,8 +610,21 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
605
610
  }
606
611
  }
607
612
 
613
+ // eslint-disable-next-line prefer-const
614
+ let ariaAttribute = {};
615
+
616
+ // Take effect when used by Popover component
617
+ if (role === 'dialog') {
618
+ ariaAttribute['aria-expanded'] = visible ? 'true' : 'false';
619
+ ariaAttribute['aria-haspopup'] = 'dialog';
620
+ ariaAttribute['aria-controls'] = id;
621
+ } else {
622
+ ariaAttribute['aria-describedby'] = id;
623
+ }
624
+
608
625
  // The incoming children is a single valid element, otherwise wrap a layer with span
609
626
  const newChild = React.cloneElement(children as React.ReactElement, {
627
+ ...ariaAttribute,
610
628
  ...(children as React.ReactElement).props,
611
629
  ...this.mergeEvents((children as React.ReactElement).props, triggerEventSet),
612
630
  style: {
@@ -615,7 +633,6 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
615
633
  },
616
634
  className: classNames(
617
635
  get(children, 'props.className')
618
- // `${prefixCls}-trigger`
619
636
  ),
620
637
  // to maintain refs with callback
621
638
  ref: (node: React.ReactNode) => {
@@ -291,7 +291,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
291
291
  return null;
292
292
  }
293
293
  return (
294
- <div className={`${prefixcls }-filter`}>
294
+ <div role="search" aria-label="Transfer filter" className={`${prefixcls}-filter`}>
295
295
  <Input
296
296
  prefix={<IconSearch />}
297
297
  placeholder={locale.placeholder}
@@ -309,20 +309,20 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
309
309
  const { disabled } = this.props;
310
310
  const { totalContent, allContent, onAllClick, type, showButton } = headerConfig;
311
311
  const headerCls = cls({
312
- [`${prefixcls }-header`]: true,
313
- [`${prefixcls }-right-header`]: type === 'right',
314
- [`${prefixcls }-left-header`]: type === 'left',
312
+ [`${prefixcls}-header`]: true,
313
+ [`${prefixcls}-right-header`]: type === 'right',
314
+ [`${prefixcls}-left-header`]: type === 'left',
315
315
  });
316
316
  return (
317
317
  <div className={headerCls}>
318
- <span className={`${prefixcls }-header-total`}>{totalContent}</span>
318
+ <span className={`${prefixcls}-header-total`}>{totalContent}</span>
319
319
  {showButton ? (
320
320
  <Button
321
321
  theme="borderless"
322
322
  disabled={disabled}
323
323
  type="tertiary"
324
324
  size="small"
325
- className={`${prefixcls }-header-all`}
325
+ className={`${prefixcls}-header-all`}
326
326
  onClick={onAllClick}
327
327
  >
328
328
  {allContent}
@@ -340,8 +340,8 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
340
340
  return renderSourceItem({ ...item, checked, onChange: () => this.onSelectOrRemove(item) });
341
341
  }
342
342
  const leftItemCls = cls({
343
- [`${prefixcls }-item`]: true,
344
- [`${prefixcls }-item-disabled`]: item.disabled,
343
+ [`${prefixcls}-item`]: true,
344
+ [`${prefixcls}-item-disabled`]: item.disabled,
345
345
  });
346
346
  return (
347
347
  <Checkbox
@@ -349,6 +349,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
349
349
  disabled={item.disabled || disabled}
350
350
  className={leftItemCls}
351
351
  checked={checked}
352
+ role="listitem"
352
353
  onChange={() => this.onSelectOrRemove(item)}
353
354
  >
354
355
  {item.label}
@@ -438,7 +439,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
438
439
  }
439
440
 
440
441
  return (
441
- <section className={`${prefixcls }-left`}>
442
+ <section className={`${prefixcls}-left`}>
442
443
  {inputCom}
443
444
  {content}
444
445
  </section>
@@ -501,7 +502,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
501
502
  content.push(optionContent);
502
503
  }
503
504
  });
504
- return <div className={`${prefixcls }-left-list`}>{content}</div>;
505
+ return <div className={`${prefixcls}-left-list`} role="list" aria-label="Option list">{content}</div>;
505
506
  }
506
507
 
507
508
  renderRightItem(item: ResolvedDataItem): React.ReactNode {
@@ -513,9 +514,9 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
513
514
  }
514
515
  const onRemove = () => this.foundation.handleSelectOrRemove(newItem);
515
516
  const rightItemCls = cls({
516
- [`${prefixcls }-item`]: true,
517
- [`${prefixcls }-right-item`]: true,
518
- [`${prefixcls }-right-item-draggable`]: draggable
517
+ [`${prefixcls}-item`]: true,
518
+ [`${prefixcls}-right-item`]: true,
519
+ [`${prefixcls}-right-item-draggable`]: draggable
519
520
  });
520
521
  const shouldShowPath = type === strings.TYPE_TREE_TO_LIST && showPath === true;
521
522
 
@@ -526,15 +527,18 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
526
527
  }
527
528
 
528
529
  const DragHandle = SortableHandle(() => (
529
- <IconHandle className={`${prefixcls }-right-item-drag-handler`} />
530
+ <IconHandle role="button" aria-label="Drag and sort" className={`${prefixcls}-right-item-drag-handler`} />
530
531
  ));
531
532
 
532
533
  return (
533
- <div className={rightItemCls} key={newItem.key}>
534
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
535
+ <div role="listitem" className={rightItemCls} key={newItem.key}>
534
536
  {draggable ? <DragHandle /> : null}
535
537
  <div className={`${prefixcls}-right-item-text`}>{label}</div>
536
538
  <IconClose
537
- onClick={onRemove} className={cls(`${prefixcls}-item-close-icon`, {
539
+ onClick={onRemove}
540
+ aria-disabled={item.disabled}
541
+ className={cls(`${prefixcls}-item-close-icon`, {
538
542
  [`${prefixcls}-item-close-icon-disabled`]: item.disabled
539
543
  })}
540
544
  />
@@ -544,11 +548,11 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
544
548
 
545
549
  renderEmpty(type: string, emptyText: React.ReactNode) {
546
550
  const emptyCls = cls({
547
- [`${prefixcls }-empty`]: true,
548
- [`${prefixcls }-right-empty`]: type === 'right',
549
- [`${prefixcls }-left-empty`]: type === 'left',
551
+ [`${prefixcls}-empty`]: true,
552
+ [`${prefixcls}-right-empty`]: type === 'right',
553
+ [`${prefixcls}-left-empty`]: type === 'left',
550
554
  });
551
- return <div className={emptyCls}>{emptyText}</div>;
555
+ return <div aria-label="empty" className={emptyCls}>{emptyText}</div>;
552
556
  }
553
557
 
554
558
  renderRightSortableList(selectedData: Array<ResolvedDataItem>) {
@@ -557,7 +561,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
557
561
  (item: ResolvedDataItem) => this.renderRightItem(item)) as React.SFC<ResolvedDataItem>
558
562
  );
559
563
  const SortableList = SortableContainer(({ items }: { items: Array<ResolvedDataItem> }) => (
560
- <div className={`${prefixcls}-right-list`}>
564
+ <div className={`${prefixcls}-right-list`} role="list" aria-label="Selected list">
561
565
  {items.map((item, index: number) => (
562
566
  // sortableElement will take over the property 'key', so use another '_optionKey' to pass
563
567
  <SortableItem key={item.label} index={index} {...item} _optionKey={item.key} />
@@ -597,7 +601,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
597
601
  };
598
602
  const headerCom = this.renderHeader(headerConfig);
599
603
  const emptyCom = this.renderEmpty('right', emptyContent.right ? emptyContent.right : locale.emptyRight);
600
- const panelCls = `${prefixcls }-right`;
604
+ const panelCls = `${prefixcls}-right`;
601
605
 
602
606
  let content = null;
603
607
 
@@ -608,7 +612,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
608
612
  break;
609
613
  case selectedData.length && !draggable:
610
614
  const list = (
611
- <div className={`${prefixcls }-right-list`}>
615
+ <div className={`${prefixcls}-right-list`} role="list" aria-label="Selected list">
612
616
  {selectedData.map(item => this.renderRightItem({ ...item }))}
613
617
  </div>
614
618
  );
@@ -632,8 +636,8 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
632
636
  render() {
633
637
  const { className, style, disabled, renderSelectedPanel, renderSourcePanel } = this.props;
634
638
  const transferCls = cls(prefixcls, className, {
635
- [`${prefixcls }-disabled`]: disabled,
636
- [`${prefixcls }-custom-panel`]: renderSelectedPanel && renderSourcePanel,
639
+ [`${prefixcls}-disabled`]: disabled,
640
+ [`${prefixcls}-custom-panel`]: renderSelectedPanel && renderSourcePanel,
637
641
  });
638
642
 
639
643
  return (
@@ -1279,7 +1279,7 @@ const RefSearch = () => {
1279
1279
  ];
1280
1280
  return (
1281
1281
  <div>
1282
- <Input onChange={v => ref.current.search(v)} />
1282
+ <Input aria-label='filter tree' onChange={v => ref.current.search(v)} />
1283
1283
  <Tree
1284
1284
  treeData={treeData}
1285
1285
  defaultValue="Shanghai"
@@ -1814,7 +1814,7 @@ const MutipleHLTree = () => {
1814
1814
  : 'transparent',
1815
1815
  };
1816
1816
  return (
1817
- <li className={className} role="treenode" onClick={onClick} style={style}>
1817
+ <li className={className} role="treeitem" onClick={onClick} style={style}>
1818
1818
  {isLeaf ? null : expandIcon}
1819
1819
  {icon ? icon : null}
1820
1820
  <span>{label}</span>
@@ -2141,7 +2141,7 @@ export const RenderFullLabelWithDraggable = () => {
2141
2141
  : 'transparent',
2142
2142
  };
2143
2143
  return (
2144
- <li className={className} role="treenode" onClick={onClick} style={style}>
2144
+ <li className={className} role="treeitem" onClick={onClick} style={style}>
2145
2145
  {isLeaf ? <span style={{ width: 24 }}></span> : expandIcon}
2146
2146
  {icon ? icon : null}
2147
2147
  <span>{label}</span>
package/tree/index.tsx CHANGED
@@ -112,6 +112,7 @@ class Tree extends BaseComponent<TreeProps, TreeState> {
112
112
  onDragStart: PropTypes.func,
113
113
  onDrop: PropTypes.func,
114
114
  labelEllipsis: PropTypes.bool,
115
+ 'aria-label': PropTypes.string,
115
116
  };
116
117
 
117
118
  static defaultProps = {
@@ -511,6 +512,7 @@ class Tree extends BaseComponent<TreeProps, TreeState> {
511
512
  }
512
513
  return (
513
514
  <Input
515
+ aria-label='Filter Tree'
514
516
  ref={this.inputRef as any}
515
517
  {...inputProps}
516
518
  />
@@ -701,6 +703,12 @@ class Tree extends BaseComponent<TreeProps, TreeState> {
701
703
  });
702
704
  const searchNoRes = Boolean(inputValue) && !filteredKeys.size;
703
705
  const noData = isEmpty(keyEntities) || (showFilteredOnly && searchNoRes);
706
+ const ariaAttr = {
707
+ role: noData ? 'none' : 'tree'
708
+ };
709
+ if (ariaAttr.role === 'tree'){
710
+ ariaAttr['aria-multiselectable'] = multiple ? true : false;
711
+ }
704
712
  return (
705
713
  <TreeContext.Provider
706
714
  value={{
@@ -739,9 +747,9 @@ class Tree extends BaseComponent<TreeProps, TreeState> {
739
747
  labelEllipsis: typeof labelEllipsis === 'undefined' ? virtualize : labelEllipsis,
740
748
  }}
741
749
  >
742
- <div className={wrapperCls} role="list-box" style={style}>
750
+ <div aria-label={this.props['aria-label']} className={wrapperCls} style={style}>
743
751
  {filterTreeNode ? this.renderInput() : null}
744
- <div className={listCls} role="tree">
752
+ <div className={listCls} {...ariaAttr}>
745
753
  {noData ? this.renderEmpty() : this.renderNodeList()}
746
754
  </div>
747
755
  </div>
package/tree/treeNode.tsx CHANGED
@@ -2,7 +2,8 @@ import React, { PureComponent } from 'react';
2
2
  import cls from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
4
  import { cssClasses } from '@douyinfe/semi-foundation/tree/constants';
5
- import { debounce, isFunction, isString } from 'lodash';
5
+ import isEnterPress from '@douyinfe/semi-foundation/utils/isEnterPress';
6
+ import { debounce, isFunction, isString, get } from 'lodash';
6
7
  import { IconTreeTriangleDown, IconFile, IconFolder, IconFolderOpen } from '@douyinfe/semi-icons';
7
8
  import { Checkbox } from '../checkbox';
8
9
  import TreeContext from './treeContext';
@@ -51,19 +52,19 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
51
52
  });
52
53
  }
53
54
 
54
- onSelect = (e: React.MouseEvent) => {
55
+ onSelect = (e: React.MouseEvent | React.KeyboardEvent) => {
55
56
  const { onNodeSelect } = this.context;
56
57
  onNodeSelect(e, this.props);
57
58
  };
58
59
 
59
- onExpand = (e: React.MouseEvent) => {
60
+ onExpand = (e: React.MouseEvent | React.KeyboardEvent) => {
60
61
  const { onNodeExpand } = this.context;
61
62
  e && e.stopPropagation();
62
63
  e.nativeEvent.stopImmediatePropagation();
63
64
  onNodeExpand(e, this.props);
64
65
  };
65
66
 
66
- onCheck = (e: React.MouseEvent) => {
67
+ onCheck = (e: React.MouseEvent | React.KeyboardEvent) => {
67
68
  if (this.isDisabled()) {
68
69
  return;
69
70
  }
@@ -73,12 +74,21 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
73
74
  onNodeCheck(e, this.props);
74
75
  };
75
76
 
77
+ /**
78
+ * A11y: simulate checkbox click
79
+ */
80
+ handleCheckEnterPress = (e: React.KeyboardEvent) => {
81
+ if (isEnterPress(e)) {
82
+ this.onCheck(e);
83
+ }
84
+ }
85
+
76
86
  onContextMenu = (e: React.MouseEvent) => {
77
87
  const { onNodeRightClick } = this.context;
78
88
  onNodeRightClick(e, this.props);
79
89
  };
80
90
 
81
- onClick = (e: React.MouseEvent) => {
91
+ onClick = (e: React.MouseEvent | React.KeyboardEvent) => {
82
92
  const { expandAction } = this.context;
83
93
  if (expandAction === 'doubleClick') {
84
94
  this.debounceSelect(e);
@@ -90,6 +100,15 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
90
100
  }
91
101
  };
92
102
 
103
+ /**
104
+ * A11y: simulate li click
105
+ */
106
+ handleliEnterPress = (e: React.KeyboardEvent) => {
107
+ if (isEnterPress(e)) {
108
+ this.onClick(e);
109
+ }
110
+ }
111
+
93
112
  onDoubleClick = (e: React.MouseEvent) => {
94
113
  const { expandAction, onNodeDoubleClick } = this.context;
95
114
  e.stopPropagation();
@@ -179,13 +198,15 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
179
198
 
180
199
  renderArrow() {
181
200
  const showIcon = !this.isLeaf();
182
- const { loading } = this.props;
201
+ const { loading, expanded } = this.props;
183
202
  if (loading) {
184
203
  return <Spin wrapperClassName={`${prefixcls}-spin-icon`} />;
185
204
  }
186
205
  if (showIcon) {
187
206
  return (
188
207
  <IconTreeTriangleDown
208
+ role='button'
209
+ aria-label={`${expanded ? 'Expand' : 'Collapse'} the tree item`}
189
210
  className={`${prefixcls}-expand-icon`}
190
211
  size="small"
191
212
  onClick={this.onExpand}
@@ -201,8 +222,13 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
201
222
  const { checked, halfChecked } = this.props;
202
223
  const disabled = this.isDisabled();
203
224
  return (
204
- <div onClick={this.onCheck}>
225
+ <div
226
+ role='none'
227
+ onClick={this.onCheck}
228
+ onKeyPress={this.handleCheckEnterPress}
229
+ >
205
230
  <Checkbox
231
+ aria-label='Toggle the checked state of checkbox'
206
232
  indeterminate={halfChecked}
207
233
  checked={checked}
208
234
  disabled={Boolean(disabled)}
@@ -242,9 +268,9 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
242
268
  });
243
269
  return (
244
270
  <ul className={wrapperCls}>
245
- <span className={`${prefixcls}-label ${prefixcls}-label-empty`}>
271
+ <li className={`${prefixcls}-label ${prefixcls}-label-empty`}>
246
272
  {emptyContent}
247
- </span>
273
+ </li>
248
274
  </ul>
249
275
  );
250
276
  }
@@ -373,12 +399,22 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
373
399
  [`${prefixcls}-drag-over-gap-top`]: !disabled && dragOverGapTop,
374
400
  [`${prefixcls}-drag-over-gap-bottom`]: !disabled && dragOverGapBottom,
375
401
  });
402
+ const setsize = get(rest, ['data', 'children', 'length']);
403
+ const posinset = isString(rest.pos) ? Number(rest.pos.split('-')[level+1]) + 1 : 1;
376
404
  return (
377
405
  <li
378
406
  className={nodeCls}
379
- role="treenode"
407
+ role="treeitem"
408
+ aria-disabled={disabled}
409
+ aria-checked={checked}
410
+ aria-selected={selected}
411
+ aria-setsize={setsize}
412
+ aria-posinset={posinset}
413
+ aria-expanded={expanded}
414
+ aria-level={level+1}
380
415
  data-key={eventKey}
381
416
  onClick={this.onClick}
417
+ onKeyPress={this.handleliEnterPress}
382
418
  onContextMenu={this.onContextMenu}
383
419
  onDoubleClick={this.onDoubleClick}
384
420
  ref={this.setRef}
@@ -632,7 +632,12 @@ describe('TreeSelect', () => {
632
632
  searchPosition: 'trigger',
633
633
  filterTreeNode: true,
634
634
  multiple: true,
635
+ maxTagCount: 1,
636
+ defaultValue: ['Zhongguo', 'Meiguo']
635
637
  });
638
+ const selection = treeSelect.find(`.${BASE_CLASS_PREFIX}-tree-select .${BASE_CLASS_PREFIX}-tree-select-selection`);
639
+ expect(selection.find(`.${BASE_CLASS_PREFIX}-tagInput .${BASE_CLASS_PREFIX}-tag`).length).toEqual(1);
640
+ expect(selection.find(`.${BASE_CLASS_PREFIX}-tagInput .${BASE_CLASS_PREFIX}-tagInput-wrapper-n`).at(0).getDOMNode().textContent).toEqual('+1');
636
641
  const input = treeSelect.find(`.${BASE_CLASS_PREFIX}-tree-select .${BASE_CLASS_PREFIX}-tagInput .${BASE_CLASS_PREFIX}-input`);
637
642
  const searchValue = '北';
638
643
  const event = { target: { value: searchValue } };
@@ -299,6 +299,18 @@ export const SearchPosition = () => (
299
299
  placeholder="searchAutoFocus"
300
300
  searchAutoFocus
301
301
  />
302
+ <br />
303
+ <br />
304
+ <TreeSelect
305
+ searchPosition="trigger"
306
+ style={{ width: 300 }}
307
+ dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
308
+ treeData={treeData2}
309
+ multiple
310
+ filterTreeNode
311
+ maxTagCount={1}
312
+ placeholder="maxTagCount=1"
313
+ />
302
314
  </>
303
315
  );
304
316