@bifrostui/react 2.0.0-alpha.0 → 2.0.0-alpha.10
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/dist/Alert/Alert.js +2 -1
- package/dist/Alert/__tests__/fixtures/A11yDemos.d.ts +17 -0
- package/dist/Alert/__tests__/fixtures/A11yDemos.js +143 -0
- package/dist/Alert/index.css +4 -4
- package/dist/Avatar/AvatarGroup.css +8 -8
- package/dist/Avatar/index.css +8 -8
- package/dist/Backdrop/Backdrop.js +3 -2
- package/dist/Backdrop/Backdrop.types.d.ts +4 -0
- package/dist/Backdrop/__tests__/fixtures/A11yDemos.d.ts +8 -0
- package/dist/Backdrop/__tests__/fixtures/A11yDemos.js +51 -0
- package/dist/Backdrop/index.css +2 -2
- package/dist/Badge/Badge.js +38 -11
- package/dist/Badge/Badge.types.d.ts +30 -1
- package/dist/Badge/__tests__/fixtures/A11yDemos.d.ts +25 -0
- package/dist/Badge/__tests__/fixtures/A11yDemos.js +110 -0
- package/dist/Badge/hooks/useBadgeA11y.d.ts +23 -0
- package/dist/Badge/hooks/useBadgeA11y.js +76 -0
- package/dist/Badge/hooks/useBadgeDisplay.d.ts +16 -0
- package/dist/Badge/hooks/useBadgeDisplay.js +56 -0
- package/dist/Button/Button.js +2 -1
- package/dist/Button/__tests__/fixtures/A11yDemos.d.ts +23 -0
- package/dist/Button/__tests__/fixtures/A11yDemos.js +81 -0
- package/dist/Button/index.css +4 -5
- package/dist/CSSTransition/CSSTransition.d.ts +4 -0
- package/dist/CSSTransition/CSSTransition.js +177 -0
- package/dist/CSSTransition/CSSTransition.types.d.ts +13 -0
- package/dist/CSSTransition/CSSTransition.types.js +15 -0
- package/dist/CSSTransition/demo/CSSTransitionDemo.d.ts +4 -0
- package/dist/CSSTransition/demo/CSSTransitionDemo.js +76 -0
- package/dist/CSSTransition/demo/index.css +25 -0
- package/dist/CSSTransition/index.d.ts +2 -0
- package/dist/CSSTransition/index.js +41 -0
- package/dist/Calendar/Calendar.js +131 -34
- package/dist/Calendar/Calendar.types.d.ts +16 -1
- package/dist/Calendar/__tests__/fixtures/A11yDemos.d.ts +2 -0
- package/dist/Calendar/__tests__/fixtures/A11yDemos.js +41 -0
- package/dist/Calendar/index.css +52 -9
- package/dist/Calendar/utils.d.ts +7 -3
- package/dist/Calendar/utils.js +33 -23
- package/dist/Checkbox/Checkbox.js +5 -4
- package/dist/Checkbox/__tests__/fixtures/A11yDemos.d.ts +15 -0
- package/dist/Checkbox/__tests__/fixtures/A11yDemos.js +57 -0
- package/dist/CitySelector/CitySelector.types.d.ts +0 -1
- package/dist/Collapse/Collapse.d.ts +1 -1
- package/dist/Collapse/Collapse.js +26 -12
- package/dist/Collapse/Collapse.miniapp.d.ts +10 -0
- package/dist/Collapse/Collapse.miniapp.js +255 -0
- package/dist/Collapse/index.css +40 -1
- package/dist/CollapsePanel/index.css +1 -1
- package/dist/Countdown/Countdown.js +61 -21
- package/dist/Countdown/Countdown.types.d.ts +19 -15
- package/dist/Countdown/__tests__/fixtures/A11yDemos.d.ts +23 -0
- package/dist/Countdown/__tests__/fixtures/A11yDemos.js +107 -0
- package/dist/Countdown/index.css +11 -0
- package/dist/DatePicker/DatePicker.d.ts +4 -0
- package/dist/DatePicker/DatePicker.js +335 -0
- package/dist/DatePicker/DatePicker.types.d.ts +36 -0
- package/dist/DatePicker/DatePicker.types.js +15 -0
- package/dist/DatePicker/constants.d.ts +9 -0
- package/dist/DatePicker/constants.js +37 -0
- package/dist/DatePicker/index.d.ts +3 -0
- package/dist/DatePicker/index.js +44 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.css +61 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
- package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
- package/dist/DesktopDatePicker/index.css +161 -0
- package/dist/DesktopDatePicker/index.d.ts +2 -0
- package/dist/DesktopDatePicker/index.js +41 -0
- package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
- package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
- package/dist/DesktopDateTimePicker/index.css +66 -0
- package/dist/DesktopDateTimePicker/index.d.ts +2 -0
- package/dist/DesktopDateTimePicker/index.js +41 -0
- package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
- package/dist/DesktopPicker/DesktopPicker.js +243 -0
- package/dist/DesktopPicker/DesktopPicker.types.d.ts +61 -0
- package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
- package/dist/DesktopPicker/index.css +39 -0
- package/dist/DesktopPicker/index.d.ts +2 -0
- package/dist/DesktopPicker/index.js +41 -0
- package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
- package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
- package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
- package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
- package/dist/DesktopTimePicker/index.css +170 -0
- package/dist/DesktopTimePicker/index.d.ts +2 -0
- package/dist/DesktopTimePicker/index.js +41 -0
- package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
- package/dist/DesktopTimePicker/useGetTimePickerContent.js +249 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
- package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
- package/dist/DesktopTimePicker/utils/utils.js +408 -0
- package/dist/Dialog/Dialog.d.ts +5 -2
- package/dist/Dialog/Dialog.js +56 -34
- package/dist/Dialog/Dialog.types.d.ts +50 -22
- package/dist/Dialog/FunctionalDialog.d.ts +10 -3
- package/dist/Dialog/FunctionalDialog.js +102 -80
- package/dist/Dialog/__tests__/fixtures/A11yDemos.d.ts +9 -0
- package/dist/Dialog/__tests__/fixtures/A11yDemos.js +78 -0
- package/dist/Dialog/index.css +19 -19
- package/dist/Dialog/index.d.ts +4 -1
- package/dist/Dialog/index.js +9 -2
- package/dist/Drawer/Drawer.js +7 -7
- package/dist/Drawer/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/dist/Drawer/__tests__/fixtures/A11yDemos.js +148 -0
- package/dist/Fade/Fade.js +2 -2
- package/dist/Fade/Fade.miniapp.d.ts +10 -0
- package/dist/Fade/Fade.miniapp.js +200 -0
- package/dist/Fade/index.css +18 -0
- package/dist/IconButton/IconButton.js +23 -8
- package/dist/IconButton/IconButton.types.d.ts +35 -1
- package/dist/IconButton/index.css +3 -0
- package/dist/Image/Image.js +17 -10
- package/dist/Image/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/dist/Image/__tests__/fixtures/A11yDemos.js +130 -0
- package/dist/Image/index.css +3 -8
- package/dist/Input/Input.js +5 -3
- package/dist/Input/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/dist/Input/__tests__/fixtures/A11yDemos.js +81 -0
- package/dist/Input/index.css +8 -8
- package/dist/ItemSelector/ItemSelector.types.d.ts +0 -1
- package/dist/Modal/Modal.js +47 -47
- package/dist/Modal/Modal.miniapp.d.ts +2 -2
- package/dist/Modal/Modal.miniapp.js +48 -32
- package/dist/Modal/Modal.types.d.ts +26 -2
- package/dist/Modal/ModalManager.d.ts +21 -0
- package/dist/Modal/ModalManager.js +238 -0
- package/dist/Modal/__tests__/fixtures/A11yDemos.d.ts +8 -0
- package/dist/Modal/__tests__/fixtures/A11yDemos.js +52 -0
- package/dist/Modal/index.css +1 -1
- package/dist/Modal/index.d.ts +3 -0
- package/dist/Modal/index.js +9 -1
- package/dist/Modal/useModal.d.ts +24 -0
- package/dist/Modal/useModal.js +190 -0
- package/dist/NavBar/index.css +2 -2
- package/dist/Picker/Picker.css +4 -0
- package/dist/Picker/Picker.js +72 -18
- package/dist/Picker/Picker.types.d.ts +15 -2
- package/dist/Picker/PickerPanel.css +4 -0
- package/dist/Picker/PickerPanel.js +52 -41
- package/dist/Picker/__tests__/fixtures/A11yDemos.d.ts +2 -0
- package/dist/Picker/__tests__/fixtures/A11yDemos.js +79 -0
- package/dist/Picker/index.css +8 -0
- package/dist/Picker/utils.d.ts +8 -5
- package/dist/Picker/utils.js +9 -12
- package/dist/Popover/Popover.js +123 -91
- package/dist/Popover/Popover.types.d.ts +44 -7
- package/dist/Popover/__tests__/fixtures/A11yDemos.d.ts +25 -0
- package/dist/Popover/__tests__/fixtures/A11yDemos.js +175 -0
- package/dist/Popover/hooks/index.d.ts +8 -0
- package/dist/Popover/hooks/index.js +36 -0
- package/dist/Popover/hooks/usePopoverA11y.d.ts +14 -0
- package/dist/Popover/hooks/usePopoverA11y.js +66 -0
- package/dist/Popover/hooks/usePopoverEvents.d.ts +21 -0
- package/dist/Popover/hooks/usePopoverEvents.js +150 -0
- package/dist/Popover/hooks/usePopoverPosition.d.ts +17 -0
- package/dist/Popover/hooks/usePopoverPosition.js +124 -0
- package/dist/Popover/hooks/usePopoverState.d.ts +16 -0
- package/dist/Popover/hooks/usePopoverState.js +54 -0
- package/dist/Portal/Portal.miniapp.js +20 -11
- package/dist/Portal/Portal.types.d.ts +1 -1
- package/dist/Portal/PortalCore.js +2 -2
- package/dist/Progress/Progress.js +61 -6
- package/dist/Progress/Progress.types.d.ts +44 -0
- package/dist/Progress/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/dist/Progress/__tests__/fixtures/A11yDemos.js +100 -0
- package/dist/Radio/Radio.js +5 -4
- package/dist/Radio/RadioGroup.js +1 -1
- package/dist/Radio/__tests__/fixtures/A11yDemos.d.ts +15 -0
- package/dist/Radio/__tests__/fixtures/A11yDemos.js +57 -0
- package/dist/Rating/index.css +8 -12
- package/dist/ScrollView/ScrollView.js +48 -196
- package/dist/ScrollView/ScrollView.types.d.ts +120 -86
- package/dist/ScrollView/__tests__/fixtures/A11yDemos.d.ts +7 -0
- package/dist/ScrollView/__tests__/fixtures/A11yDemos.js +319 -0
- package/dist/ScrollView/useScrollView.d.ts +10 -0
- package/dist/ScrollView/useScrollView.js +300 -0
- package/dist/Select/Select.js +73 -39
- package/dist/Select/Select.types.d.ts +2 -2
- package/dist/Select/SelectOption.js +5 -1
- package/dist/Select/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/dist/Select/__tests__/fixtures/A11yDemos.js +154 -0
- package/dist/Select/index.css +12 -8
- package/dist/Select/selectContext.d.ts +0 -1
- package/dist/Slide/Slide.js +2 -2
- package/dist/Slide/Slide.miniapp.d.ts +14 -0
- package/dist/Slide/Slide.miniapp.js +213 -0
- package/dist/Slide/index.css +72 -0
- package/dist/Slider/Slider.js +13 -5
- package/dist/Stack/demo/index.css +2 -0
- package/dist/SwipeAction/SwipeAction.css +79 -0
- package/dist/SwipeAction/SwipeAction.d.ts +5 -0
- package/dist/SwipeAction/SwipeAction.js +349 -0
- package/dist/SwipeAction/SwipeAction.types.d.ts +75 -0
- package/dist/SwipeAction/SwipeAction.types.js +15 -0
- package/dist/SwipeAction/SwipeActionContext.d.ts +3 -0
- package/dist/SwipeAction/SwipeActionContext.js +30 -0
- package/dist/SwipeAction/SwipeActionItem.css +31 -0
- package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
- package/dist/SwipeAction/SwipeActionItem.js +105 -0
- package/dist/SwipeAction/constants.d.ts +9 -0
- package/dist/SwipeAction/constants.js +39 -0
- package/dist/SwipeAction/index.css +110 -0
- package/dist/SwipeAction/index.d.ts +5 -0
- package/dist/SwipeAction/index.js +50 -0
- package/dist/Swiper/Swiper.js +18 -4
- package/dist/Switch/Switch.js +5 -4
- package/dist/Switch/__tests__/fixtures/A11yDemos.d.ts +15 -0
- package/dist/Switch/__tests__/fixtures/A11yDemos.js +57 -0
- package/dist/Tabs/Tab.js +36 -21
- package/dist/Tabs/Tab.types.d.ts +1 -1
- package/dist/Tabs/TabPanel.d.ts +1 -1
- package/dist/Tabs/TabPanel.js +9 -5
- package/dist/Tabs/Tabs.css +2 -2
- package/dist/Tabs/Tabs.js +87 -64
- package/dist/Tabs/Tabs.types.d.ts +1 -1
- package/dist/Tabs/TabsContext.d.ts +4 -5
- package/dist/Tabs/TabsContext.js +3 -1
- package/dist/Tabs/index.css +2 -2
- package/dist/Tabs/utils/scroll.d.ts +2 -0
- package/dist/Tabs/utils/scroll.js +55 -0
- package/dist/Tag/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/dist/Tag/__tests__/fixtures/A11yDemos.js +196 -0
- package/dist/TextArea/TextArea.js +50 -7
- package/dist/TextArea/TextArea.types.d.ts +28 -0
- package/dist/TextArea/__tests__/fixtures/A11yDemos.d.ts +19 -0
- package/dist/TextArea/__tests__/fixtures/A11yDemos.js +91 -0
- package/dist/TextArea/index.css +4 -4
- package/dist/ThemeProvider/ThemeProvider.types.d.ts +2 -2
- package/dist/ThemeProvider/ThemeProvider.types.js +0 -12
- package/dist/Toast/FunctionalToast.d.ts +2 -2
- package/dist/Toast/FunctionalToast.js +180 -85
- package/dist/Toast/Toast.d.ts +2 -2
- package/dist/Toast/Toast.js +69 -28
- package/dist/Toast/Toast.types.d.ts +13 -10
- package/dist/Toast/__tests__/fixtures/A11yDemos.d.ts +2 -0
- package/dist/Toast/__tests__/fixtures/A11yDemos.js +54 -0
- package/dist/Toast/index.css +0 -1
- package/dist/Tooltip/Tooltip.js +63 -107
- package/dist/Tooltip/Tooltip.types.d.ts +94 -43
- package/dist/Tooltip/__tests__/fixtures/A11yDemos.d.ts +25 -0
- package/dist/Tooltip/__tests__/fixtures/A11yDemos.js +100 -0
- package/dist/Tooltip/useTooltip.d.ts +29 -0
- package/dist/Tooltip/useTooltip.js +313 -0
- package/dist/Transition/TransitionCore.js +30 -25
- package/dist/TransitionGroup/TransitionGroup.d.ts +7 -0
- package/dist/TransitionGroup/TransitionGroup.js +132 -0
- package/dist/TransitionGroup/TransitionGroup.types.d.ts +47 -0
- package/dist/TransitionGroup/TransitionGroup.types.js +15 -0
- package/dist/TransitionGroup/demo/TransitionGroupDemo.d.ts +4 -0
- package/dist/TransitionGroup/demo/TransitionGroupDemo.js +68 -0
- package/dist/TransitionGroup/demo/index.css +33 -0
- package/dist/TransitionGroup/index.d.ts +2 -0
- package/dist/TransitionGroup/index.js +41 -0
- package/dist/TransitionGroup/utils/childMapping.d.ts +27 -0
- package/dist/TransitionGroup/utils/childMapping.js +119 -0
- package/dist/_.._/benchmarks/components/Button.js +41 -0
- package/dist/_.._/benchmarks/components/Input.js +45 -0
- package/dist/_.._/benchmarks/components/Tabs.js +50 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +17 -1
- package/dist/locales/base.d.ts +40 -1
- package/dist/locales/en-US.js +54 -2
- package/dist/locales/zh-CN.js +56 -1
- package/dist/locales/zh-TW.js +56 -1
- package/es/Alert/Alert.js +2 -1
- package/es/Alert/__tests__/fixtures/A11yDemos.d.ts +17 -0
- package/es/Alert/__tests__/fixtures/A11yDemos.js +107 -0
- package/es/Alert/index.css +4 -4
- package/es/Avatar/AvatarGroup.css +8 -8
- package/es/Avatar/index.css +8 -8
- package/es/Backdrop/Backdrop.js +3 -2
- package/es/Backdrop/Backdrop.types.d.ts +4 -0
- package/es/Backdrop/__tests__/fixtures/A11yDemos.d.ts +8 -0
- package/es/Backdrop/__tests__/fixtures/A11yDemos.js +17 -0
- package/es/Backdrop/index.css +2 -2
- package/es/Badge/Badge.js +38 -11
- package/es/Badge/Badge.types.d.ts +30 -1
- package/es/Badge/__tests__/fixtures/A11yDemos.d.ts +25 -0
- package/es/Badge/__tests__/fixtures/A11yDemos.js +70 -0
- package/es/Badge/hooks/useBadgeA11y.d.ts +23 -0
- package/es/Badge/hooks/useBadgeA11y.js +53 -0
- package/es/Badge/hooks/useBadgeDisplay.d.ts +16 -0
- package/es/Badge/hooks/useBadgeDisplay.js +33 -0
- package/es/Button/Button.js +2 -1
- package/es/Button/__tests__/fixtures/A11yDemos.d.ts +23 -0
- package/es/Button/__tests__/fixtures/A11yDemos.js +42 -0
- package/es/Button/index.css +4 -5
- package/es/CSSTransition/CSSTransition.d.ts +4 -0
- package/es/CSSTransition/CSSTransition.js +153 -0
- package/es/CSSTransition/CSSTransition.types.d.ts +13 -0
- package/es/CSSTransition/CSSTransition.types.js +1 -0
- package/es/CSSTransition/demo/CSSTransitionDemo.d.ts +4 -0
- package/es/CSSTransition/demo/CSSTransitionDemo.js +47 -0
- package/es/CSSTransition/demo/index.css +25 -0
- package/es/CSSTransition/index.d.ts +2 -0
- package/es/CSSTransition/index.js +6 -0
- package/es/Calendar/Calendar.js +131 -34
- package/es/Calendar/Calendar.types.d.ts +16 -1
- package/es/Calendar/__tests__/fixtures/A11yDemos.d.ts +2 -0
- package/es/Calendar/__tests__/fixtures/A11yDemos.js +8 -0
- package/es/Calendar/index.css +52 -9
- package/es/Calendar/utils.d.ts +7 -3
- package/es/Calendar/utils.js +29 -20
- package/es/Checkbox/Checkbox.js +5 -4
- package/es/Checkbox/__tests__/fixtures/A11yDemos.d.ts +15 -0
- package/es/Checkbox/__tests__/fixtures/A11yDemos.js +22 -0
- package/es/CitySelector/CitySelector.types.d.ts +0 -1
- package/es/Collapse/Collapse.d.ts +1 -1
- package/es/Collapse/Collapse.js +26 -12
- package/es/Collapse/Collapse.miniapp.d.ts +10 -0
- package/es/Collapse/Collapse.miniapp.js +236 -0
- package/es/Collapse/index.css +40 -1
- package/es/CollapsePanel/index.css +1 -1
- package/es/Countdown/Countdown.js +61 -21
- package/es/Countdown/Countdown.types.d.ts +19 -15
- package/es/Countdown/__tests__/fixtures/A11yDemos.d.ts +23 -0
- package/es/Countdown/__tests__/fixtures/A11yDemos.js +68 -0
- package/es/Countdown/index.css +11 -0
- package/es/DatePicker/DatePicker.d.ts +4 -0
- package/es/DatePicker/DatePicker.js +308 -0
- package/es/DatePicker/DatePicker.types.d.ts +36 -0
- package/es/DatePicker/DatePicker.types.js +1 -0
- package/es/DatePicker/constants.d.ts +9 -0
- package/es/DatePicker/constants.js +14 -0
- package/es/DatePicker/index.d.ts +3 -0
- package/es/DatePicker/index.js +8 -0
- package/es/DesktopDatePicker/DesktopDatePicker.css +61 -0
- package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
- package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
- package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
- package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
- package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
- package/es/DesktopDatePicker/index.css +161 -0
- package/es/DesktopDatePicker/index.d.ts +2 -0
- package/es/DesktopDatePicker/index.js +6 -0
- package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
- package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
- package/es/DesktopDateTimePicker/index.css +66 -0
- package/es/DesktopDateTimePicker/index.d.ts +2 -0
- package/es/DesktopDateTimePicker/index.js +9 -0
- package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
- package/es/DesktopPicker/DesktopPicker.js +226 -0
- package/es/DesktopPicker/DesktopPicker.types.d.ts +61 -0
- package/es/DesktopPicker/DesktopPicker.types.js +1 -0
- package/es/DesktopPicker/index.css +39 -0
- package/es/DesktopPicker/index.d.ts +2 -0
- package/es/DesktopPicker/index.js +6 -0
- package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
- package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
- package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
- package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
- package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
- package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
- package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
- package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
- package/es/DesktopTimePicker/index.css +170 -0
- package/es/DesktopTimePicker/index.d.ts +2 -0
- package/es/DesktopTimePicker/index.js +6 -0
- package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
- package/es/DesktopTimePicker/useGetTimePickerContent.js +226 -0
- package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
- package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
- package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
- package/es/DesktopTimePicker/utils/utils.js +365 -0
- package/es/Dialog/Dialog.d.ts +5 -2
- package/es/Dialog/Dialog.js +57 -35
- package/es/Dialog/Dialog.types.d.ts +50 -22
- package/es/Dialog/FunctionalDialog.d.ts +10 -3
- package/es/Dialog/FunctionalDialog.js +106 -84
- package/es/Dialog/__tests__/fixtures/A11yDemos.d.ts +9 -0
- package/es/Dialog/__tests__/fixtures/A11yDemos.js +43 -0
- package/es/Dialog/index.css +19 -19
- package/es/Dialog/index.d.ts +4 -1
- package/es/Dialog/index.js +10 -3
- package/es/Drawer/Drawer.js +8 -8
- package/es/Drawer/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/es/Drawer/__tests__/fixtures/A11yDemos.js +112 -0
- package/es/Fade/Fade.js +2 -2
- package/es/Fade/Fade.miniapp.d.ts +10 -0
- package/es/Fade/Fade.miniapp.js +179 -0
- package/es/Fade/index.css +18 -0
- package/es/IconButton/IconButton.js +23 -8
- package/es/IconButton/IconButton.types.d.ts +35 -1
- package/es/IconButton/index.css +3 -0
- package/es/Image/Image.js +17 -10
- package/es/Image/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/es/Image/__tests__/fixtures/A11yDemos.js +92 -0
- package/es/Image/index.css +3 -8
- package/es/Input/Input.js +5 -3
- package/es/Input/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/es/Input/__tests__/fixtures/A11yDemos.js +43 -0
- package/es/Input/index.css +8 -8
- package/es/ItemSelector/ItemSelector.types.d.ts +0 -1
- package/es/Modal/Modal.js +48 -48
- package/es/Modal/Modal.miniapp.d.ts +2 -2
- package/es/Modal/Modal.miniapp.js +49 -33
- package/es/Modal/Modal.types.d.ts +26 -2
- package/es/Modal/ModalManager.d.ts +21 -0
- package/es/Modal/ModalManager.js +214 -0
- package/es/Modal/__tests__/fixtures/A11yDemos.d.ts +8 -0
- package/es/Modal/__tests__/fixtures/A11yDemos.js +18 -0
- package/es/Modal/index.css +1 -1
- package/es/Modal/index.d.ts +3 -0
- package/es/Modal/index.js +6 -1
- package/es/Modal/useModal.d.ts +24 -0
- package/es/Modal/useModal.js +169 -0
- package/es/NavBar/index.css +2 -2
- package/es/Picker/Picker.css +4 -0
- package/es/Picker/Picker.js +72 -18
- package/es/Picker/Picker.types.d.ts +15 -2
- package/es/Picker/PickerPanel.css +4 -0
- package/es/Picker/PickerPanel.js +52 -41
- package/es/Picker/__tests__/fixtures/A11yDemos.d.ts +2 -0
- package/es/Picker/__tests__/fixtures/A11yDemos.js +46 -0
- package/es/Picker/index.css +8 -0
- package/es/Picker/utils.d.ts +8 -5
- package/es/Picker/utils.js +9 -12
- package/es/Popover/Popover.js +130 -99
- package/es/Popover/Popover.types.d.ts +44 -7
- package/es/Popover/__tests__/fixtures/A11yDemos.d.ts +25 -0
- package/es/Popover/__tests__/fixtures/A11yDemos.js +135 -0
- package/es/Popover/hooks/index.d.ts +8 -0
- package/es/Popover/hooks/index.js +10 -0
- package/es/Popover/hooks/usePopoverA11y.d.ts +14 -0
- package/es/Popover/hooks/usePopoverA11y.js +43 -0
- package/es/Popover/hooks/usePopoverEvents.d.ts +21 -0
- package/es/Popover/hooks/usePopoverEvents.js +127 -0
- package/es/Popover/hooks/usePopoverPosition.d.ts +17 -0
- package/es/Popover/hooks/usePopoverPosition.js +105 -0
- package/es/Popover/hooks/usePopoverState.d.ts +16 -0
- package/es/Popover/hooks/usePopoverState.js +31 -0
- package/es/Portal/Portal.miniapp.js +21 -12
- package/es/Portal/Portal.types.d.ts +1 -1
- package/es/Portal/PortalCore.js +2 -2
- package/es/Progress/Progress.js +61 -6
- package/es/Progress/Progress.types.d.ts +44 -0
- package/es/Progress/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/es/Progress/__tests__/fixtures/A11yDemos.js +62 -0
- package/es/Radio/Radio.js +5 -4
- package/es/Radio/RadioGroup.js +1 -1
- package/es/Radio/__tests__/fixtures/A11yDemos.d.ts +15 -0
- package/es/Radio/__tests__/fixtures/A11yDemos.js +22 -0
- package/es/Rating/index.css +8 -12
- package/es/ScrollView/ScrollView.js +51 -197
- package/es/ScrollView/ScrollView.types.d.ts +120 -86
- package/es/ScrollView/__tests__/fixtures/A11yDemos.d.ts +7 -0
- package/es/ScrollView/__tests__/fixtures/A11yDemos.js +283 -0
- package/es/ScrollView/useScrollView.d.ts +10 -0
- package/es/ScrollView/useScrollView.js +279 -0
- package/es/Select/Select.js +73 -40
- package/es/Select/Select.types.d.ts +2 -2
- package/es/Select/SelectOption.js +5 -1
- package/es/Select/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/es/Select/__tests__/fixtures/A11yDemos.js +118 -0
- package/es/Select/index.css +12 -8
- package/es/Select/selectContext.d.ts +0 -1
- package/es/Slide/Slide.js +2 -2
- package/es/Slide/Slide.miniapp.d.ts +14 -0
- package/es/Slide/Slide.miniapp.js +192 -0
- package/es/Slide/index.css +72 -0
- package/es/Slider/Slider.js +16 -6
- package/es/Stack/demo/index.css +2 -0
- package/es/SwipeAction/SwipeAction.css +79 -0
- package/es/SwipeAction/SwipeAction.d.ts +5 -0
- package/es/SwipeAction/SwipeAction.js +334 -0
- package/es/SwipeAction/SwipeAction.types.d.ts +75 -0
- package/es/SwipeAction/SwipeAction.types.js +1 -0
- package/es/SwipeAction/SwipeActionContext.d.ts +3 -0
- package/es/SwipeAction/SwipeActionContext.js +11 -0
- package/es/SwipeAction/SwipeActionItem.css +31 -0
- package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
- package/es/SwipeAction/SwipeActionItem.js +78 -0
- package/es/SwipeAction/constants.d.ts +9 -0
- package/es/SwipeAction/constants.js +15 -0
- package/es/SwipeAction/index.css +110 -0
- package/es/SwipeAction/index.d.ts +5 -0
- package/es/SwipeAction/index.js +12 -0
- package/es/Swiper/Swiper.js +18 -4
- package/es/Switch/Switch.js +5 -4
- package/es/Switch/__tests__/fixtures/A11yDemos.d.ts +15 -0
- package/es/Switch/__tests__/fixtures/A11yDemos.js +22 -0
- package/es/Tabs/Tab.js +36 -21
- package/es/Tabs/Tab.types.d.ts +1 -1
- package/es/Tabs/TabPanel.d.ts +1 -1
- package/es/Tabs/TabPanel.js +8 -4
- package/es/Tabs/Tabs.css +2 -2
- package/es/Tabs/Tabs.js +87 -64
- package/es/Tabs/Tabs.types.d.ts +1 -1
- package/es/Tabs/TabsContext.d.ts +4 -5
- package/es/Tabs/TabsContext.js +3 -1
- package/es/Tabs/index.css +2 -2
- package/es/Tabs/utils/scroll.d.ts +2 -0
- package/es/Tabs/utils/scroll.js +36 -0
- package/es/Tag/__tests__/fixtures/A11yDemos.d.ts +21 -0
- package/es/Tag/__tests__/fixtures/A11yDemos.js +160 -0
- package/es/TextArea/TextArea.js +51 -8
- package/es/TextArea/TextArea.types.d.ts +28 -0
- package/es/TextArea/__tests__/fixtures/A11yDemos.d.ts +19 -0
- package/es/TextArea/__tests__/fixtures/A11yDemos.js +54 -0
- package/es/TextArea/index.css +4 -4
- package/es/ThemeProvider/ThemeProvider.types.d.ts +2 -2
- package/es/Toast/FunctionalToast.d.ts +2 -2
- package/es/Toast/FunctionalToast.js +186 -86
- package/es/Toast/Toast.d.ts +2 -2
- package/es/Toast/Toast.js +69 -28
- package/es/Toast/Toast.types.d.ts +13 -10
- package/es/Toast/__tests__/fixtures/A11yDemos.d.ts +2 -0
- package/es/Toast/__tests__/fixtures/A11yDemos.js +21 -0
- package/es/Toast/index.css +0 -1
- package/es/Tooltip/Tooltip.js +64 -114
- package/es/Tooltip/Tooltip.types.d.ts +94 -43
- package/es/Tooltip/__tests__/fixtures/A11yDemos.d.ts +25 -0
- package/es/Tooltip/__tests__/fixtures/A11yDemos.js +60 -0
- package/es/Tooltip/useTooltip.d.ts +29 -0
- package/es/Tooltip/useTooltip.js +290 -0
- package/es/Transition/TransitionCore.js +31 -26
- package/es/TransitionGroup/TransitionGroup.d.ts +7 -0
- package/es/TransitionGroup/TransitionGroup.js +109 -0
- package/es/TransitionGroup/TransitionGroup.types.d.ts +47 -0
- package/es/TransitionGroup/TransitionGroup.types.js +1 -0
- package/es/TransitionGroup/demo/TransitionGroupDemo.d.ts +4 -0
- package/es/TransitionGroup/demo/TransitionGroupDemo.js +39 -0
- package/es/TransitionGroup/demo/index.css +33 -0
- package/es/TransitionGroup/index.d.ts +2 -0
- package/es/TransitionGroup/index.js +6 -0
- package/es/TransitionGroup/utils/childMapping.d.ts +27 -0
- package/es/TransitionGroup/utils/childMapping.js +93 -0
- package/es/_.._/benchmarks/components/Button.js +8 -0
- package/es/_.._/benchmarks/components/Input.js +12 -0
- package/es/_.._/benchmarks/components/Tabs.js +17 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +8 -0
- package/es/locales/base.d.ts +40 -1
- package/es/locales/en-US.js +54 -2
- package/es/locales/zh-CN.js +56 -1
- package/es/locales/zh-TW.js +56 -1
- package/package.json +9 -6
- package/dist/Tabs/utils/bound.d.ts +0 -1
- package/es/Tabs/utils/bound.d.ts +0 -1
- package/es/Tabs/utils/bound.js +0 -13
package/es/Badge/Badge.js
CHANGED
|
@@ -28,47 +28,74 @@ var __objRest = (source, exclude) => {
|
|
|
28
28
|
};
|
|
29
29
|
import clsx from "clsx";
|
|
30
30
|
import React from "react";
|
|
31
|
+
import { useBadgeDisplay } from "./hooks/useBadgeDisplay";
|
|
32
|
+
import { useBadgeA11y } from "./hooks/useBadgeA11y";
|
|
31
33
|
import "./index.css";
|
|
32
34
|
const prefixCls = "bui-badge";
|
|
33
35
|
const Badge = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
34
36
|
const _a = props, {
|
|
35
37
|
className,
|
|
36
|
-
onClick,
|
|
37
38
|
children,
|
|
38
39
|
content,
|
|
39
40
|
color = "primary",
|
|
40
|
-
|
|
41
|
+
max,
|
|
42
|
+
showZero = false,
|
|
43
|
+
invisible = false,
|
|
41
44
|
variant = "contained",
|
|
42
|
-
type = "standard"
|
|
45
|
+
type = "standard",
|
|
46
|
+
// 无障碍功能相关属性
|
|
47
|
+
"aria-label": ariaLabel,
|
|
48
|
+
"aria-describedby": ariaDescribedby,
|
|
49
|
+
role = "status",
|
|
50
|
+
"aria-hidden": ariaHidden = false
|
|
43
51
|
} = _a, others = __objRest(_a, [
|
|
44
52
|
"className",
|
|
45
|
-
"onClick",
|
|
46
53
|
"children",
|
|
47
54
|
"content",
|
|
48
55
|
"color",
|
|
49
|
-
"
|
|
56
|
+
"max",
|
|
57
|
+
"showZero",
|
|
58
|
+
"invisible",
|
|
50
59
|
"variant",
|
|
51
|
-
"type"
|
|
60
|
+
"type",
|
|
61
|
+
"aria-label",
|
|
62
|
+
"aria-describedby",
|
|
63
|
+
"role",
|
|
64
|
+
"aria-hidden"
|
|
52
65
|
]);
|
|
53
|
-
const displayValue
|
|
66
|
+
const { displayValue, shouldShowBadge } = useBadgeDisplay({
|
|
67
|
+
content,
|
|
68
|
+
max,
|
|
69
|
+
showZero,
|
|
70
|
+
type
|
|
71
|
+
});
|
|
72
|
+
const { ariaAttributes } = useBadgeA11y({
|
|
73
|
+
displayValue,
|
|
74
|
+
type,
|
|
75
|
+
"aria-label": ariaLabel,
|
|
76
|
+
"aria-describedby": ariaDescribedby,
|
|
77
|
+
role,
|
|
78
|
+
"aria-hidden": ariaHidden
|
|
79
|
+
});
|
|
80
|
+
if (invisible)
|
|
81
|
+
return null;
|
|
54
82
|
return /* @__PURE__ */ React.createElement(
|
|
55
83
|
"div",
|
|
56
84
|
__spreadValues({
|
|
57
85
|
className: clsx(`${prefixCls}`, className, {
|
|
58
86
|
[`${prefixCls}-position`]: children
|
|
59
87
|
}),
|
|
60
|
-
onClick,
|
|
61
88
|
ref
|
|
62
89
|
}, others),
|
|
63
|
-
|
|
90
|
+
shouldShowBadge && /* @__PURE__ */ React.createElement(
|
|
64
91
|
"div",
|
|
65
|
-
{
|
|
92
|
+
__spreadValues({
|
|
66
93
|
className: clsx(
|
|
67
94
|
`${prefixCls}-${color}`,
|
|
68
95
|
`${prefixCls}-${variant}`,
|
|
69
96
|
`${prefixCls}-${type}`
|
|
70
97
|
)
|
|
71
|
-
},
|
|
98
|
+
}, ariaAttributes),
|
|
72
99
|
displayValue
|
|
73
100
|
),
|
|
74
101
|
children
|
|
@@ -13,7 +13,16 @@ export type BadgeProps<D extends React.ElementType = 'div', P = {}> = OverridePr
|
|
|
13
13
|
/**
|
|
14
14
|
* 最大值
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
max?: number;
|
|
17
|
+
/**
|
|
18
|
+
* content为0时是否展示
|
|
19
|
+
*/
|
|
20
|
+
showZero?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 是否隐藏badge
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
invisible?: boolean;
|
|
17
26
|
/**
|
|
18
27
|
*徽章类型
|
|
19
28
|
*/
|
|
@@ -22,6 +31,26 @@ export type BadgeProps<D extends React.ElementType = 'div', P = {}> = OverridePr
|
|
|
22
31
|
* 徽章形状
|
|
23
32
|
*/
|
|
24
33
|
type?: 'dot' | 'standard' | 'bubble';
|
|
34
|
+
/**
|
|
35
|
+
* 无障碍功能:为Badge提供可访问的标签
|
|
36
|
+
* 如果不提供,将根据content和type自动生成
|
|
37
|
+
*/
|
|
38
|
+
'aria-label'?: string;
|
|
39
|
+
/**
|
|
40
|
+
* 无障碍功能:引用描述此Badge的元素ID
|
|
41
|
+
*/
|
|
42
|
+
'aria-describedby'?: string;
|
|
43
|
+
/**
|
|
44
|
+
* 无障碍功能:Badge的角色
|
|
45
|
+
* @default 'status'
|
|
46
|
+
*/
|
|
47
|
+
role?: 'status' | 'img' | 'presentation';
|
|
48
|
+
/**
|
|
49
|
+
* 无障碍功能:是否对屏幕阅读器隐藏Badge
|
|
50
|
+
* 当为true时,Badge将被屏幕阅读器忽略
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
'aria-hidden'?: boolean;
|
|
25
54
|
};
|
|
26
55
|
defaultComponent: D;
|
|
27
56
|
}, D>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 自定义 Badge 组件 Demo 集合
|
|
4
|
+
* 这个文件包含多个测试 demo,展示如何使用 getCustomDemoCodesFromFile 进行无障碍测试
|
|
5
|
+
* 文件名必须是 A11yDemos.tsx(固定约定)
|
|
6
|
+
*/
|
|
7
|
+
export declare const basicBadgeDemo: () => React.JSX.Element;
|
|
8
|
+
export declare const colorBadgeDemo: () => React.JSX.Element;
|
|
9
|
+
export declare const typeBadgeDemo: () => React.JSX.Element;
|
|
10
|
+
export declare const maxBadgeDemo: () => React.JSX.Element;
|
|
11
|
+
export declare const accessibilityBadgeDemo: () => React.JSX.Element;
|
|
12
|
+
export declare const invisibilityBadgeDemo: () => React.JSX.Element;
|
|
13
|
+
export declare const complexInteractionBadgeDemo: () => React.JSX.Element;
|
|
14
|
+
export declare const specialContentBadgeDemo: () => React.JSX.Element;
|
|
15
|
+
declare const _default: {
|
|
16
|
+
basicBadgeDemo: () => React.JSX.Element;
|
|
17
|
+
colorBadgeDemo: () => React.JSX.Element;
|
|
18
|
+
typeBadgeDemo: () => React.JSX.Element;
|
|
19
|
+
maxBadgeDemo: () => React.JSX.Element;
|
|
20
|
+
accessibilityBadgeDemo: () => React.JSX.Element;
|
|
21
|
+
invisibilityBadgeDemo: () => React.JSX.Element;
|
|
22
|
+
complexInteractionBadgeDemo: () => React.JSX.Element;
|
|
23
|
+
specialContentBadgeDemo: () => React.JSX.Element;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Badge from "../../Badge";
|
|
3
|
+
const basicBadgeDemo = () => {
|
|
4
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Badge, { content: "12" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u5185\u5BB9")));
|
|
5
|
+
};
|
|
6
|
+
const colorBadgeDemo = () => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px" } }, /* @__PURE__ */ React.createElement(Badge, { content: "1", color: "primary" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Primary")), /* @__PURE__ */ React.createElement(Badge, { content: "2", color: "success" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Success")), /* @__PURE__ */ React.createElement(Badge, { content: "3", color: "warning" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Warning")), /* @__PURE__ */ React.createElement(Badge, { content: "4", color: "danger" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Danger")));
|
|
8
|
+
};
|
|
9
|
+
const typeBadgeDemo = () => {
|
|
10
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px" } }, /* @__PURE__ */ React.createElement(Badge, { content: "99", type: "standard" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Standard")), /* @__PURE__ */ React.createElement(Badge, { type: "dot" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Dot")), /* @__PURE__ */ React.createElement(Badge, { content: "NEW", type: "bubble" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Bubble")));
|
|
11
|
+
};
|
|
12
|
+
const maxBadgeDemo = () => {
|
|
13
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px" } }, /* @__PURE__ */ React.createElement(Badge, { content: 99, max: 50 }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "50+")), /* @__PURE__ */ React.createElement(Badge, { content: 150, max: 99 }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "99+")));
|
|
14
|
+
};
|
|
15
|
+
const accessibilityBadgeDemo = () => {
|
|
16
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px", flexDirection: "column" } }, /* @__PURE__ */ React.createElement(Badge, { content: 5, "aria-label": "\u81EA\u5B9A\u4E49\u6807\u7B7E" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u81EA\u5B9A\u4E49\u6807\u7B7E")), /* @__PURE__ */ React.createElement(Badge, { content: 3, role: "img" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u81EA\u5B9A\u4E49\u89D2\u8272")), /* @__PURE__ */ React.createElement(Badge, { content: 1, "aria-hidden": true }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u9690\u85CF\u89D2\u8272")), /* @__PURE__ */ React.createElement(Badge, { content: 2, "aria-hidden": true }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u9690\u85CF")));
|
|
17
|
+
};
|
|
18
|
+
const invisibilityBadgeDemo = () => {
|
|
19
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px" } }, /* @__PURE__ */ React.createElement(Badge, { content: 0, showZero: true }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "ShowZero")), /* @__PURE__ */ React.createElement(Badge, { content: 0, showZero: false }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "HideZero")), /* @__PURE__ */ React.createElement(Badge, { content: 5, invisible: false }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "Visible")));
|
|
20
|
+
};
|
|
21
|
+
const complexInteractionBadgeDemo = () => {
|
|
22
|
+
const ComplexInteractionBadgeDemo = () => {
|
|
23
|
+
const [count, setCount] = React.useState(1);
|
|
24
|
+
const [visible, setVisible] = React.useState(true);
|
|
25
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px", alignItems: "center" } }, /* @__PURE__ */ React.createElement(Badge, { content: count, invisible: !visible }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u5185\u5BB9")), /* @__PURE__ */ React.createElement(
|
|
26
|
+
"button",
|
|
27
|
+
{
|
|
28
|
+
type: "button",
|
|
29
|
+
onClick: () => setCount(count + 1),
|
|
30
|
+
style: { padding: "4px 8px" }
|
|
31
|
+
},
|
|
32
|
+
"\u589E\u52A0(",
|
|
33
|
+
count,
|
|
34
|
+
")"
|
|
35
|
+
), /* @__PURE__ */ React.createElement(
|
|
36
|
+
"button",
|
|
37
|
+
{
|
|
38
|
+
type: "button",
|
|
39
|
+
onClick: () => setVisible(!visible),
|
|
40
|
+
style: { padding: "4px 8px" }
|
|
41
|
+
},
|
|
42
|
+
visible ? "\u9690\u85CF" : "\u663E\u793A"
|
|
43
|
+
));
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ React.createElement(ComplexInteractionBadgeDemo, null);
|
|
46
|
+
};
|
|
47
|
+
const specialContentBadgeDemo = () => {
|
|
48
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "10px", flexWrap: "wrap" } }, /* @__PURE__ */ React.createElement(Badge, { content: "NEW" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u6587\u672C")), /* @__PURE__ */ React.createElement(Badge, { content: "99+" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "99+")), /* @__PURE__ */ React.createElement(Badge, { content: 1 }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u5355\u6570")), /* @__PURE__ */ React.createElement(Badge, { content: "" }, /* @__PURE__ */ React.createElement("div", { style: { width: 40, height: 40, background: "#f0f0f0" } }, "\u7A7A\u5185\u5BB9")));
|
|
49
|
+
};
|
|
50
|
+
var A11yDemos_default = {
|
|
51
|
+
basicBadgeDemo,
|
|
52
|
+
colorBadgeDemo,
|
|
53
|
+
typeBadgeDemo,
|
|
54
|
+
maxBadgeDemo,
|
|
55
|
+
accessibilityBadgeDemo,
|
|
56
|
+
invisibilityBadgeDemo,
|
|
57
|
+
complexInteractionBadgeDemo,
|
|
58
|
+
specialContentBadgeDemo
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
accessibilityBadgeDemo,
|
|
62
|
+
basicBadgeDemo,
|
|
63
|
+
colorBadgeDemo,
|
|
64
|
+
complexInteractionBadgeDemo,
|
|
65
|
+
A11yDemos_default as default,
|
|
66
|
+
invisibilityBadgeDemo,
|
|
67
|
+
maxBadgeDemo,
|
|
68
|
+
specialContentBadgeDemo,
|
|
69
|
+
typeBadgeDemo
|
|
70
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UseBadgeA11yProps {
|
|
3
|
+
displayValue: React.ReactNode;
|
|
4
|
+
type?: 'dot' | 'standard' | 'bubble';
|
|
5
|
+
'aria-label'?: string;
|
|
6
|
+
'aria-describedby'?: string;
|
|
7
|
+
role?: 'status' | 'img' | 'presentation';
|
|
8
|
+
'aria-hidden'?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface UseBadgeA11yResult {
|
|
11
|
+
accessibilityLabel: string | undefined;
|
|
12
|
+
ariaAttributes: {
|
|
13
|
+
role?: string;
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
'aria-describedby'?: string;
|
|
16
|
+
'aria-hidden'?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Badge 无障碍功能的自定义 Hook
|
|
21
|
+
* 负责处理可访问性标签和ARIA属性
|
|
22
|
+
*/
|
|
23
|
+
export declare const useBadgeA11y: ({ displayValue, type, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, role, "aria-hidden": ariaHidden, }: UseBadgeA11yProps) => UseBadgeA11yResult;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const useBadgeA11y = ({
|
|
3
|
+
displayValue,
|
|
4
|
+
type = "standard",
|
|
5
|
+
"aria-label": ariaLabel,
|
|
6
|
+
"aria-describedby": ariaDescribedby,
|
|
7
|
+
role = "status",
|
|
8
|
+
"aria-hidden": ariaHidden = false
|
|
9
|
+
}) => {
|
|
10
|
+
const accessibilityLabel = useMemo(() => {
|
|
11
|
+
if (ariaLabel)
|
|
12
|
+
return ariaLabel;
|
|
13
|
+
if (ariaHidden)
|
|
14
|
+
return void 0;
|
|
15
|
+
if (type === "dot") {
|
|
16
|
+
return "\u6709\u65B0\u901A\u77E5";
|
|
17
|
+
}
|
|
18
|
+
if (displayValue !== null && displayValue !== void 0) {
|
|
19
|
+
if (String(displayValue).includes("+")) {
|
|
20
|
+
return `\u8D85\u8FC7${String(displayValue).replace("+", "")}\u6761\u901A\u77E5`;
|
|
21
|
+
}
|
|
22
|
+
const numValue = Number(displayValue);
|
|
23
|
+
if (!Number.isNaN(numValue)) {
|
|
24
|
+
if (numValue === 0)
|
|
25
|
+
return "\u65E0\u901A\u77E5";
|
|
26
|
+
if (numValue === 1)
|
|
27
|
+
return "1\u6761\u901A\u77E5";
|
|
28
|
+
return `${displayValue}\u6761\u901A\u77E5`;
|
|
29
|
+
}
|
|
30
|
+
return `\u901A\u77E5\uFF1A${displayValue}`;
|
|
31
|
+
}
|
|
32
|
+
return void 0;
|
|
33
|
+
}, [ariaLabel, ariaHidden, type, displayValue]);
|
|
34
|
+
const ariaAttributes = useMemo(() => {
|
|
35
|
+
if (ariaHidden) {
|
|
36
|
+
return {
|
|
37
|
+
"aria-hidden": true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
role,
|
|
42
|
+
"aria-label": accessibilityLabel,
|
|
43
|
+
"aria-describedby": ariaDescribedby
|
|
44
|
+
};
|
|
45
|
+
}, [ariaHidden, role, accessibilityLabel, ariaDescribedby]);
|
|
46
|
+
return {
|
|
47
|
+
accessibilityLabel,
|
|
48
|
+
ariaAttributes
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
useBadgeA11y
|
|
53
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UseBadgeDisplayProps {
|
|
3
|
+
content?: React.ReactNode;
|
|
4
|
+
max?: number;
|
|
5
|
+
showZero?: boolean;
|
|
6
|
+
type?: 'dot' | 'standard' | 'bubble';
|
|
7
|
+
}
|
|
8
|
+
export interface UseBadgeDisplayResult {
|
|
9
|
+
displayValue: React.ReactNode;
|
|
10
|
+
shouldShowBadge: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Badge 显示逻辑的自定义 Hook
|
|
14
|
+
* 负责计算显示值和判断是否应该显示徽章
|
|
15
|
+
*/
|
|
16
|
+
export declare const useBadgeDisplay: ({ content, max, showZero, type, }: UseBadgeDisplayProps) => UseBadgeDisplayResult;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const useBadgeDisplay = ({
|
|
3
|
+
content,
|
|
4
|
+
max,
|
|
5
|
+
showZero = false,
|
|
6
|
+
type = "standard"
|
|
7
|
+
}) => {
|
|
8
|
+
const displayValue = useMemo(() => {
|
|
9
|
+
if (type === "dot") {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (!Number.isNaN(Number(content)) && typeof max === "number") {
|
|
13
|
+
return Number(content) > Number(max) ? `${max}+` : content;
|
|
14
|
+
}
|
|
15
|
+
return content;
|
|
16
|
+
}, [content, max, type]);
|
|
17
|
+
const shouldShowBadge = useMemo(() => {
|
|
18
|
+
if (type === "dot") {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (content === 0 && !showZero) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return !!content || content === 0;
|
|
25
|
+
}, [content, showZero, type]);
|
|
26
|
+
return {
|
|
27
|
+
displayValue,
|
|
28
|
+
shouldShowBadge
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
useBadgeDisplay
|
|
33
|
+
};
|
package/es/Button/Button.js
CHANGED
|
@@ -69,7 +69,8 @@ const Button = /* @__PURE__ */ React.forwardRef(
|
|
|
69
69
|
className
|
|
70
70
|
),
|
|
71
71
|
ref,
|
|
72
|
-
disabled
|
|
72
|
+
disabled,
|
|
73
|
+
"aria-disabled": disabled ? "true" : void 0
|
|
73
74
|
}, others),
|
|
74
75
|
startIcon && /* @__PURE__ */ React.createElement(ButtonIcon, { iconPosition: "start" }, startIcon),
|
|
75
76
|
children,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 自定义 Button 组件 Demo 集合
|
|
4
|
+
* 这个文件包含多个测试 demo,展示如何使用 getCustomDemoCodesFromFile 进行无障碍测试
|
|
5
|
+
* 文件名必须是 customDemoComponent.tsx(固定约定)
|
|
6
|
+
*/
|
|
7
|
+
export declare const basicButtonDemo: () => React.JSX.Element;
|
|
8
|
+
export declare const variantButtonDemo: () => React.JSX.Element;
|
|
9
|
+
export declare const colorButtonDemo: () => React.JSX.Element;
|
|
10
|
+
export declare const sizeButtonDemo: () => React.JSX.Element;
|
|
11
|
+
export declare const disabledButtonDemo: () => React.JSX.Element;
|
|
12
|
+
export declare const iconButtonDemo: () => React.JSX.Element;
|
|
13
|
+
export declare const ariaLabelButtonDemo: () => React.JSX.Element;
|
|
14
|
+
declare const _default: {
|
|
15
|
+
basicButtonDemo: () => React.JSX.Element;
|
|
16
|
+
variantButtonDemo: () => React.JSX.Element;
|
|
17
|
+
colorButtonDemo: () => React.JSX.Element;
|
|
18
|
+
sizeButtonDemo: () => React.JSX.Element;
|
|
19
|
+
disabledButtonDemo: () => React.JSX.Element;
|
|
20
|
+
iconButtonDemo: () => React.JSX.Element;
|
|
21
|
+
ariaLabelButtonDemo: () => React.JSX.Element;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Button from "../../Button";
|
|
3
|
+
const basicButtonDemo = () => {
|
|
4
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, null, "\u57FA\u7840\u6309\u94AE"));
|
|
5
|
+
};
|
|
6
|
+
const variantButtonDemo = () => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, { variant: "text" }, "\u6587\u5B57\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { variant: "outlined" }, "\u7EBF\u6846\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { variant: "contained" }, "\u586B\u5145\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { variant: "subtle" }, "\u67D4\u548C\u6309\u94AE"));
|
|
8
|
+
};
|
|
9
|
+
const colorButtonDemo = () => {
|
|
10
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, { color: "primary" }, "\u4E3B\u8981\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { color: "success" }, "\u6210\u529F\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { color: "warning" }, "\u8B66\u544A\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { color: "danger" }, "\u5371\u9669\u6309\u94AE"));
|
|
11
|
+
};
|
|
12
|
+
const sizeButtonDemo = () => {
|
|
13
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, { size: "small" }, "\u5C0F\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { size: "medium" }, "\u4E2D\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { size: "large" }, "\u5927\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { size: "full", style: { width: "200px" } }, "\u5168\u5BBD\u6309\u94AE"));
|
|
14
|
+
};
|
|
15
|
+
const disabledButtonDemo = () => {
|
|
16
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, { disabled: true }, "\u7981\u7528\u6309\u94AE"), /* @__PURE__ */ React.createElement(Button, { variant: "contained", disabled: true }, "\u7981\u7528\u586B\u5145\u6309\u94AE"));
|
|
17
|
+
};
|
|
18
|
+
const iconButtonDemo = () => {
|
|
19
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, { startIcon: /* @__PURE__ */ React.createElement("span", null, "\u{1F31F}") }, "\u5E26\u524D\u7F00\u56FE\u6807"), /* @__PURE__ */ React.createElement(Button, { endIcon: /* @__PURE__ */ React.createElement("span", null, "\u{1F4C5}") }, "\u5E26\u540E\u7F00\u56FE\u6807"));
|
|
20
|
+
};
|
|
21
|
+
const ariaLabelButtonDemo = () => {
|
|
22
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Button, { "aria-label": "\u63D0\u4EA4\u8868\u5355" }, "\u63D0\u4EA4"), /* @__PURE__ */ React.createElement(Button, { "aria-label": "\u53D6\u6D88\u64CD\u4F5C" }, "\u53D6\u6D88"));
|
|
23
|
+
};
|
|
24
|
+
var A11yDemos_default = {
|
|
25
|
+
basicButtonDemo,
|
|
26
|
+
variantButtonDemo,
|
|
27
|
+
colorButtonDemo,
|
|
28
|
+
sizeButtonDemo,
|
|
29
|
+
disabledButtonDemo,
|
|
30
|
+
iconButtonDemo,
|
|
31
|
+
ariaLabelButtonDemo
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
ariaLabelButtonDemo,
|
|
35
|
+
basicButtonDemo,
|
|
36
|
+
colorButtonDemo,
|
|
37
|
+
A11yDemos_default as default,
|
|
38
|
+
disabledButtonDemo,
|
|
39
|
+
iconButtonDemo,
|
|
40
|
+
sizeButtonDemo,
|
|
41
|
+
variantButtonDemo
|
|
42
|
+
};
|
package/es/Button/index.css
CHANGED
|
@@ -8,7 +8,7 @@ xhs-page {
|
|
|
8
8
|
--bui-btn-large-border-radius: 120px;
|
|
9
9
|
--bui-btn-full-border-radius: 120px;
|
|
10
10
|
--bui-btn-color: var(--bui-color-fg-muted);
|
|
11
|
-
--bui-btn-
|
|
11
|
+
--bui-btn-bg: var(--bui-color-bg-view);
|
|
12
12
|
--bui-btn-border: 0;
|
|
13
13
|
--bui-btn-height: 27px;
|
|
14
14
|
--bui-btn-small-height: 24px;
|
|
@@ -20,8 +20,8 @@ xhs-page {
|
|
|
20
20
|
--bui-btn-small-padding: 0 11px;
|
|
21
21
|
--bui-btn-padding: 0 14px;
|
|
22
22
|
--bui-btn-large-padding: 0 14px;
|
|
23
|
+
--bui-btn-large-font-size: var(--bui-text-size-2);
|
|
23
24
|
--bui-btn-full-font-size: var(--bui-title-size-4);
|
|
24
|
-
--bui-btn-full-font-family: var(--bui-font-family);
|
|
25
25
|
}
|
|
26
26
|
.bui-btn {
|
|
27
27
|
outline: 0;
|
|
@@ -34,7 +34,7 @@ xhs-page {
|
|
|
34
34
|
justify-content: center;
|
|
35
35
|
white-space: nowrap;
|
|
36
36
|
color: var(--bui-btn-color);
|
|
37
|
-
background: var(--bui-btn-
|
|
37
|
+
background: var(--bui-btn-bg);
|
|
38
38
|
font-size: var(--bui-btn-font-size);
|
|
39
39
|
font-weight: var(--bui-btn-font-weight);
|
|
40
40
|
border: var(--bui-btn-border);
|
|
@@ -95,13 +95,12 @@ xhs-page {
|
|
|
95
95
|
border-radius: var(--bui-btn-small-border-radius);
|
|
96
96
|
}
|
|
97
97
|
.bui-btn-large {
|
|
98
|
-
font-size: var(--bui-
|
|
98
|
+
font-size: var(--bui-btn-large-font-size);
|
|
99
99
|
padding: var(--bui-btn-large-padding);
|
|
100
100
|
height: var(--bui-btn-large-height);
|
|
101
101
|
border-radius: var(--bui-btn-large-border-radius);
|
|
102
102
|
}
|
|
103
103
|
.bui-btn-full {
|
|
104
|
-
font-family: var(--bui-btn-full-font-family);
|
|
105
104
|
font-size: var(--bui-btn-full-font-size);
|
|
106
105
|
width: 100%;
|
|
107
106
|
height: var(--bui-btn-full-height);
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import React, { useRef } from "react";
|
|
33
|
+
import {
|
|
34
|
+
addClass as addOneClass,
|
|
35
|
+
removeClass as removeOneClass
|
|
36
|
+
} from "@bifrostui/utils";
|
|
37
|
+
import Transition from "../Transition";
|
|
38
|
+
const forceReflow = (node) => node.scrollTop;
|
|
39
|
+
const benchAddClass = (node, classes) => node && classes && classes.split(" ").forEach((c) => addOneClass(node, c));
|
|
40
|
+
const benchRemoveClass = (node, classes) => node && classes && classes.split(" ").forEach((c) => removeOneClass(node, c));
|
|
41
|
+
const CSSTransition = /* @__PURE__ */ React.forwardRef(
|
|
42
|
+
(props, ref) => {
|
|
43
|
+
const _a = props, { classNames = "" } = _a, others = __objRest(_a, ["classNames"]);
|
|
44
|
+
const appliedClasses = useRef({
|
|
45
|
+
appear: {},
|
|
46
|
+
enter: {},
|
|
47
|
+
exit: {}
|
|
48
|
+
});
|
|
49
|
+
const getClassNames = (type) => {
|
|
50
|
+
const isStringClassNames = typeof classNames === "string";
|
|
51
|
+
const prefix = isStringClassNames && classNames ? `${classNames}-` : "";
|
|
52
|
+
if (isStringClassNames) {
|
|
53
|
+
return {
|
|
54
|
+
baseClassName: `${prefix}${type}`,
|
|
55
|
+
activeClassName: `${prefix}${type}-active`,
|
|
56
|
+
doneClassName: `${prefix}${type}-done`
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
baseClassName: classNames == null ? void 0 : classNames[type],
|
|
61
|
+
activeClassName: classNames == null ? void 0 : classNames[`${type}Active`],
|
|
62
|
+
doneClassName: classNames == null ? void 0 : classNames[`${type}Done`]
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const addClass = (node, type, phase) => {
|
|
66
|
+
const className = getClassNames(type)[`${phase}ClassName`];
|
|
67
|
+
if (phase === "active") {
|
|
68
|
+
if (node)
|
|
69
|
+
forceReflow(node);
|
|
70
|
+
}
|
|
71
|
+
if (className) {
|
|
72
|
+
appliedClasses.current[type][phase] = className;
|
|
73
|
+
benchAddClass(node, className);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const removeClasses = (node, type) => {
|
|
77
|
+
const {
|
|
78
|
+
base: baseClassName,
|
|
79
|
+
active: activeClassName,
|
|
80
|
+
done: doneClassName
|
|
81
|
+
} = appliedClasses.current[type];
|
|
82
|
+
appliedClasses.current[type] = {};
|
|
83
|
+
if (baseClassName) {
|
|
84
|
+
benchRemoveClass(node, baseClassName);
|
|
85
|
+
}
|
|
86
|
+
if (activeClassName) {
|
|
87
|
+
benchRemoveClass(node, activeClassName);
|
|
88
|
+
}
|
|
89
|
+
if (doneClassName) {
|
|
90
|
+
benchRemoveClass(node, doneClassName);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const onEnter = (node) => {
|
|
94
|
+
removeClasses(node, "exit");
|
|
95
|
+
addClass(node, "enter", "base");
|
|
96
|
+
if (props.onEnter) {
|
|
97
|
+
props.onEnter(node);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const onEntering = (node) => {
|
|
101
|
+
addClass(node, "enter", "active");
|
|
102
|
+
if (props.onEntering) {
|
|
103
|
+
props.onEntering(node);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const onEntered = (node) => {
|
|
107
|
+
removeClasses(node, "enter");
|
|
108
|
+
addClass(node, "enter", "done");
|
|
109
|
+
if (props.onEntered) {
|
|
110
|
+
props.onEntered(node);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const onExit = (node) => {
|
|
114
|
+
removeClasses(node, "enter");
|
|
115
|
+
addClass(node, "exit", "base");
|
|
116
|
+
if (props.onExit) {
|
|
117
|
+
props.onExit(node);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const onExiting = (node) => {
|
|
121
|
+
addClass(node, "exit", "active");
|
|
122
|
+
if (props.onExiting) {
|
|
123
|
+
props.onExiting(node);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const onExited = (node) => {
|
|
127
|
+
removeClasses(node, "exit");
|
|
128
|
+
addClass(node, "exit", "done");
|
|
129
|
+
if (props.onExited) {
|
|
130
|
+
props.onExited(node);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return /* @__PURE__ */ React.createElement(
|
|
134
|
+
Transition,
|
|
135
|
+
__spreadProps(__spreadValues({
|
|
136
|
+
ref,
|
|
137
|
+
delay: 0
|
|
138
|
+
}, others), {
|
|
139
|
+
onEnter,
|
|
140
|
+
onEntered,
|
|
141
|
+
onEntering,
|
|
142
|
+
onExit,
|
|
143
|
+
onExiting,
|
|
144
|
+
onExited
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
CSSTransition.displayName = "BuiCSSTransition";
|
|
150
|
+
var CSSTransition_default = CSSTransition;
|
|
151
|
+
export {
|
|
152
|
+
CSSTransition_default as default
|
|
153
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TransitionProps } from '../Transition';
|
|
2
|
+
type IClassNames = string | {
|
|
3
|
+
enter?: string;
|
|
4
|
+
enterActive?: string;
|
|
5
|
+
enterDone?: string;
|
|
6
|
+
exit?: string;
|
|
7
|
+
exitActive?: string;
|
|
8
|
+
exitDone?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface CSSTransitionProps extends TransitionProps {
|
|
11
|
+
classNames?: IClassNames;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|