@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/Dialog/Dialog.js
CHANGED
|
@@ -30,7 +30,8 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import clsx from "clsx";
|
|
33
|
-
import React, {
|
|
33
|
+
import React, { useRef } from "react";
|
|
34
|
+
import { useUniqueId } from "@bifrostui/utils";
|
|
34
35
|
import { Input } from "../Input";
|
|
35
36
|
import { Button } from "../Button";
|
|
36
37
|
import { useLocaleText } from "../locales";
|
|
@@ -42,11 +43,11 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
42
43
|
const _a = props, {
|
|
43
44
|
open,
|
|
44
45
|
onOk,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
type,
|
|
49
|
-
|
|
46
|
+
onCancel,
|
|
47
|
+
title,
|
|
48
|
+
content,
|
|
49
|
+
type = "confirm",
|
|
50
|
+
okText,
|
|
50
51
|
cancelText,
|
|
51
52
|
placeholder,
|
|
52
53
|
InputProps,
|
|
@@ -55,33 +56,42 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
55
56
|
} = _a, others = __objRest(_a, [
|
|
56
57
|
"open",
|
|
57
58
|
"onOk",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
59
|
+
"onCancel",
|
|
60
|
+
"title",
|
|
61
|
+
"content",
|
|
61
62
|
"type",
|
|
62
|
-
"
|
|
63
|
+
"okText",
|
|
63
64
|
"cancelText",
|
|
64
65
|
"placeholder",
|
|
65
66
|
"InputProps",
|
|
66
67
|
"className",
|
|
67
68
|
"theme"
|
|
68
69
|
]);
|
|
69
|
-
const
|
|
70
|
+
const inputRef = useRef(null);
|
|
71
|
+
const titleId = useUniqueId();
|
|
72
|
+
const contentId = useUniqueId();
|
|
70
73
|
const themeConfig = useTheme(theme);
|
|
71
74
|
const {
|
|
72
75
|
cancel,
|
|
73
|
-
|
|
76
|
+
ok,
|
|
74
77
|
placeholder: placeholderLocaleName
|
|
75
78
|
} = useLocaleText("dialog", themeConfig);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const isAlertMode = type === "alert";
|
|
80
|
+
const isPromptMode = type === "prompt";
|
|
81
|
+
const handleOk = (event) => {
|
|
82
|
+
var _a2;
|
|
83
|
+
const inputValue = ((_a2 = inputRef.current) == null ? void 0 : _a2.value) || "";
|
|
84
|
+
onOk == null ? void 0 : onOk(event, { value: inputValue });
|
|
85
|
+
};
|
|
86
|
+
const handleCancel = (event) => {
|
|
87
|
+
onCancel == null ? void 0 : onCancel(event);
|
|
88
|
+
};
|
|
89
|
+
const actionsNode = /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-actions` }, !isAlertMode && /* @__PURE__ */ React.createElement(
|
|
80
90
|
Button,
|
|
81
91
|
{
|
|
82
92
|
variant: "text",
|
|
83
|
-
onClick:
|
|
84
|
-
className: `${prefixCls}-
|
|
93
|
+
onClick: handleCancel,
|
|
94
|
+
className: `${prefixCls}-actions-btn`
|
|
85
95
|
},
|
|
86
96
|
cancelText || cancel
|
|
87
97
|
), /* @__PURE__ */ React.createElement(
|
|
@@ -89,33 +99,45 @@ const Dialog = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
89
99
|
{
|
|
90
100
|
variant: "text",
|
|
91
101
|
color: "primary",
|
|
92
|
-
onClick:
|
|
93
|
-
|
|
94
|
-
onOk((_a2 = InputRef == null ? void 0 : InputRef.current) == null ? void 0 : _a2.value);
|
|
95
|
-
},
|
|
96
|
-
className: `${prefixCls}-body-button`
|
|
102
|
+
onClick: handleOk,
|
|
103
|
+
className: `${prefixCls}-actions-btn`
|
|
97
104
|
},
|
|
98
|
-
|
|
105
|
+
okText || ok
|
|
99
106
|
));
|
|
100
|
-
const inputNode =
|
|
107
|
+
const inputNode = isPromptMode && /* @__PURE__ */ React.createElement(
|
|
101
108
|
Input,
|
|
102
109
|
__spreadProps(__spreadValues({}, InputProps), {
|
|
103
|
-
inputRef
|
|
104
|
-
className: `${prefixCls}-
|
|
105
|
-
placeholder:
|
|
110
|
+
inputRef,
|
|
111
|
+
className: `${prefixCls}-input`,
|
|
112
|
+
placeholder: placeholder || placeholderLocaleName,
|
|
113
|
+
autoFocus: true,
|
|
114
|
+
"aria-describedby": content ? contentId : void 0
|
|
106
115
|
})
|
|
107
116
|
);
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
const ariaLabelledBy = title ? titleId : void 0;
|
|
118
|
+
const ariaDescribedBy = content ? contentId : void 0;
|
|
110
119
|
return /* @__PURE__ */ React.createElement(
|
|
111
120
|
Modal,
|
|
112
121
|
__spreadProps(__spreadValues({}, others), {
|
|
113
|
-
open
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
onClose
|
|
122
|
+
open,
|
|
123
|
+
ref,
|
|
124
|
+
className: clsx(prefixCls, `${prefixCls}-${type}`, className),
|
|
125
|
+
onClose: handleCancel
|
|
117
126
|
}),
|
|
118
|
-
/* @__PURE__ */ React.createElement(
|
|
127
|
+
/* @__PURE__ */ React.createElement(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: `${prefixCls}-container`,
|
|
131
|
+
role: type === "alert" ? "alertdialog" : "dialog",
|
|
132
|
+
"aria-modal": "true",
|
|
133
|
+
"aria-labelledby": ariaLabelledBy,
|
|
134
|
+
"aria-describedby": ariaDescribedBy
|
|
135
|
+
},
|
|
136
|
+
title && /* @__PURE__ */ React.createElement("h1", { id: titleId, className: `${prefixCls}-title` }, title),
|
|
137
|
+
content && /* @__PURE__ */ React.createElement("div", { id: contentId, className: `${prefixCls}-content` }, content),
|
|
138
|
+
inputNode,
|
|
139
|
+
actionsNode
|
|
140
|
+
)
|
|
119
141
|
);
|
|
120
142
|
});
|
|
121
143
|
Dialog.displayName = "BuiDialog";
|
|
@@ -5,12 +5,9 @@ import { ThemeProps } from '../ThemeProvider/ThemeProvider.types';
|
|
|
5
5
|
/**
|
|
6
6
|
* 对话框类型
|
|
7
7
|
*/
|
|
8
|
-
export type DialogType = 'confirm' | 'prompt';
|
|
9
|
-
export type Dispatch = (action: boolean, val?: string) => void;
|
|
10
|
-
export
|
|
11
|
-
theme?: ThemeProps;
|
|
12
|
-
};
|
|
13
|
-
export interface DialogProps extends ModalProps {
|
|
8
|
+
export type DialogType = 'confirm' | 'prompt' | 'alert';
|
|
9
|
+
export type Dispatch = (action: boolean, e: React.SyntheticEvent, val?: string) => void;
|
|
10
|
+
export interface DialogProps extends Omit<ModalProps, 'title' | 'content'> {
|
|
14
11
|
/**
|
|
15
12
|
* 对话框类型
|
|
16
13
|
* @default confirm
|
|
@@ -19,11 +16,11 @@ export interface DialogProps extends ModalProps {
|
|
|
19
16
|
/**
|
|
20
17
|
* 自定义标题
|
|
21
18
|
*/
|
|
22
|
-
|
|
19
|
+
title?: ReactNode;
|
|
23
20
|
/**
|
|
24
21
|
* 自定义内容
|
|
25
22
|
*/
|
|
26
|
-
|
|
23
|
+
content?: ReactNode;
|
|
27
24
|
/**
|
|
28
25
|
* 输入框占位文本
|
|
29
26
|
*/
|
|
@@ -33,9 +30,9 @@ export interface DialogProps extends ModalProps {
|
|
|
33
30
|
*/
|
|
34
31
|
InputProps?: Partial<InputProps>;
|
|
35
32
|
/**
|
|
36
|
-
*
|
|
33
|
+
* 确认按钮文本内容
|
|
37
34
|
*/
|
|
38
|
-
|
|
35
|
+
okText?: ReactNode;
|
|
39
36
|
/**
|
|
40
37
|
* 取消文本内容
|
|
41
38
|
*/
|
|
@@ -44,27 +41,36 @@ export interface DialogProps extends ModalProps {
|
|
|
44
41
|
* theme 主题定制
|
|
45
42
|
*/
|
|
46
43
|
theme?: ThemeProps;
|
|
44
|
+
/**
|
|
45
|
+
* 渲染Dialog的根容器
|
|
46
|
+
* @default document.body
|
|
47
|
+
*/
|
|
48
|
+
container?: HTMLElement | (() => HTMLElement);
|
|
47
49
|
/**
|
|
48
50
|
* 确认回调
|
|
49
51
|
*/
|
|
50
|
-
onOk?: (
|
|
52
|
+
onOk?: (e: React.SyntheticEvent, data: {
|
|
53
|
+
value: string;
|
|
54
|
+
}) => void;
|
|
51
55
|
/**
|
|
52
56
|
* 取消回调
|
|
53
57
|
*/
|
|
54
|
-
|
|
58
|
+
onCancel?: (e: React.SyntheticEvent) => void;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* 函数式调用配置参数
|
|
58
62
|
*/
|
|
59
|
-
export type DialogOptions = Omit<DialogProps, 'placeholder' | 'inputProps' | 'onOk' | '
|
|
63
|
+
export type DialogOptions = Omit<DialogProps, 'placeholder' | 'inputProps' | 'onOk' | 'onCancel'> & {
|
|
60
64
|
/**
|
|
61
65
|
* 确认回调
|
|
62
66
|
*/
|
|
63
|
-
|
|
67
|
+
onOk?: (e: React.SyntheticEvent, data: {
|
|
68
|
+
value: string;
|
|
69
|
+
}) => void;
|
|
64
70
|
/**
|
|
65
71
|
* 取消回调
|
|
66
72
|
*/
|
|
67
|
-
onCancel?: () => void
|
|
73
|
+
onCancel?: (e: React.SyntheticEvent) => void;
|
|
68
74
|
};
|
|
69
75
|
/**
|
|
70
76
|
* prompt函数式调用配置参数
|
|
@@ -83,6 +89,10 @@ export type PromptOptions = (DialogOptions & {
|
|
|
83
89
|
* confirm函数式调用配置参数
|
|
84
90
|
*/
|
|
85
91
|
export type ConfirmOptions = DialogOptions | string;
|
|
92
|
+
/**
|
|
93
|
+
* alert函数式调用配置参数
|
|
94
|
+
*/
|
|
95
|
+
export type AlertOptions = DialogOptions | string;
|
|
86
96
|
/**
|
|
87
97
|
* Dialog函数式调用返回值类型
|
|
88
98
|
*/
|
|
@@ -91,19 +101,37 @@ export type DialogPromise = Promise<boolean | string>;
|
|
|
91
101
|
* Dialog Instance
|
|
92
102
|
*/
|
|
93
103
|
export interface DialogFunction {
|
|
94
|
-
/**
|
|
95
|
-
* 直接调用显示确认框 Dialog
|
|
96
|
-
*/
|
|
97
|
-
(options: ConfirmOptions): DialogPromise;
|
|
98
104
|
/**
|
|
99
105
|
* 显示确认框 Dialog.confirm
|
|
100
106
|
*/
|
|
101
|
-
confirm?: (options: ConfirmOptions) =>
|
|
107
|
+
confirm?: (options: ConfirmOptions) => Promise<boolean>;
|
|
102
108
|
/**
|
|
103
109
|
* 显示提示对话框 Dialog.prompt
|
|
104
110
|
*/
|
|
105
|
-
prompt?: (options: PromptOptions, val?: string) =>
|
|
111
|
+
prompt?: (options: PromptOptions, val?: string) => Promise<string | null>;
|
|
112
|
+
/**
|
|
113
|
+
* 显示警告对话框 Dialog.alert
|
|
114
|
+
*/
|
|
115
|
+
alert?: (options: AlertOptions) => Promise<boolean>;
|
|
106
116
|
}
|
|
107
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Dialog组件类型,支持组件式调用和函数式调用
|
|
119
|
+
*/
|
|
120
|
+
export interface DialogComponent extends React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLDivElement>> {
|
|
121
|
+
/**
|
|
122
|
+
* 显示确认框
|
|
123
|
+
*/
|
|
124
|
+
confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* 显示提示对话框
|
|
127
|
+
*/
|
|
128
|
+
prompt: (options: PromptOptions) => Promise<string | null>;
|
|
129
|
+
/**
|
|
130
|
+
* 显示警告对话框
|
|
131
|
+
*/
|
|
132
|
+
alert: (options: AlertOptions) => Promise<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* 使用Dialog Hook
|
|
135
|
+
*/
|
|
108
136
|
useDialog: () => [DialogFunction, React.JSX.Element];
|
|
109
137
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DialogPromise, PromptOptions, ConfirmOptions, AlertOptions, DialogOptions, DialogFunction } from './Dialog.types';
|
|
3
|
+
declare const FunctionalDialog: {
|
|
4
|
+
(props: DialogOptions | string): DialogPromise;
|
|
5
|
+
confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
6
|
+
prompt: (options: PromptOptions) => Promise<string>;
|
|
7
|
+
alert: (options: AlertOptions) => Promise<boolean>;
|
|
8
|
+
useDialog: () => [DialogFunction, React.JSX.Element];
|
|
9
|
+
};
|
|
10
|
+
export default FunctionalDialog;
|
|
@@ -49,136 +49,158 @@ var __async = (__this, __arguments, generator) => {
|
|
|
49
49
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
-
import React, { useCallback,
|
|
53
|
-
import {
|
|
54
|
-
import
|
|
55
|
-
const { isValidElement
|
|
52
|
+
import React, { useCallback, useState } from "react";
|
|
53
|
+
import { getRootContainer, render, unmount, isMini } from "@bifrostui/utils";
|
|
54
|
+
import Dialog from "./Dialog";
|
|
55
|
+
const { isValidElement } = React;
|
|
56
56
|
const formatProps = (props) => {
|
|
57
57
|
if (typeof props === "string" || isValidElement(props)) {
|
|
58
|
-
return {
|
|
58
|
+
return { content: props };
|
|
59
59
|
}
|
|
60
60
|
return props;
|
|
61
61
|
};
|
|
62
62
|
const DialogGenerator = (options) => {
|
|
63
|
-
const
|
|
64
|
-
const rootElement =
|
|
65
|
-
rootElement.appendChild(
|
|
66
|
-
const
|
|
67
|
-
const _a = options, {
|
|
68
|
-
const [visible, setVisible] = useState(false);
|
|
63
|
+
const dialogFragment = isMini ? document.createElement("div") : document.createDocumentFragment();
|
|
64
|
+
const rootElement = getRootContainer(options == null ? void 0 : options.container);
|
|
65
|
+
rootElement.appendChild(dialogFragment);
|
|
66
|
+
const DialogWrapper = () => {
|
|
67
|
+
const _a = options, { onOk, onCancel } = _a, rest = __objRest(_a, ["onOk", "onCancel"]);
|
|
69
68
|
const close = useCallback(() => {
|
|
70
|
-
setVisible(false);
|
|
71
69
|
setTimeout(() => {
|
|
72
|
-
const unmountRes = unmount(
|
|
73
|
-
if (unmountRes &&
|
|
74
|
-
|
|
70
|
+
const unmountRes = unmount(dialogFragment);
|
|
71
|
+
if (unmountRes && dialogFragment.parentNode) {
|
|
72
|
+
dialogFragment.parentNode.removeChild(dialogFragment);
|
|
75
73
|
}
|
|
76
74
|
}, 150);
|
|
77
|
-
}, [
|
|
78
|
-
|
|
79
|
-
setVisible(true);
|
|
80
|
-
}, []);
|
|
81
|
-
const dispatch = (action, val) => __async(void 0, null, function* () {
|
|
75
|
+
}, [dialogFragment]);
|
|
76
|
+
const dispatch = (action, e, val = "") => __async(void 0, null, function* () {
|
|
82
77
|
if (action === true) {
|
|
83
|
-
|
|
84
|
-
yield onConfirm == null ? void 0 : onConfirm(val);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
}
|
|
78
|
+
yield onOk == null ? void 0 : onOk(e, { value: val });
|
|
87
79
|
} else if (action === false) {
|
|
88
|
-
|
|
89
|
-
yield onCancel == null ? void 0 : onCancel();
|
|
90
|
-
} catch (error) {
|
|
91
|
-
}
|
|
80
|
+
yield onCancel == null ? void 0 : onCancel(e);
|
|
92
81
|
}
|
|
93
82
|
close();
|
|
94
83
|
});
|
|
95
84
|
return /* @__PURE__ */ React.createElement(
|
|
96
|
-
|
|
97
|
-
__spreadProps(__spreadValues({
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
onOk: (val) => dispatch(true, val),
|
|
102
|
-
onClose: () => dispatch(false)
|
|
85
|
+
Dialog,
|
|
86
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
87
|
+
open: true,
|
|
88
|
+
onOk: (e, { value }) => dispatch(true, e, value),
|
|
89
|
+
onCancel: (e) => dispatch(false, e)
|
|
103
90
|
})
|
|
104
91
|
);
|
|
105
92
|
};
|
|
106
|
-
return render(/* @__PURE__ */ React.createElement(
|
|
93
|
+
return render(/* @__PURE__ */ React.createElement(DialogWrapper, null), dialogFragment);
|
|
107
94
|
};
|
|
108
|
-
const
|
|
95
|
+
const FunctionalDialog = (props) => {
|
|
109
96
|
const options = formatProps(props);
|
|
110
|
-
const _a = options, {
|
|
97
|
+
const _a = options, { onOk, onCancel } = _a, rest = __objRest(_a, ["onOk", "onCancel"]);
|
|
111
98
|
return new Promise((resolve) => {
|
|
112
99
|
DialogGenerator(__spreadProps(__spreadValues({}, rest), {
|
|
113
|
-
|
|
114
|
-
yield
|
|
100
|
+
onOk: (_0, _1) => __async(void 0, [_0, _1], function* (e, { value: val }) {
|
|
101
|
+
yield onOk == null ? void 0 : onOk(e, { value: val });
|
|
115
102
|
if (rest.type === "prompt")
|
|
116
103
|
resolve(val);
|
|
117
104
|
else
|
|
118
105
|
resolve(true);
|
|
119
106
|
}),
|
|
120
|
-
onCancel: () => __async(void 0, null, function* () {
|
|
121
|
-
yield onCancel == null ? void 0 : onCancel();
|
|
122
|
-
|
|
107
|
+
onCancel: (e) => __async(void 0, null, function* () {
|
|
108
|
+
yield onCancel == null ? void 0 : onCancel(e);
|
|
109
|
+
if (rest.type === "prompt")
|
|
110
|
+
resolve(null);
|
|
111
|
+
else
|
|
112
|
+
resolve(false);
|
|
123
113
|
})
|
|
124
114
|
}));
|
|
125
115
|
});
|
|
126
116
|
};
|
|
127
|
-
Dialog.prototype = Component.prototype;
|
|
128
117
|
const confirm = (options) => {
|
|
129
|
-
return
|
|
118
|
+
return FunctionalDialog(__spreadValues({
|
|
130
119
|
type: "confirm"
|
|
131
120
|
}, formatProps(options)));
|
|
132
121
|
};
|
|
133
122
|
const prompt = (options) => {
|
|
134
|
-
return
|
|
123
|
+
return FunctionalDialog(__spreadValues({
|
|
135
124
|
type: "prompt"
|
|
136
125
|
}, formatProps(options)));
|
|
137
126
|
};
|
|
127
|
+
const alert = (options) => {
|
|
128
|
+
return FunctionalDialog(__spreadValues({
|
|
129
|
+
type: "alert"
|
|
130
|
+
}, formatProps(options)));
|
|
131
|
+
};
|
|
138
132
|
const useDialog = () => {
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
var _a;
|
|
142
|
-
const options = __spreadValues({ theme: (_a = holderRef.current) == null ? void 0 : _a.theme }, formatProps(props));
|
|
143
|
-
const _b = options, { onConfirm, onCancel } = _b, rest = __objRest(_b, ["onConfirm", "onCancel"]);
|
|
133
|
+
const [elements, setElements] = useState([]);
|
|
134
|
+
const createDialog = useCallback((config) => {
|
|
144
135
|
return new Promise((resolve) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
136
|
+
const key = `dialog-${Date.now()}-${Math.random()}`;
|
|
137
|
+
const destroy = () => {
|
|
138
|
+
setElements((prev) => prev.filter((el) => el.key !== key));
|
|
139
|
+
};
|
|
140
|
+
const onInternalOk = (e, data) => __async(void 0, null, function* () {
|
|
141
|
+
var _a;
|
|
142
|
+
yield (_a = config.onOk) == null ? void 0 : _a.call(config, e, data);
|
|
143
|
+
if (config.type === "prompt")
|
|
144
|
+
resolve(data.value);
|
|
145
|
+
else
|
|
146
|
+
resolve(true);
|
|
147
|
+
destroy();
|
|
148
|
+
});
|
|
149
|
+
const onInternalCancel = (e) => __async(void 0, null, function* () {
|
|
150
|
+
var _a;
|
|
151
|
+
yield (_a = config.onCancel) == null ? void 0 : _a.call(config, e);
|
|
152
|
+
if (config.type === "prompt")
|
|
153
|
+
resolve(null);
|
|
154
|
+
else
|
|
155
155
|
resolve(false);
|
|
156
|
+
destroy();
|
|
157
|
+
});
|
|
158
|
+
const dialogElement = /* @__PURE__ */ React.createElement(
|
|
159
|
+
Dialog,
|
|
160
|
+
__spreadProps(__spreadValues({
|
|
161
|
+
key
|
|
162
|
+
}, config), {
|
|
163
|
+
open: true,
|
|
164
|
+
onOk: onInternalOk,
|
|
165
|
+
onCancel: onInternalCancel
|
|
156
166
|
})
|
|
157
|
-
|
|
167
|
+
);
|
|
168
|
+
setElements((prev) => [...prev, dialogElement]);
|
|
158
169
|
});
|
|
159
|
-
};
|
|
160
|
-
wrapAPI
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
}, []);
|
|
171
|
+
const wrapAPI = {};
|
|
172
|
+
wrapAPI.confirm = useCallback(
|
|
173
|
+
(options) => {
|
|
174
|
+
return createDialog(__spreadValues({
|
|
175
|
+
type: "confirm"
|
|
176
|
+
}, formatProps(options)));
|
|
177
|
+
},
|
|
178
|
+
[createDialog]
|
|
179
|
+
);
|
|
180
|
+
wrapAPI.prompt = useCallback(
|
|
181
|
+
(options) => {
|
|
182
|
+
return createDialog(__spreadValues({
|
|
183
|
+
type: "prompt"
|
|
184
|
+
}, formatProps(options)));
|
|
185
|
+
},
|
|
186
|
+
[createDialog]
|
|
187
|
+
);
|
|
188
|
+
wrapAPI.alert = useCallback(
|
|
189
|
+
(options) => {
|
|
190
|
+
return createDialog(__spreadValues({
|
|
191
|
+
type: "alert"
|
|
192
|
+
}, formatProps(options)));
|
|
193
|
+
},
|
|
194
|
+
[createDialog]
|
|
195
|
+
);
|
|
196
|
+
const contextHolder = /* @__PURE__ */ React.createElement(React.Fragment, null, elements);
|
|
197
|
+
return [wrapAPI, contextHolder];
|
|
177
198
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
199
|
+
FunctionalDialog.confirm = confirm;
|
|
200
|
+
FunctionalDialog.prompt = prompt;
|
|
201
|
+
FunctionalDialog.alert = alert;
|
|
202
|
+
FunctionalDialog.useDialog = useDialog;
|
|
203
|
+
var FunctionalDialog_default = FunctionalDialog;
|
|
182
204
|
export {
|
|
183
205
|
FunctionalDialog_default as default
|
|
184
206
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 自定义 Dialog 组件 Demo 集合
|
|
4
|
+
* 这个文件包含多个测试 demo,展示如何使用 getCustomDemoCodesFromFile 进行无障碍测试
|
|
5
|
+
* 文件名必须是 A11yDemos.tsx(固定约定)
|
|
6
|
+
*/
|
|
7
|
+
export declare const basicDialogDemo: () => React.JSX.Element;
|
|
8
|
+
export declare const promptDialogDemo: () => React.JSX.Element;
|
|
9
|
+
export declare const alertDialogDemo: () => React.JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dialog from "../../Dialog";
|
|
3
|
+
const basicDialogDemo = () => {
|
|
4
|
+
return /* @__PURE__ */ React.createElement(
|
|
5
|
+
Dialog,
|
|
6
|
+
{
|
|
7
|
+
open: true,
|
|
8
|
+
disablePortal: true,
|
|
9
|
+
title: "\u57FA\u7840\u5BF9\u8BDD\u6846",
|
|
10
|
+
content: "\u8FD9\u662F\u4E00\u4E2A\u57FA\u7840\u7684 Dialog \u7EC4\u4EF6\u793A\u4F8B"
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
const promptDialogDemo = () => {
|
|
15
|
+
return /* @__PURE__ */ React.createElement(
|
|
16
|
+
Dialog,
|
|
17
|
+
{
|
|
18
|
+
open: true,
|
|
19
|
+
disablePortal: true,
|
|
20
|
+
type: "prompt",
|
|
21
|
+
title: "\u8F93\u5165\u5BF9\u8BDD\u6846",
|
|
22
|
+
content: "\u8BF7\u8F93\u5165\u60A8\u7684\u59D3\u540D\uFF1A",
|
|
23
|
+
placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D"
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const alertDialogDemo = () => {
|
|
28
|
+
return /* @__PURE__ */ React.createElement(
|
|
29
|
+
Dialog,
|
|
30
|
+
{
|
|
31
|
+
open: true,
|
|
32
|
+
disablePortal: true,
|
|
33
|
+
title: "\u8B66\u544A",
|
|
34
|
+
content: "\u8FD9\u662F\u4E00\u4E2A\u8B66\u544A\u5BF9\u8BDD\u6846\uFF0C\u8BF7\u6CE8\u610F\uFF01",
|
|
35
|
+
type: "alert"
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
alertDialogDemo,
|
|
41
|
+
basicDialogDemo,
|
|
42
|
+
promptDialogDemo
|
|
43
|
+
};
|