@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.
- package/_base/_story/a11y.jsx +6 -6
- package/_base/_story/a11y.scss +0 -1
- package/_base/_story/index.scss +2 -5
- package/_utils/hooks/usePrevFocus.ts +16 -0
- package/_utils/index.ts +4 -0
- package/anchor/_story/anchor.stories.js +1 -1
- package/anchor/index.tsx +5 -2
- package/anchor/link.tsx +29 -4
- package/autoComplete/index.tsx +28 -1
- package/avatar/_story/avatar.stories.js +4 -4
- package/avatar/index.tsx +6 -4
- package/banner/index.tsx +2 -1
- package/breadcrumb/_story/breadcrumb.stories.js +22 -8
- package/breadcrumb/index.tsx +8 -1
- package/breadcrumb/item.tsx +1 -1
- package/button/Button.tsx +4 -0
- package/button/__test__/button.test.js +1 -1
- package/button/_story/button.stories.js +10 -10
- package/button/buttonGroup.tsx +4 -2
- package/button/splitButtonGroup.tsx +5 -2
- package/card/_story/card.stories.js +8 -1
- package/card/_story/card.stories.tsx +3 -0
- package/card/index.tsx +5 -2
- package/cascader/index.tsx +33 -5
- package/checkbox/_story/checkbox.stories.js +19 -12
- package/checkbox/checkbox.tsx +40 -5
- package/checkbox/checkboxGroup.tsx +30 -5
- package/checkbox/checkboxInner.tsx +25 -2
- package/collapse/index.tsx +1 -1
- package/collapse/item.tsx +12 -7
- package/collapsible/index.tsx +4 -2
- package/configProvider/_story/configProvider.stories.tsx +27 -0
- package/datePicker/__test__/datePicker.test.js +108 -0
- package/datePicker/_story/datePicker.stories.js +146 -2
- package/datePicker/datePicker.tsx +24 -0
- package/datePicker/monthsGrid.tsx +2 -1
- package/dist/css/semi.css +34 -7
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +2768 -1501
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/dropdown/dropdownItem.tsx +1 -1
- package/dropdown/dropdownMenu.tsx +1 -1
- package/empty/index.tsx +4 -4
- package/form/_story/FormApi/formApiDemo.jsx +3 -2
- package/form/_story/Validate/validateDemo.jsx +1 -1
- package/form/_story/demo.jsx +12 -3
- package/form/_story/form.stories.js +0 -7
- package/form/baseForm.tsx +2 -0
- package/form/errorMessage.tsx +13 -2
- package/form/hoc/withField.tsx +37 -8
- package/form/index.tsx +0 -2
- package/form/interface.ts +2 -0
- package/form/label.tsx +4 -2
- package/input/index.tsx +49 -4
- package/input/inputGroup.tsx +9 -4
- package/input/textarea.tsx +25 -6
- package/inputNumber/_story/inputNumber.stories.js +12 -0
- package/inputNumber/index.tsx +33 -2
- package/layout/Sider.tsx +6 -2
- package/layout/index.tsx +4 -3
- package/lib/cjs/_utils/hooks/usePrevFocus.d.ts +2 -0
- package/lib/cjs/_utils/hooks/usePrevFocus.js +30 -0
- package/lib/cjs/_utils/index.d.ts +1 -0
- package/lib/cjs/_utils/index.js +6 -1
- package/lib/cjs/anchor/index.d.ts +2 -0
- package/lib/cjs/anchor/index.js +6 -1
- package/lib/cjs/anchor/link.d.ts +4 -1
- package/lib/cjs/anchor/link.js +39 -5
- package/lib/cjs/autoComplete/index.d.ts +17 -0
- package/lib/cjs/autoComplete/index.js +21 -2
- package/lib/cjs/avatar/index.d.ts +4 -3
- package/lib/cjs/avatar/index.js +15 -11
- package/lib/cjs/banner/index.js +4 -2
- package/lib/cjs/breadcrumb/index.d.ts +3 -0
- package/lib/cjs/breadcrumb/index.js +10 -4
- package/lib/cjs/breadcrumb/item.js +2 -2
- package/lib/cjs/button/Button.d.ts +2 -0
- package/lib/cjs/button/Button.js +4 -2
- package/lib/cjs/button/buttonGroup.d.ts +3 -0
- package/lib/cjs/button/buttonGroup.js +8 -4
- package/lib/cjs/button/index.d.ts +1 -0
- package/lib/cjs/button/splitButtonGroup.d.ts +3 -0
- package/lib/cjs/button/splitButtonGroup.js +5 -2
- package/lib/cjs/card/index.d.ts +3 -0
- package/lib/cjs/card/index.js +3 -1
- package/lib/cjs/cascader/index.d.ts +14 -0
- package/lib/cjs/cascader/index.js +35 -7
- package/lib/cjs/checkbox/checkbox.d.ts +21 -1
- package/lib/cjs/checkbox/checkbox.js +51 -17
- package/lib/cjs/checkbox/checkboxGroup.d.ts +13 -1
- package/lib/cjs/checkbox/checkboxGroup.js +16 -3
- package/lib/cjs/checkbox/checkboxInner.d.ts +15 -0
- package/lib/cjs/checkbox/checkboxInner.js +20 -3
- package/lib/cjs/collapse/item.d.ts +2 -1
- package/lib/cjs/collapse/item.js +12 -2
- package/lib/cjs/collapsible/index.d.ts +1 -0
- package/lib/cjs/collapsible/index.js +4 -2
- package/lib/cjs/datePicker/datePicker.d.ts +12 -0
- package/lib/cjs/datePicker/datePicker.js +22 -3
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGrid.js +2 -1
- package/lib/cjs/dropdown/dropdownItem.js +3 -1
- package/lib/cjs/dropdown/dropdownMenu.js +4 -1
- package/lib/cjs/form/baseForm.d.ts +9 -0
- package/lib/cjs/form/baseForm.js +3 -1
- package/lib/cjs/form/errorMessage.d.ts +4 -0
- package/lib/cjs/form/errorMessage.js +21 -3
- package/lib/cjs/form/field.d.ts +7 -0
- package/lib/cjs/form/hoc/withField.js +49 -16
- package/lib/cjs/form/index.d.ts +0 -1
- package/lib/cjs/form/interface.d.ts +2 -0
- package/lib/cjs/form/label.d.ts +2 -0
- package/lib/cjs/form/label.js +5 -2
- package/lib/cjs/input/index.d.ts +16 -0
- package/lib/cjs/input/index.js +51 -15
- package/lib/cjs/input/inputGroup.d.ts +2 -1
- package/lib/cjs/input/inputGroup.js +11 -1
- package/lib/cjs/input/textarea.js +12 -1
- package/lib/cjs/inputNumber/index.d.ts +21 -12
- package/lib/cjs/inputNumber/index.js +37 -3
- package/lib/cjs/layout/Sider.d.ts +4 -0
- package/lib/cjs/layout/Sider.js +4 -1
- package/lib/cjs/layout/index.js +2 -0
- package/lib/cjs/list/item.js +0 -1
- package/lib/cjs/modal/Modal.js +2 -0
- package/lib/cjs/modal/ModalContent.d.ts +3 -1
- package/lib/cjs/modal/ModalContent.js +47 -5
- package/lib/cjs/navigation/Item.d.ts +4 -2
- package/lib/cjs/navigation/Item.js +25 -5
- package/lib/cjs/navigation/SubNav.d.ts +4 -2
- package/lib/cjs/navigation/SubNav.js +8 -1
- package/lib/cjs/navigation/index.js +2 -0
- package/lib/cjs/notification/notice.d.ts +1 -1
- package/lib/cjs/notification/notice.js +32 -22
- package/lib/cjs/pagination/index.js +16 -6
- package/lib/cjs/popover/index.js +7 -3
- package/lib/cjs/progress/index.d.ts +8 -0
- package/lib/cjs/progress/index.js +42 -9
- package/lib/cjs/radio/radio.d.ts +6 -1
- package/lib/cjs/radio/radio.js +17 -5
- package/lib/cjs/radio/radioGroup.d.ts +16 -1
- package/lib/cjs/radio/radioGroup.js +18 -3
- package/lib/cjs/radio/radioInner.d.ts +6 -1
- package/lib/cjs/radio/radioInner.js +11 -3
- package/lib/cjs/rating/index.d.ts +14 -0
- package/lib/cjs/rating/index.js +14 -3
- package/lib/cjs/rating/item.d.ts +2 -0
- package/lib/cjs/rating/item.js +6 -1
- package/lib/cjs/select/index.d.ts +16 -0
- package/lib/cjs/select/index.js +65 -19
- package/lib/cjs/select/option.js +28 -22
- package/lib/cjs/sideSheet/SideSheetContent.d.ts +1 -0
- package/lib/cjs/sideSheet/SideSheetContent.js +4 -1
- package/lib/cjs/sideSheet/index.d.ts +1 -0
- package/lib/cjs/sideSheet/index.js +2 -1
- package/lib/cjs/slider/index.d.ts +2 -1
- package/lib/cjs/slider/index.js +64 -17
- package/lib/cjs/spin/icon.js +3 -4
- package/lib/cjs/steps/basicStep.d.ts +3 -0
- package/lib/cjs/steps/basicStep.js +23 -25
- package/lib/cjs/steps/basicSteps.d.ts +1 -0
- package/lib/cjs/steps/basicSteps.js +2 -1
- package/lib/cjs/steps/fillStep.d.ts +3 -0
- package/lib/cjs/steps/fillStep.js +19 -4
- package/lib/cjs/steps/fillSteps.d.ts +1 -0
- package/lib/cjs/steps/fillSteps.js +2 -1
- package/lib/cjs/steps/navStep.d.ts +3 -0
- package/lib/cjs/steps/navStep.js +22 -25
- package/lib/cjs/steps/navSteps.d.ts +1 -0
- package/lib/cjs/steps/navSteps.js +2 -1
- package/lib/cjs/switch/index.d.ts +12 -0
- package/lib/cjs/switch/index.js +19 -4
- package/lib/cjs/table/Body/BaseRow.js +35 -3
- package/lib/cjs/table/Body/index.js +9 -1
- package/lib/cjs/table/ColumnFilter.js +4 -0
- package/lib/cjs/table/ColumnSelection.d.ts +3 -0
- package/lib/cjs/table/ColumnSelection.js +6 -2
- package/lib/cjs/table/ColumnSorter.js +19 -3
- package/lib/cjs/table/CustomExpandIcon.js +7 -1
- package/lib/cjs/table/Table.d.ts +2 -0
- package/lib/cjs/table/Table.js +31 -15
- package/lib/cjs/table/TableCell.d.ts +2 -0
- package/lib/cjs/table/TableCell.js +6 -2
- package/lib/cjs/table/TableHeaderRow.js +8 -2
- package/lib/cjs/tabs/TabBar.js +11 -3
- package/lib/cjs/tabs/TabPane.js +3 -1
- package/lib/cjs/tabs/index.js +0 -1
- package/lib/cjs/tagInput/index.d.ts +4 -1
- package/lib/cjs/tagInput/index.js +29 -3
- package/lib/cjs/timePicker/TimePicker.d.ts +12 -0
- package/lib/cjs/timePicker/TimePicker.js +9 -1
- package/lib/cjs/timePicker/index.d.ts +6 -0
- package/lib/cjs/timeline/index.d.ts +1 -1
- package/lib/cjs/timeline/index.js +1 -0
- package/lib/cjs/timeline/item.js +4 -2
- package/lib/cjs/toast/toast.js +2 -0
- package/lib/cjs/tooltip/TriangleArrow.js +1 -0
- package/lib/cjs/tooltip/TriangleArrowVertical.js +1 -0
- package/lib/cjs/tooltip/index.d.ts +16 -12
- package/lib/cjs/tooltip/index.js +55 -39
- package/lib/cjs/transfer/index.d.ts +1 -1
- package/lib/cjs/transfer/index.js +35 -17
- package/lib/cjs/tree/index.d.ts +1 -0
- package/lib/cjs/tree/index.js +15 -6
- package/lib/cjs/tree/treeNode.d.ts +12 -4
- package/lib/cjs/tree/treeNode.js +44 -4
- package/lib/cjs/treeSelect/index.d.ts +16 -0
- package/lib/cjs/treeSelect/index.js +60 -12
- package/lib/cjs/typography/base.js +18 -7
- package/lib/cjs/typography/copyable.js +6 -1
- package/lib/cjs/upload/fileCard.js +26 -7
- package/lib/cjs/upload/index.js +19 -4
- package/lib/es/_utils/hooks/usePrevFocus.d.ts +2 -0
- package/lib/es/_utils/hooks/usePrevFocus.js +15 -0
- package/lib/es/_utils/index.d.ts +1 -0
- package/lib/es/_utils/index.js +4 -1
- package/lib/es/anchor/index.d.ts +2 -0
- package/lib/es/anchor/index.js +6 -1
- package/lib/es/anchor/link.d.ts +4 -1
- package/lib/es/anchor/link.js +38 -5
- package/lib/es/autoComplete/index.d.ts +17 -0
- package/lib/es/autoComplete/index.js +21 -2
- package/lib/es/avatar/index.d.ts +4 -3
- package/lib/es/avatar/index.js +15 -11
- package/lib/es/banner/index.js +4 -2
- package/lib/es/breadcrumb/index.d.ts +3 -0
- package/lib/es/breadcrumb/index.js +10 -4
- package/lib/es/breadcrumb/item.js +2 -2
- package/lib/es/button/Button.d.ts +2 -0
- package/lib/es/button/Button.js +4 -2
- package/lib/es/button/buttonGroup.d.ts +3 -0
- package/lib/es/button/buttonGroup.js +8 -4
- package/lib/es/button/index.d.ts +1 -0
- package/lib/es/button/splitButtonGroup.d.ts +3 -0
- package/lib/es/button/splitButtonGroup.js +5 -2
- package/lib/es/card/index.d.ts +3 -0
- package/lib/es/card/index.js +3 -1
- package/lib/es/cascader/index.d.ts +14 -0
- package/lib/es/cascader/index.js +35 -7
- package/lib/es/checkbox/checkbox.d.ts +21 -1
- package/lib/es/checkbox/checkbox.js +50 -17
- package/lib/es/checkbox/checkboxGroup.d.ts +13 -1
- package/lib/es/checkbox/checkboxGroup.js +18 -5
- package/lib/es/checkbox/checkboxInner.d.ts +15 -0
- package/lib/es/checkbox/checkboxInner.js +20 -3
- package/lib/es/collapse/item.d.ts +2 -1
- package/lib/es/collapse/item.js +11 -2
- package/lib/es/collapsible/index.d.ts +1 -0
- package/lib/es/collapsible/index.js +4 -2
- package/lib/es/datePicker/datePicker.d.ts +12 -0
- package/lib/es/datePicker/datePicker.js +22 -3
- package/lib/es/datePicker/monthsGrid.d.ts +1 -0
- package/lib/es/datePicker/monthsGrid.js +2 -1
- package/lib/es/dropdown/dropdownItem.js +3 -1
- package/lib/es/dropdown/dropdownMenu.js +4 -1
- package/lib/es/form/baseForm.d.ts +9 -0
- package/lib/es/form/baseForm.js +3 -1
- package/lib/es/form/errorMessage.d.ts +4 -0
- package/lib/es/form/errorMessage.js +21 -3
- package/lib/es/form/field.d.ts +7 -0
- package/lib/es/form/hoc/withField.js +48 -15
- package/lib/es/form/index.d.ts +0 -1
- package/lib/es/form/index.js +0 -1
- package/lib/es/form/interface.d.ts +2 -0
- package/lib/es/form/label.d.ts +2 -0
- package/lib/es/form/label.js +5 -2
- package/lib/es/input/index.d.ts +16 -0
- package/lib/es/input/index.js +51 -15
- package/lib/es/input/inputGroup.d.ts +2 -1
- package/lib/es/input/inputGroup.js +11 -1
- package/lib/es/input/textarea.js +12 -1
- package/lib/es/inputNumber/index.d.ts +21 -12
- package/lib/es/inputNumber/index.js +38 -3
- package/lib/es/layout/Sider.d.ts +4 -0
- package/lib/es/layout/Sider.js +4 -1
- package/lib/es/layout/index.js +2 -0
- package/lib/es/list/item.js +0 -1
- package/lib/es/modal/Modal.js +2 -0
- package/lib/es/modal/ModalContent.d.ts +3 -1
- package/lib/es/modal/ModalContent.js +46 -5
- package/lib/es/navigation/Item.d.ts +4 -2
- package/lib/es/navigation/Item.js +25 -5
- package/lib/es/navigation/SubNav.d.ts +4 -2
- package/lib/es/navigation/SubNav.js +8 -1
- package/lib/es/navigation/index.js +2 -0
- package/lib/es/notification/notice.d.ts +1 -1
- package/lib/es/notification/notice.js +33 -24
- package/lib/es/pagination/index.js +16 -6
- package/lib/es/popover/index.js +7 -3
- package/lib/es/progress/index.d.ts +8 -0
- package/lib/es/progress/index.js +42 -9
- package/lib/es/radio/radio.d.ts +6 -1
- package/lib/es/radio/radio.js +16 -5
- package/lib/es/radio/radioGroup.d.ts +16 -1
- package/lib/es/radio/radioGroup.js +18 -3
- package/lib/es/radio/radioInner.d.ts +6 -1
- package/lib/es/radio/radioInner.js +11 -3
- package/lib/es/rating/index.d.ts +14 -0
- package/lib/es/rating/index.js +14 -3
- package/lib/es/rating/item.d.ts +2 -0
- package/lib/es/rating/item.js +6 -1
- package/lib/es/select/index.d.ts +16 -0
- package/lib/es/select/index.js +63 -17
- package/lib/es/select/option.js +28 -22
- package/lib/es/sideSheet/SideSheetContent.d.ts +1 -0
- package/lib/es/sideSheet/SideSheetContent.js +4 -1
- package/lib/es/sideSheet/index.d.ts +1 -0
- package/lib/es/sideSheet/index.js +2 -1
- package/lib/es/slider/index.d.ts +2 -1
- package/lib/es/slider/index.js +63 -16
- package/lib/es/spin/icon.js +3 -4
- package/lib/es/steps/basicStep.d.ts +3 -0
- package/lib/es/steps/basicStep.js +23 -23
- package/lib/es/steps/basicSteps.d.ts +1 -0
- package/lib/es/steps/basicSteps.js +2 -1
- package/lib/es/steps/fillStep.d.ts +3 -0
- package/lib/es/steps/fillStep.js +19 -4
- package/lib/es/steps/fillSteps.d.ts +1 -0
- package/lib/es/steps/fillSteps.js +2 -1
- package/lib/es/steps/navStep.d.ts +3 -0
- package/lib/es/steps/navStep.js +22 -23
- package/lib/es/steps/navSteps.d.ts +1 -0
- package/lib/es/steps/navSteps.js +2 -1
- package/lib/es/switch/index.d.ts +12 -0
- package/lib/es/switch/index.js +19 -4
- package/lib/es/table/Body/BaseRow.js +35 -3
- package/lib/es/table/Body/index.js +9 -2
- package/lib/es/table/ColumnFilter.js +4 -0
- package/lib/es/table/ColumnSelection.d.ts +3 -0
- package/lib/es/table/ColumnSelection.js +6 -2
- package/lib/es/table/ColumnSorter.js +17 -3
- package/lib/es/table/CustomExpandIcon.js +6 -1
- package/lib/es/table/Table.d.ts +2 -0
- package/lib/es/table/Table.js +31 -15
- package/lib/es/table/TableCell.d.ts +2 -0
- package/lib/es/table/TableCell.js +6 -2
- package/lib/es/table/TableHeaderRow.js +8 -2
- package/lib/es/tabs/TabBar.js +11 -3
- package/lib/es/tabs/TabPane.js +3 -1
- package/lib/es/tabs/index.js +0 -1
- package/lib/es/tagInput/index.d.ts +4 -1
- package/lib/es/tagInput/index.js +29 -3
- package/lib/es/timePicker/TimePicker.d.ts +12 -0
- package/lib/es/timePicker/TimePicker.js +9 -1
- package/lib/es/timePicker/index.d.ts +6 -0
- package/lib/es/timeline/index.d.ts +1 -1
- package/lib/es/timeline/index.js +1 -0
- package/lib/es/timeline/item.js +4 -2
- package/lib/es/toast/toast.js +2 -0
- package/lib/es/tooltip/TriangleArrow.js +1 -0
- package/lib/es/tooltip/TriangleArrowVertical.js +1 -0
- package/lib/es/tooltip/index.d.ts +16 -12
- package/lib/es/tooltip/index.js +53 -39
- package/lib/es/transfer/index.d.ts +1 -1
- package/lib/es/transfer/index.js +35 -17
- package/lib/es/tree/index.d.ts +1 -0
- package/lib/es/tree/index.js +15 -6
- package/lib/es/tree/treeNode.d.ts +12 -4
- package/lib/es/tree/treeNode.js +44 -4
- package/lib/es/treeSelect/index.d.ts +16 -0
- package/lib/es/treeSelect/index.js +57 -10
- package/lib/es/typography/base.js +17 -7
- package/lib/es/typography/copyable.js +5 -1
- package/lib/es/upload/fileCard.js +26 -7
- package/lib/es/upload/index.js +19 -4
- package/list/item.tsx +0 -1
- package/modal/Modal.tsx +2 -0
- package/modal/ModalContent.tsx +35 -5
- package/navigation/Item.tsx +15 -0
- package/navigation/SubNav.tsx +13 -1
- package/navigation/index.tsx +1 -1
- package/notification/notice.tsx +19 -14
- package/package.json +8 -8
- package/pagination/index.tsx +9 -5
- package/popover/index.tsx +5 -0
- package/progress/_story/progress.stories.js +18 -18
- package/progress/index.tsx +58 -20
- package/radio/radio.tsx +12 -2
- package/radio/radioGroup.tsx +29 -3
- package/radio/radioInner.tsx +10 -1
- package/rating/index.tsx +19 -2
- package/rating/item.tsx +6 -0
- package/select/__test__/select.test.js +45 -0
- package/select/_story/select.stories.js +29 -0
- package/select/index.tsx +52 -4
- package/select/option.tsx +3 -0
- package/sideSheet/SideSheetContent.tsx +6 -4
- package/sideSheet/index.tsx +3 -2
- package/slider/__test__/slider.test.js +9 -0
- package/slider/_story/slider.stories.js +1 -1
- package/slider/index.tsx +44 -7
- package/spin/icon.tsx +4 -3
- package/steps/basicStep.tsx +15 -4
- package/steps/basicSteps.tsx +3 -2
- package/steps/fillStep.tsx +27 -12
- package/steps/fillSteps.tsx +2 -0
- package/steps/navStep.tsx +15 -4
- package/steps/navSteps.tsx +3 -2
- package/switch/_story/switch.stories.js +20 -19
- package/switch/_story/switch.stories.tsx +13 -13
- package/switch/index.tsx +23 -5
- package/table/Body/BaseRow.tsx +25 -1
- package/table/Body/index.tsx +7 -2
- package/table/ColumnFilter.tsx +7 -1
- package/table/ColumnSelection.tsx +4 -1
- package/table/ColumnSorter.tsx +18 -1
- package/table/CustomExpandIcon.tsx +5 -0
- package/table/Table.tsx +26 -13
- package/table/TableCell.tsx +11 -1
- package/table/TableHeaderRow.tsx +16 -2
- package/table/__test__/table.test.js +46 -0
- package/tabs/TabBar.tsx +8 -5
- package/tabs/TabPane.tsx +3 -1
- package/tabs/index.tsx +0 -1
- package/tagInput/__test__/tagInput.test.js +46 -0
- package/tagInput/_story/tagInput.stories.js +2 -2
- package/tagInput/index.tsx +31 -8
- package/timePicker/TimePicker.tsx +14 -1
- package/timeline/_story/timeline.stories.js +1 -1
- package/timeline/index.tsx +2 -2
- package/timeline/item.tsx +2 -1
- package/toast/toast.tsx +2 -0
- package/tooltip/TriangleArrow.tsx +1 -1
- package/tooltip/TriangleArrowVertical.tsx +1 -1
- package/tooltip/_story/tooltip.stories.js +562 -514
- package/tooltip/index.tsx +51 -33
- package/transfer/index.tsx +32 -28
- package/tree/_story/tree.stories.js +3 -3
- package/tree/index.tsx +10 -2
- package/tree/treeNode.tsx +46 -10
- package/treeSelect/__test__/treeMultiple.test.js +5 -0
- package/treeSelect/_story/treeSelect.stories.js +12 -0
- package/treeSelect/index.tsx +58 -7
- package/typography/base.tsx +7 -1
- package/typography/copyable.tsx +10 -1
- package/upload/fileCard.tsx +14 -16
- 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
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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
|
|
41
|
-
<rect
|
|
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"
|
package/steps/basicStep.tsx
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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 {
|
|
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`}>
|
package/steps/basicSteps.tsx
CHANGED
|
@@ -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
|
);
|
package/steps/fillStep.tsx
CHANGED
|
@@ -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
|
|
55
|
-
[`${prefixCls
|
|
56
|
-
[`${prefixCls
|
|
57
|
-
[`${prefixCls
|
|
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
|
|
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
|
|
83
|
-
<div className={`${prefixCls
|
|
84
|
-
<span className={`${prefixCls
|
|
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
|
|
102
|
+
className={`${prefixCls}-description`}
|
|
88
103
|
title={typeof description === 'string' ? description : null}
|
|
89
104
|
>
|
|
90
105
|
{description}
|
package/steps/fillSteps.tsx
CHANGED
|
@@ -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,
|
|
22
|
-
const classString = classnames(prefixCls,
|
|
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 {
|
|
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`}>
|
package/steps/navSteps.tsx
CHANGED
|
@@ -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
|
|
38
|
+
<Switch defaultChecked checkedText='|' uncheckedText='〇' aria-label='power-switch'/>
|
|
39
39
|
<br/><br/>
|
|
40
|
-
<Switch checkedText='开' uncheckedText='关' size='large' />
|
|
41
|
-
<Switch
|
|
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>
|