react-native-system-ui 0.0.4 → 0.0.6
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/cjs/components/action-sheet/ActionSheet.js +28 -22
- package/dist/cjs/components/area/Area.js +72 -6
- package/dist/cjs/components/area/tokens.js +11 -0
- package/dist/cjs/components/avatar/Avatar.js +42 -10
- package/dist/cjs/components/badge/Badge.js +10 -10
- package/dist/cjs/components/badge/tokens.js +4 -0
- package/dist/cjs/components/button/Button.js +16 -65
- package/dist/cjs/components/button/ButtonContext.js +7 -10
- package/dist/cjs/components/button/ButtonGroup.js +13 -15
- package/dist/cjs/components/button/tokens.js +1 -5
- package/dist/cjs/components/calendar/Calendar.js +23 -12
- package/dist/cjs/components/cascader/Cascader.js +18 -13
- package/dist/cjs/components/cell/Cell.js +3 -3
- package/dist/cjs/components/cell/CellGroup.js +26 -21
- package/dist/cjs/components/checkbox/Checkbox.js +5 -4
- package/dist/cjs/components/checkbox/CheckboxContext.js +7 -10
- package/dist/cjs/components/checkbox/CheckboxGroup.js +24 -21
- package/dist/cjs/components/circle/Circle.js +6 -6
- package/dist/cjs/components/collapse/Collapse.js +10 -10
- package/dist/cjs/components/config-provider/locale/en-US.js +66 -4
- package/dist/cjs/components/config-provider/locale/zh-CN.js +74 -2
- package/dist/cjs/components/config-provider/tokens.js +11 -0
- package/dist/cjs/components/count-down/CountDown.js +6 -6
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +6 -6
- package/dist/cjs/components/datetime-picker/tokens.js +11 -0
- package/dist/cjs/components/dialog/Dialog.js +39 -34
- package/dist/cjs/components/dialog/tokens.js +1 -4
- package/dist/cjs/components/divider/Divider.js +36 -1
- package/dist/cjs/components/field/Field.js +303 -201
- package/dist/cjs/components/flex/Flex.js +7 -3
- package/dist/cjs/components/flex/FlexContext.js +7 -14
- package/dist/cjs/components/form/Form.js +112 -122
- package/dist/cjs/components/form/FormContext.js +7 -10
- package/dist/cjs/components/form/FormItem.js +30 -4
- package/dist/cjs/components/form/FormList.js +16 -3
- package/dist/cjs/components/form/tokens.js +11 -0
- package/dist/cjs/components/form/utils.js +2 -1
- package/dist/cjs/components/grid/Grid.js +45 -31
- package/dist/cjs/components/grid/GridContext.js +7 -10
- package/dist/cjs/components/grid/GridItem.js +22 -22
- package/dist/cjs/components/image/Image.js +17 -13
- package/dist/cjs/components/image-preview/ImagePreview.js +43 -41
- package/dist/cjs/components/index.js +43 -141
- package/dist/cjs/components/input/Input.js +19 -5
- package/dist/cjs/components/loading/Loading.js +10 -139
- package/dist/cjs/components/loading/tokens.js +0 -24
- package/dist/cjs/components/notice-bar/NoticeBar.js +45 -41
- package/dist/cjs/components/notify/Notify.js +72 -30
- package/dist/cjs/components/notify/imperative.js +2 -2
- package/dist/cjs/components/notify/tokens.js +11 -1
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +6 -6
- package/dist/cjs/components/overlay/Overlay.js +70 -77
- package/dist/cjs/components/overlay/index.js +13 -27
- package/dist/cjs/components/overlay/tokens.js +4 -31
- package/dist/cjs/components/password-input/PasswordInput.js +2 -41
- package/dist/cjs/components/password-input/tokens.js +53 -0
- package/dist/cjs/components/picker/Picker.js +618 -38
- package/dist/cjs/components/popup/Popup.js +60 -47
- package/dist/cjs/components/portal/Portal.js +39 -31
- package/dist/cjs/components/portal/PortalHost.js +258 -213
- package/dist/cjs/components/portal/tokens.js +11 -0
- package/dist/cjs/components/progress/Progress.js +77 -36
- package/dist/cjs/components/progress/index.js +6 -0
- package/dist/cjs/components/radio/Radio.js +35 -12
- package/dist/cjs/components/radio/RadioContext.js +7 -10
- package/dist/cjs/components/radio/RadioGroup.js +23 -20
- package/dist/cjs/components/safe-area-view/tokens.js +11 -0
- package/dist/cjs/components/search/Search.js +16 -16
- package/dist/cjs/components/selector/Selector.js +6 -6
- package/dist/cjs/components/share-sheet/ShareSheet.js +50 -46
- package/dist/cjs/components/sidebar/Sidebar.js +27 -22
- package/dist/cjs/components/sidebar/SidebarItem.js +27 -22
- package/dist/cjs/components/skeleton/Skeleton.js +34 -21
- package/dist/cjs/components/slider/Slider.js +135 -78
- package/dist/cjs/components/stepper/Stepper.js +12 -10
- package/dist/cjs/components/swiper/Swiper.js +247 -710
- package/dist/cjs/components/swiper/SwiperItem.js +5 -33
- package/dist/cjs/components/swiper/tokens.js +11 -0
- package/dist/cjs/components/switch/Switch.js +46 -98
- package/dist/cjs/components/switch/tokens.js +1 -55
- package/dist/cjs/components/tabbar/Tabbar.js +26 -22
- package/dist/cjs/components/tabbar/TabbarItem.js +23 -22
- package/dist/cjs/components/tabbar/tokens.js +0 -2
- package/dist/cjs/components/tabs/Tabs.js +268 -94
- package/dist/cjs/components/tabs/index.js +4 -5
- package/dist/cjs/components/toast/Toast.js +72 -27
- package/dist/cjs/components/toast/imperative.js +2 -2
- package/dist/cjs/hooks/gesture/useGestureScroll.js +1 -2
- package/dist/cjs/hooks/index.js +12 -12
- package/dist/cjs/hooks/overlay/index.js +27 -0
- package/dist/cjs/hooks/useHairline.js +0 -4
- package/dist/cjs/platform/scrollLock.js +1 -1
- package/dist/cjs/utils/compare.js +26 -0
- package/dist/cjs/utils/index.js +11 -0
- package/dist/es/components/action-sheet/ActionSheet.js +29 -23
- package/dist/es/components/area/Area.js +73 -7
- package/dist/es/components/area/tokens.js +5 -0
- package/dist/es/components/avatar/Avatar.js +42 -10
- package/dist/es/components/badge/Badge.js +11 -11
- package/dist/es/components/badge/tokens.js +4 -0
- package/dist/es/components/button/Button.js +17 -65
- package/dist/es/components/button/ButtonContext.js +1 -2
- package/dist/es/components/button/ButtonGroup.js +10 -12
- package/dist/es/components/button/tokens.js +1 -5
- package/dist/es/components/calendar/Calendar.js +24 -13
- package/dist/es/components/cascader/Cascader.js +16 -11
- package/dist/es/components/cell/Cell.js +4 -4
- package/dist/es/components/cell/CellGroup.js +25 -20
- package/dist/es/components/checkbox/Checkbox.js +5 -4
- package/dist/es/components/checkbox/CheckboxContext.js +1 -2
- package/dist/es/components/checkbox/CheckboxGroup.js +24 -21
- package/dist/es/components/circle/Circle.js +7 -7
- package/dist/es/components/collapse/Collapse.js +11 -11
- package/dist/es/components/config-provider/locale/en-US.js +66 -4
- package/dist/es/components/config-provider/locale/zh-CN.js +74 -2
- package/dist/es/components/config-provider/tokens.js +5 -0
- package/dist/es/components/count-down/CountDown.js +7 -7
- package/dist/es/components/datetime-picker/DatetimePicker.js +7 -7
- package/dist/es/components/datetime-picker/tokens.js +5 -0
- package/dist/es/components/dialog/Dialog.js +40 -35
- package/dist/es/components/dialog/tokens.js +1 -4
- package/dist/es/components/divider/Divider.js +36 -1
- package/dist/es/components/field/Field.js +304 -202
- package/dist/es/components/flex/Flex.js +5 -1
- package/dist/es/components/flex/FlexContext.js +1 -6
- package/dist/es/components/form/Form.js +89 -99
- package/dist/es/components/form/FormContext.js +1 -2
- package/dist/es/components/form/FormItem.js +32 -6
- package/dist/es/components/form/FormList.js +18 -5
- package/dist/es/components/form/tokens.js +5 -0
- package/dist/es/components/form/utils.js +1 -0
- package/dist/es/components/grid/Grid.js +43 -29
- package/dist/es/components/grid/GridContext.js +1 -2
- package/dist/es/components/grid/GridItem.js +24 -24
- package/dist/es/components/image/Image.js +18 -14
- package/dist/es/components/image-preview/ImagePreview.js +44 -42
- package/dist/es/components/index.js +2 -17
- package/dist/es/components/input/Input.js +20 -6
- package/dist/es/components/loading/Loading.js +10 -139
- package/dist/es/components/loading/tokens.js +0 -24
- package/dist/es/components/notice-bar/NoticeBar.js +46 -42
- package/dist/es/components/notify/Notify.js +72 -30
- package/dist/es/components/notify/imperative.js +2 -2
- package/dist/es/components/notify/tokens.js +5 -1
- package/dist/es/components/number-keyboard/NumberKeyboard.js +7 -7
- package/dist/es/components/overlay/Overlay.js +58 -75
- package/dist/es/components/overlay/index.js +3 -4
- package/dist/es/components/overlay/tokens.js +3 -29
- package/dist/es/components/password-input/PasswordInput.js +1 -40
- package/dist/es/components/password-input/tokens.js +41 -0
- package/dist/es/components/picker/Picker.js +610 -34
- package/dist/es/components/popup/Popup.js +62 -49
- package/dist/es/components/portal/Portal.js +37 -31
- package/dist/es/components/portal/PortalHost.js +257 -211
- package/dist/es/components/portal/tokens.js +5 -0
- package/dist/es/components/progress/Progress.js +76 -36
- package/dist/es/components/progress/index.js +2 -1
- package/dist/es/components/radio/Radio.js +37 -14
- package/dist/es/components/radio/RadioContext.js +1 -2
- package/dist/es/components/radio/RadioGroup.js +23 -20
- package/dist/es/components/safe-area-view/tokens.js +5 -0
- package/dist/es/components/search/Search.js +17 -17
- package/dist/es/components/selector/Selector.js +7 -7
- package/dist/es/components/share-sheet/ShareSheet.js +51 -47
- package/dist/es/components/sidebar/Sidebar.js +26 -21
- package/dist/es/components/sidebar/SidebarItem.js +26 -22
- package/dist/es/components/skeleton/Skeleton.js +35 -22
- package/dist/es/components/slider/Slider.js +132 -75
- package/dist/es/components/stepper/Stepper.js +13 -11
- package/dist/es/components/swiper/Swiper.js +248 -711
- package/dist/es/components/swiper/SwiperItem.js +1 -21
- package/dist/es/components/swiper/tokens.js +5 -0
- package/dist/es/components/switch/Switch.js +49 -101
- package/dist/es/components/switch/tokens.js +1 -49
- package/dist/es/components/tabbar/Tabbar.js +27 -23
- package/dist/es/components/tabbar/TabbarItem.js +22 -22
- package/dist/es/components/tabbar/tokens.js +0 -2
- package/dist/es/components/tabs/Tabs.js +264 -90
- package/dist/es/components/tabs/index.js +1 -2
- package/dist/es/components/toast/Toast.js +72 -28
- package/dist/es/components/toast/imperative.js +2 -2
- package/dist/es/hooks/gesture/useGestureScroll.js +1 -2
- package/dist/es/hooks/index.js +1 -1
- package/dist/es/hooks/overlay/index.js +3 -0
- package/dist/es/hooks/useHairline.js +0 -4
- package/dist/es/platform/scrollLock.js +1 -1
- package/dist/es/utils/compare.js +18 -0
- package/dist/es/utils/index.js +1 -1
- package/dist/types/components/area/tokens.d.ts +3 -0
- package/dist/types/components/avatar/Avatar.d.ts +4 -2
- package/dist/types/components/button/ButtonContext.d.ts +2 -16
- package/dist/types/components/button/ButtonGroup.d.ts +14 -1
- package/dist/types/components/button/index.d.ts +1 -1
- package/dist/types/components/checkbox/CheckboxContext.d.ts +2 -16
- package/dist/types/components/checkbox/CheckboxGroup.d.ts +15 -1
- package/dist/types/components/collapse/Collapse.d.ts +0 -1
- package/dist/types/components/config-provider/LocaleContext.d.ts +2 -74
- package/dist/types/components/config-provider/tokens.d.ts +3 -0
- package/dist/types/components/config-provider/useLocale.d.ts +1 -74
- package/dist/types/components/datetime-picker/tokens.d.ts +3 -0
- package/dist/types/components/flex/Flex.d.ts +6 -0
- package/dist/types/components/flex/FlexContext.d.ts +2 -8
- package/dist/types/components/form/Form.d.ts +15 -1
- package/dist/types/components/form/FormContext.d.ts +2 -17
- package/dist/types/components/form/tokens.d.ts +3 -0
- package/dist/types/components/form/utils.d.ts +1 -0
- package/dist/types/components/grid/Grid.d.ts +16 -1
- package/dist/types/components/grid/GridContext.d.ts +2 -17
- package/dist/types/components/index.d.ts +3 -33
- package/dist/types/components/loading/index.d.ts +1 -1
- package/dist/types/components/notify/Notify.d.ts +1 -0
- package/dist/types/components/overlay/Overlay.d.ts +6 -1
- package/dist/types/components/overlay/index.d.ts +2 -3
- package/dist/types/components/overlay/tokens.d.ts +2 -3
- package/dist/types/components/password-input/PasswordInput.d.ts +0 -39
- package/dist/types/components/password-input/tokens.d.ts +40 -0
- package/dist/types/components/picker/Picker.d.ts +18 -2
- package/dist/types/components/picker/index.d.ts +1 -1
- package/dist/types/components/portal/Portal.d.ts +4 -6
- package/dist/types/components/portal/PortalHost.d.ts +1 -15
- package/dist/types/components/portal/tokens.d.ts +3 -0
- package/dist/types/components/progress/Progress.d.ts +4 -0
- package/dist/types/components/progress/index.d.ts +2 -1
- package/dist/types/components/radio/RadioContext.d.ts +2 -13
- package/dist/types/components/radio/RadioGroup.d.ts +12 -1
- package/dist/types/components/safe-area-view/tokens.d.ts +3 -0
- package/dist/types/components/swiper/Swiper.d.ts +4 -2
- package/dist/types/components/swiper/SwiperItem.d.ts +1 -5
- package/dist/types/components/swiper/tokens.d.ts +3 -0
- package/dist/types/components/tabs/Tabs.d.ts +8 -4
- package/dist/types/components/tabs/index.d.ts +3 -1
- package/dist/types/components/toast/Toast.d.ts +1 -4
- package/dist/types/hooks/aria/useAriaListBox.d.ts +0 -6
- package/dist/types/hooks/aria/useAriaOverlay.d.ts +0 -10
- package/dist/types/hooks/aria/useAriaPress.d.ts +0 -20
- package/dist/types/hooks/aria/useAriaToggle.d.ts +0 -3
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/hooks/overlay/index.d.ts +2 -0
- package/dist/types/hooks/useHairline.d.ts +0 -21
- package/dist/types/utils/compare.d.ts +2 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +10 -48
- package/dist/cjs/components/area/utils.js +0 -74
- package/dist/cjs/components/cascader/utils.js +0 -20
- package/dist/cjs/components/config-provider/locale/base.js +0 -80
- package/dist/cjs/components/dropdown-menu/DropdownItem.js +0 -288
- package/dist/cjs/components/dropdown-menu/DropdownMenu.js +0 -340
- package/dist/cjs/components/dropdown-menu/DropdownMenuContext.js +0 -21
- package/dist/cjs/components/dropdown-menu/index.js +0 -25
- package/dist/cjs/components/dropdown-menu/tokens.js +0 -67
- package/dist/cjs/components/field/utils.js +0 -24
- package/dist/cjs/components/index-bar/IndexAnchor.js +0 -74
- package/dist/cjs/components/index-bar/IndexBar.js +0 -436
- package/dist/cjs/components/index-bar/index.js +0 -25
- package/dist/cjs/components/index-bar/tokens.js +0 -45
- package/dist/cjs/components/list/List.js +0 -165
- package/dist/cjs/components/list/index.js +0 -9
- package/dist/cjs/components/list/tokens.js +0 -39
- package/dist/cjs/components/notify/defaults.js +0 -15
- package/dist/cjs/components/pagination/Pagination.js +0 -160
- package/dist/cjs/components/pagination/index.js +0 -22
- package/dist/cjs/components/pagination/tokens.js +0 -103
- package/dist/cjs/components/picker/WheelPicker.js +0 -492
- package/dist/cjs/components/picker/utils.js +0 -138
- package/dist/cjs/components/pull-refresh/PullRefresh.js +0 -378
- package/dist/cjs/components/pull-refresh/index.js +0 -16
- package/dist/cjs/components/pull-refresh/tokens.js +0 -22
- package/dist/cjs/components/rate/Rate.js +0 -269
- package/dist/cjs/components/rate/index.js +0 -15
- package/dist/cjs/components/rate/tokens.js +0 -60
- package/dist/cjs/components/slider/utils.js +0 -60
- package/dist/cjs/components/swiper/useSwiperWeb.js +0 -209
- package/dist/cjs/components/swiper/utils.js +0 -49
- package/dist/cjs/components/tabs/TabPane.js +0 -9
- package/dist/cjs/components/tabs/useTabsAnimation.js +0 -74
- package/dist/cjs/components/tabs/useTabsScroll.js +0 -133
- package/dist/cjs/components/tabs/utils.js +0 -34
- package/dist/cjs/components/types.js +0 -1
- package/dist/cjs/components/uploader/Uploader.js +0 -557
- package/dist/cjs/components/uploader/index.js +0 -22
- package/dist/cjs/components/uploader/tokens.js +0 -58
- package/dist/cjs/components/uploader/utils.js +0 -72
- package/dist/cjs/hooks/usePresenceAnimation.js +0 -70
- package/dist/es/components/area/utils.js +0 -67
- package/dist/es/components/cascader/utils.js +0 -13
- package/dist/es/components/config-provider/locale/base.js +0 -74
- package/dist/es/components/dropdown-menu/DropdownItem.js +0 -269
- package/dist/es/components/dropdown-menu/DropdownMenu.js +0 -320
- package/dist/es/components/dropdown-menu/DropdownMenuContext.js +0 -7
- package/dist/es/components/dropdown-menu/index.js +0 -7
- package/dist/es/components/dropdown-menu/tokens.js +0 -61
- package/dist/es/components/field/utils.js +0 -17
- package/dist/es/components/index-bar/IndexAnchor.js +0 -55
- package/dist/es/components/index-bar/IndexBar.js +0 -417
- package/dist/es/components/index-bar/index.js +0 -7
- package/dist/es/components/index-bar/tokens.js +0 -39
- package/dist/es/components/list/List.js +0 -145
- package/dist/es/components/list/index.js +0 -2
- package/dist/es/components/list/tokens.js +0 -32
- package/dist/es/components/notify/defaults.js +0 -9
- package/dist/es/components/pagination/Pagination.js +0 -141
- package/dist/es/components/pagination/index.js +0 -4
- package/dist/es/components/pagination/tokens.js +0 -91
- package/dist/es/components/picker/WheelPicker.js +0 -473
- package/dist/es/components/picker/utils.js +0 -127
- package/dist/es/components/pull-refresh/PullRefresh.js +0 -359
- package/dist/es/components/pull-refresh/index.js +0 -3
- package/dist/es/components/pull-refresh/tokens.js +0 -16
- package/dist/es/components/rate/Rate.js +0 -250
- package/dist/es/components/rate/index.js +0 -3
- package/dist/es/components/rate/tokens.js +0 -53
- package/dist/es/components/slider/utils.js +0 -49
- package/dist/es/components/swiper/useSwiperWeb.js +0 -190
- package/dist/es/components/swiper/utils.js +0 -37
- package/dist/es/components/tabs/TabPane.js +0 -3
- package/dist/es/components/tabs/useTabsAnimation.js +0 -55
- package/dist/es/components/tabs/useTabsScroll.js +0 -114
- package/dist/es/components/tabs/utils.js +0 -19
- package/dist/es/components/types.js +0 -1
- package/dist/es/components/uploader/Uploader.js +0 -537
- package/dist/es/components/uploader/index.js +0 -4
- package/dist/es/components/uploader/tokens.js +0 -52
- package/dist/es/components/uploader/utils.js +0 -60
- package/dist/es/hooks/usePresenceAnimation.js +0 -51
- package/dist/types/components/area/utils.d.ts +0 -2
- package/dist/types/components/cascader/utils.d.ts +0 -6
- package/dist/types/components/config-provider/locale/base.d.ts +0 -74
- package/dist/types/components/dropdown-menu/DropdownItem.d.ts +0 -4
- package/dist/types/components/dropdown-menu/DropdownMenu.d.ts +0 -4
- package/dist/types/components/dropdown-menu/DropdownMenuContext.d.ts +0 -17
- package/dist/types/components/dropdown-menu/index.d.ts +0 -8
- package/dist/types/components/dropdown-menu/tokens.d.ts +0 -52
- package/dist/types/components/field/utils.d.ts +0 -4
- package/dist/types/components/index-bar/IndexAnchor.d.ts +0 -4
- package/dist/types/components/index-bar/IndexBar.d.ts +0 -4
- package/dist/types/components/index-bar/index.d.ts +0 -9
- package/dist/types/components/index-bar/tokens.d.ts +0 -31
- package/dist/types/components/list/List.d.ts +0 -4
- package/dist/types/components/list/index.d.ts +0 -3
- package/dist/types/components/list/tokens.d.ts +0 -4
- package/dist/types/components/notify/defaults.d.ts +0 -10
- package/dist/types/components/pagination/Pagination.d.ts +0 -5
- package/dist/types/components/pagination/index.d.ts +0 -5
- package/dist/types/components/pagination/tokens.d.ts +0 -2
- package/dist/types/components/picker/WheelPicker.d.ts +0 -21
- package/dist/types/components/picker/utils.d.ts +0 -17
- package/dist/types/components/pull-refresh/PullRefresh.d.ts +0 -5
- package/dist/types/components/pull-refresh/index.d.ts +0 -4
- package/dist/types/components/pull-refresh/tokens.d.ts +0 -10
- package/dist/types/components/rate/Rate.d.ts +0 -4
- package/dist/types/components/rate/index.d.ts +0 -4
- package/dist/types/components/rate/tokens.d.ts +0 -4
- package/dist/types/components/slider/utils.d.ts +0 -42
- package/dist/types/components/swiper/useSwiperWeb.d.ts +0 -41
- package/dist/types/components/swiper/utils.d.ts +0 -17
- package/dist/types/components/tabs/TabPane.d.ts +0 -4
- package/dist/types/components/tabs/useTabsAnimation.d.ts +0 -30
- package/dist/types/components/tabs/useTabsScroll.d.ts +0 -23
- package/dist/types/components/tabs/utils.d.ts +0 -5
- package/dist/types/components/types.d.ts +0 -59
- package/dist/types/components/uploader/Uploader.d.ts +0 -4
- package/dist/types/components/uploader/index.d.ts +0 -5
- package/dist/types/components/uploader/tokens.d.ts +0 -42
- package/dist/types/components/uploader/utils.d.ts +0 -11
- package/dist/types/hooks/usePresenceAnimation.d.ts +0 -20
- /package/dist/cjs/{components → hooks}/overlay/OverlayStackStore.js +0 -0
- /package/dist/cjs/{components → hooks}/overlay/useOverlayStack.js +0 -0
- /package/dist/es/{components → hooks}/overlay/OverlayStackStore.js +0 -0
- /package/dist/es/{components → hooks}/overlay/useOverlayStack.js +0 -0
- /package/dist/types/{components → hooks}/overlay/OverlayStackStore.d.ts +0 -0
- /package/dist/types/{components → hooks}/overlay/useOverlayStack.d.ts +0 -0
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
function _react() {
|
|
8
|
-
const data = _interopRequireWildcard(require("react"));
|
|
9
|
-
_react = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _reactNative() {
|
|
15
|
-
const data = require("react-native");
|
|
16
|
-
_reactNative = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
var _platform = require("../../platform");
|
|
22
|
-
var _number = require("../../utils/number");
|
|
23
|
-
var _validate = require("../../utils/validate");
|
|
24
|
-
var _useLocale = require("../config-provider/useLocale");
|
|
25
|
-
var _tokens = require("./tokens");
|
|
26
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
27
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
28
|
-
const DEFAULT_SUCCESS_DURATION = 500;
|
|
29
|
-
const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
|
|
30
|
-
const {
|
|
31
|
-
children,
|
|
32
|
-
onRefresh,
|
|
33
|
-
onRefreshEnd,
|
|
34
|
-
refreshing,
|
|
35
|
-
defaultRefreshing,
|
|
36
|
-
tokensOverride,
|
|
37
|
-
pullingText,
|
|
38
|
-
loosingText,
|
|
39
|
-
loadingText,
|
|
40
|
-
successText = '刷新成功',
|
|
41
|
-
successDuration,
|
|
42
|
-
animationDuration,
|
|
43
|
-
headHeight,
|
|
44
|
-
pullDistance,
|
|
45
|
-
disabled = false,
|
|
46
|
-
style,
|
|
47
|
-
...scrollProps
|
|
48
|
-
} = props;
|
|
49
|
-
const isWeb = _reactNative().Platform.OS === 'web';
|
|
50
|
-
const locale = (0, _useLocale.useLocale)();
|
|
51
|
-
const tokens = (0, _tokens.usePullRefreshTokens)(tokensOverride);
|
|
52
|
-
const {
|
|
53
|
-
colors,
|
|
54
|
-
sizing
|
|
55
|
-
} = tokens;
|
|
56
|
-
const translateY = (0, _react().useRef)(new (_reactNative().Animated.Value)(0)).current;
|
|
57
|
-
const headHeightNumber = Math.max(0, (0, _number.parseNumberLike)(headHeight, sizing.headHeight) ?? sizing.headHeight);
|
|
58
|
-
const pullDistanceNumber = Math.max(0, (0, _number.parseNumberLike)(pullDistance, headHeightNumber) ?? headHeightNumber);
|
|
59
|
-
const successDurationMs = Math.max(0, (0, _number.parseNumberLike)(successDuration, DEFAULT_SUCCESS_DURATION) ?? DEFAULT_SUCCESS_DURATION);
|
|
60
|
-
const animationDurationMs = Math.max(0, (0, _number.parseNumberLike)(animationDuration, 300) ?? 300);
|
|
61
|
-
const isControlled = !(0, _validate.isUndefined)(refreshing);
|
|
62
|
-
const [innerRefreshing, setInnerRefreshing] = (0, _react().useState)(!!defaultRefreshing);
|
|
63
|
-
const mergedRefreshing = isControlled ? !!refreshing : innerRefreshing;
|
|
64
|
-
const scrollTopRef = (0, _react().useRef)(0);
|
|
65
|
-
const draggingRef = (0, _react().useRef)(false);
|
|
66
|
-
const webDragRafRef = (0, _react().useRef)(null);
|
|
67
|
-
const webDragPendingRef = (0, _react().useRef)(null);
|
|
68
|
-
const webStateUpdateAtRef = (0, _react().useRef)(0);
|
|
69
|
-
const webStateUpdateValueRef = (0, _react().useRef)(0);
|
|
70
|
-
const [distance, setDistance] = (0, _react().useState)(0);
|
|
71
|
-
const [showSuccess, setShowSuccess] = (0, _react().useState)(false);
|
|
72
|
-
const timerRef = (0, _react().useRef)(null);
|
|
73
|
-
const refreshEndTimerRef = (0, _react().useRef)(null);
|
|
74
|
-
const mergedRefreshingRef = (0, _react().useRef)(mergedRefreshing);
|
|
75
|
-
const refreshTriggeredRef = (0, _react().useRef)(false);
|
|
76
|
-
const refreshSucceededRef = (0, _react().useRef)(false);
|
|
77
|
-
const normalizeDistance = (0, _react().useCallback)(nextDistance => Math.max(0, Math.round(nextDistance)), []);
|
|
78
|
-
const updateDistanceState = (0, _react().useCallback)(normalized => {
|
|
79
|
-
setDistance(prev => Math.abs(prev - normalized) < 1 ? prev : normalized);
|
|
80
|
-
}, []);
|
|
81
|
-
const applyWebTranslate = (0, _react().useCallback)((normalized, animate = false) => {
|
|
82
|
-
translateY.stopAnimation();
|
|
83
|
-
if (animate && animationDurationMs > 0) {
|
|
84
|
-
_reactNative().Animated.timing(translateY, {
|
|
85
|
-
toValue: normalized,
|
|
86
|
-
duration: animationDurationMs,
|
|
87
|
-
useNativeDriver: false
|
|
88
|
-
}).start();
|
|
89
|
-
} else {
|
|
90
|
-
translateY.setValue(normalized);
|
|
91
|
-
}
|
|
92
|
-
}, [animationDurationMs, translateY]);
|
|
93
|
-
const setDistanceValue = (0, _react().useCallback)((nextDistance, animate = false) => {
|
|
94
|
-
const normalized = normalizeDistance(nextDistance);
|
|
95
|
-
if (isWeb) {
|
|
96
|
-
applyWebTranslate(normalized, animate);
|
|
97
|
-
}
|
|
98
|
-
updateDistanceState(normalized);
|
|
99
|
-
return normalized;
|
|
100
|
-
}, [applyWebTranslate, isWeb, normalizeDistance, updateDistanceState]);
|
|
101
|
-
const flushWebDrag = (0, _react().useCallback)(() => {
|
|
102
|
-
const pending = webDragPendingRef.current;
|
|
103
|
-
if (pending == null) return;
|
|
104
|
-
webDragPendingRef.current = null;
|
|
105
|
-
const normalized = normalizeDistance(pending);
|
|
106
|
-
if (isWeb) {
|
|
107
|
-
applyWebTranslate(normalized);
|
|
108
|
-
}
|
|
109
|
-
const now = Date.now();
|
|
110
|
-
if (now - webStateUpdateAtRef.current >= 32 || Math.abs(normalized - webStateUpdateValueRef.current) >= 4) {
|
|
111
|
-
webStateUpdateAtRef.current = now;
|
|
112
|
-
webStateUpdateValueRef.current = normalized;
|
|
113
|
-
updateDistanceState(normalized);
|
|
114
|
-
}
|
|
115
|
-
}, [applyWebTranslate, isWeb, normalizeDistance, updateDistanceState]);
|
|
116
|
-
const cancelWebDrag = (0, _react().useCallback)(() => {
|
|
117
|
-
if (webDragRafRef.current != null && typeof cancelAnimationFrame === 'function') {
|
|
118
|
-
cancelAnimationFrame(webDragRafRef.current);
|
|
119
|
-
}
|
|
120
|
-
webDragRafRef.current = null;
|
|
121
|
-
webDragPendingRef.current = null;
|
|
122
|
-
}, []);
|
|
123
|
-
const scheduleWebDrag = (0, _react().useCallback)(nextDistance => {
|
|
124
|
-
if (!isWeb || typeof requestAnimationFrame !== 'function') {
|
|
125
|
-
setDistanceValue(nextDistance);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
webDragPendingRef.current = nextDistance;
|
|
129
|
-
if (webDragRafRef.current != null) return;
|
|
130
|
-
webDragRafRef.current = requestAnimationFrame(() => {
|
|
131
|
-
webDragRafRef.current = null;
|
|
132
|
-
flushWebDrag();
|
|
133
|
-
});
|
|
134
|
-
}, [flushWebDrag, isWeb, setDistanceValue]);
|
|
135
|
-
(0, _react().useEffect)(() => {
|
|
136
|
-
return () => {
|
|
137
|
-
if (timerRef.current) {
|
|
138
|
-
clearTimeout(timerRef.current);
|
|
139
|
-
}
|
|
140
|
-
if (refreshEndTimerRef.current) {
|
|
141
|
-
clearTimeout(refreshEndTimerRef.current);
|
|
142
|
-
}
|
|
143
|
-
cancelWebDrag();
|
|
144
|
-
};
|
|
145
|
-
}, [cancelWebDrag]);
|
|
146
|
-
const setRefreshing = (0, _react().useCallback)(value => {
|
|
147
|
-
if (!isControlled) setInnerRefreshing(value);
|
|
148
|
-
}, [isControlled]);
|
|
149
|
-
(0, _react().useEffect)(() => {
|
|
150
|
-
mergedRefreshingRef.current = mergedRefreshing;
|
|
151
|
-
}, [mergedRefreshing]);
|
|
152
|
-
const resolveStatusText = (0, _react().useCallback)((text, fallback) => {
|
|
153
|
-
const resolved = (0, _validate.isUndefined)(text) ? fallback : text;
|
|
154
|
-
return (0, _validate.isFunction)(resolved) ? resolved({
|
|
155
|
-
distance
|
|
156
|
-
}) : resolved;
|
|
157
|
-
}, [distance]);
|
|
158
|
-
const triggerSuccess = (0, _react().useCallback)(() => {
|
|
159
|
-
if (successText === null || successText === undefined || successText === false) return;
|
|
160
|
-
if (successDurationMs <= 0) return;
|
|
161
|
-
setShowSuccess(true);
|
|
162
|
-
if (timerRef.current) {
|
|
163
|
-
clearTimeout(timerRef.current);
|
|
164
|
-
}
|
|
165
|
-
timerRef.current = setTimeout(() => {
|
|
166
|
-
setShowSuccess(false);
|
|
167
|
-
}, successDurationMs);
|
|
168
|
-
}, [successDurationMs, successText]);
|
|
169
|
-
const handleRefresh = (0, _react().useCallback)(async () => {
|
|
170
|
-
if (disabled || mergedRefreshing) return;
|
|
171
|
-
if (!(0, _validate.isFunction)(onRefresh)) return;
|
|
172
|
-
setShowSuccess(false);
|
|
173
|
-
refreshTriggeredRef.current = true;
|
|
174
|
-
refreshSucceededRef.current = false;
|
|
175
|
-
setRefreshing(true);
|
|
176
|
-
try {
|
|
177
|
-
await onRefresh();
|
|
178
|
-
refreshSucceededRef.current = true;
|
|
179
|
-
} finally {
|
|
180
|
-
setRefreshing(false);
|
|
181
|
-
if ((0, _validate.isFunction)(onRefreshEnd)) {
|
|
182
|
-
if (refreshEndTimerRef.current) {
|
|
183
|
-
clearTimeout(refreshEndTimerRef.current);
|
|
184
|
-
}
|
|
185
|
-
refreshEndTimerRef.current = setTimeout(onRefreshEnd, 0);
|
|
186
|
-
}
|
|
187
|
-
if (refreshTriggeredRef.current && refreshSucceededRef.current && !mergedRefreshingRef.current) {
|
|
188
|
-
triggerSuccess();
|
|
189
|
-
refreshTriggeredRef.current = false;
|
|
190
|
-
refreshSucceededRef.current = false;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}, [disabled, mergedRefreshing, onRefresh, onRefreshEnd, setRefreshing, triggerSuccess]);
|
|
194
|
-
(0, _react().useEffect)(() => {
|
|
195
|
-
if (!isWeb) return;
|
|
196
|
-
if (draggingRef.current) return;
|
|
197
|
-
if (disabled) {
|
|
198
|
-
setDistanceValue(0, true);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (mergedRefreshing || showSuccess) {
|
|
202
|
-
setDistanceValue(headHeightNumber, true);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
setDistanceValue(0, true);
|
|
206
|
-
}, [disabled, headHeightNumber, isWeb, mergedRefreshing, setDistanceValue, showSuccess]);
|
|
207
|
-
(0, _react().useEffect)(() => {
|
|
208
|
-
if (isWeb) return;
|
|
209
|
-
if (!mergedRefreshing && !showSuccess) return;
|
|
210
|
-
setDistanceValue(0);
|
|
211
|
-
}, [isWeb, mergedRefreshing, setDistanceValue, showSuccess]);
|
|
212
|
-
(0, _react().useEffect)(() => {
|
|
213
|
-
if (!refreshTriggeredRef.current) return;
|
|
214
|
-
if (mergedRefreshing) return;
|
|
215
|
-
if (!refreshSucceededRef.current) {
|
|
216
|
-
refreshTriggeredRef.current = false;
|
|
217
|
-
refreshSucceededRef.current = false;
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (showSuccess) {
|
|
221
|
-
refreshTriggeredRef.current = false;
|
|
222
|
-
refreshSucceededRef.current = false;
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
triggerSuccess();
|
|
226
|
-
refreshTriggeredRef.current = false;
|
|
227
|
-
refreshSucceededRef.current = false;
|
|
228
|
-
}, [mergedRefreshing, showSuccess, triggerSuccess]);
|
|
229
|
-
const status = mergedRefreshing ? 'loading' : showSuccess ? 'success' : disabled || distance === 0 ? 'normal' : distance < pullDistanceNumber ? 'pulling' : 'loosing';
|
|
230
|
-
const opacity = (0, _react().useRef)(new (_reactNative().Animated.Value)(status === 'normal' ? 0 : 1)).current;
|
|
231
|
-
(0, _react().useEffect)(() => {
|
|
232
|
-
const toValue = status === 'normal' ? 0 : 1;
|
|
233
|
-
opacity.stopAnimation();
|
|
234
|
-
if (animationDurationMs <= 0) {
|
|
235
|
-
opacity.setValue(toValue);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
_reactNative().Animated.timing(opacity, {
|
|
239
|
-
toValue,
|
|
240
|
-
duration: animationDurationMs,
|
|
241
|
-
useNativeDriver: _platform.nativeDriverEnabled
|
|
242
|
-
}).start();
|
|
243
|
-
}, [animationDurationMs, opacity, status]);
|
|
244
|
-
const statusNode = (() => {
|
|
245
|
-
switch (status) {
|
|
246
|
-
case 'pulling':
|
|
247
|
-
return resolveStatusText(pullingText, locale.vanPullRefresh.pulling);
|
|
248
|
-
case 'loosing':
|
|
249
|
-
return resolveStatusText(loosingText, locale.vanPullRefresh.loosing);
|
|
250
|
-
case 'loading':
|
|
251
|
-
return resolveStatusText(loadingText, locale.vanPullRefresh.loading);
|
|
252
|
-
case 'success':
|
|
253
|
-
return resolveStatusText(successText, '刷新成功');
|
|
254
|
-
default:
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
})();
|
|
258
|
-
const shouldReserveHead = (status === 'loading' || status === 'success') && distance === 0;
|
|
259
|
-
const flattenedContainerStyle = _reactNative().StyleSheet.flatten(scrollProps.contentContainerStyle);
|
|
260
|
-
const basePaddingTop = (0, _validate.isNumber)(flattenedContainerStyle?.paddingTop) ? flattenedContainerStyle.paddingTop : 0;
|
|
261
|
-
const contentContainerStyle = shouldReserveHead ? [scrollProps.contentContainerStyle, {
|
|
262
|
-
paddingTop: basePaddingTop + headHeightNumber
|
|
263
|
-
}] : scrollProps.contentContainerStyle;
|
|
264
|
-
const onScrollProp = scrollProps.onScroll;
|
|
265
|
-
const handleScroll = (0, _react().useCallback)(event => {
|
|
266
|
-
onScrollProp?.(event);
|
|
267
|
-
const offset = event.nativeEvent.contentOffset?.y ?? 0;
|
|
268
|
-
if (isWeb) {
|
|
269
|
-
scrollTopRef.current = Math.max(0, offset);
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
if (disabled) return;
|
|
273
|
-
if (!(0, _validate.isFunction)(onRefresh) || mergedRefreshing || showSuccess) {
|
|
274
|
-
setDistanceValue(0);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
setDistanceValue(offset < 0 ? -offset : 0);
|
|
278
|
-
}, [disabled, isWeb, mergedRefreshing, onRefresh, onScrollProp, setDistanceValue, showSuccess]);
|
|
279
|
-
const panResponder = (() => {
|
|
280
|
-
if (!isWeb || !(0, _validate.isFunction)(onRefresh)) return null;
|
|
281
|
-
const easeDistance = raw => {
|
|
282
|
-
const pullDistance = pullDistanceNumber;
|
|
283
|
-
let eased = raw;
|
|
284
|
-
if (eased > pullDistance) {
|
|
285
|
-
eased = eased < pullDistance * 2 ? pullDistance + (eased - pullDistance) / 2 : pullDistance * 1.5 + (eased - pullDistance * 2) / 4;
|
|
286
|
-
}
|
|
287
|
-
return Math.round(eased);
|
|
288
|
-
};
|
|
289
|
-
return _reactNative().PanResponder.create({
|
|
290
|
-
onMoveShouldSetPanResponder: (_event, gestureState) => {
|
|
291
|
-
if (disabled) return false;
|
|
292
|
-
if (mergedRefreshingRef.current) return false;
|
|
293
|
-
if (showSuccess) return false;
|
|
294
|
-
if (scrollTopRef.current > 0) return false;
|
|
295
|
-
const {
|
|
296
|
-
dx,
|
|
297
|
-
dy
|
|
298
|
-
} = gestureState;
|
|
299
|
-
if (dy <= 0) return false;
|
|
300
|
-
if (Math.abs(dy) <= Math.abs(dx)) return false;
|
|
301
|
-
return true;
|
|
302
|
-
},
|
|
303
|
-
onPanResponderGrant: () => {
|
|
304
|
-
draggingRef.current = true;
|
|
305
|
-
},
|
|
306
|
-
onPanResponderMove: (event, gestureState) => {
|
|
307
|
-
if (disabled) return;
|
|
308
|
-
if (mergedRefreshingRef.current) return;
|
|
309
|
-
if (showSuccess) return;
|
|
310
|
-
if (scrollTopRef.current > 0) return;
|
|
311
|
-
const raw = Math.max(0, gestureState.dy ?? 0);
|
|
312
|
-
scheduleWebDrag(easeDistance(raw));
|
|
313
|
-
event.preventDefault?.();
|
|
314
|
-
},
|
|
315
|
-
onPanResponderRelease: async (_event, gestureState) => {
|
|
316
|
-
draggingRef.current = false;
|
|
317
|
-
cancelWebDrag();
|
|
318
|
-
if (disabled) return;
|
|
319
|
-
if (mergedRefreshingRef.current) return;
|
|
320
|
-
if (showSuccess) return;
|
|
321
|
-
const nextDistance = easeDistance(Math.max(0, gestureState.dy));
|
|
322
|
-
const shouldRefresh = nextDistance >= pullDistanceNumber;
|
|
323
|
-
if (shouldRefresh) {
|
|
324
|
-
setDistanceValue(headHeightNumber, true);
|
|
325
|
-
await handleRefresh();
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
setDistanceValue(0, true);
|
|
329
|
-
},
|
|
330
|
-
onPanResponderTerminate: () => {
|
|
331
|
-
draggingRef.current = false;
|
|
332
|
-
cancelWebDrag();
|
|
333
|
-
setDistanceValue(0, true);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
})();
|
|
337
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().ScrollView, _extends({}, scrollProps, {
|
|
338
|
-
ref: ref,
|
|
339
|
-
style: style,
|
|
340
|
-
contentContainerStyle: contentContainerStyle,
|
|
341
|
-
refreshControl: /*#__PURE__*/_react().default.createElement(_reactNative().RefreshControl, {
|
|
342
|
-
refreshing: !!mergedRefreshing,
|
|
343
|
-
onRefresh: handleRefresh,
|
|
344
|
-
enabled: !disabled && (0, _validate.isFunction)(onRefresh)
|
|
345
|
-
}),
|
|
346
|
-
onScroll: handleScroll,
|
|
347
|
-
scrollEventThrottle: 16
|
|
348
|
-
}), /*#__PURE__*/_react().default.createElement(_reactNative().Animated.View, _extends({}, panResponder ? panResponder.panHandlers : {}, {
|
|
349
|
-
style: isWeb ? {
|
|
350
|
-
transform: [{
|
|
351
|
-
translateY
|
|
352
|
-
}]
|
|
353
|
-
} : undefined
|
|
354
|
-
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
355
|
-
pointerEvents: "none",
|
|
356
|
-
style: [styles.head, {
|
|
357
|
-
height: headHeightNumber,
|
|
358
|
-
marginTop: -headHeightNumber
|
|
359
|
-
}]
|
|
360
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().Animated.View, {
|
|
361
|
-
style: {
|
|
362
|
-
opacity
|
|
363
|
-
}
|
|
364
|
-
}, (0, _validate.isText)(statusNode) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
365
|
-
style: {
|
|
366
|
-
color: status === 'success' ? colors.success : colors.text
|
|
367
|
-
}
|
|
368
|
-
}, statusNode) : statusNode)), children));
|
|
369
|
-
});
|
|
370
|
-
PullRefresh.displayName = 'PullRefresh';
|
|
371
|
-
const styles = _reactNative().StyleSheet.create({
|
|
372
|
-
head: {
|
|
373
|
-
alignItems: 'center',
|
|
374
|
-
justifyContent: 'flex-end',
|
|
375
|
-
paddingBottom: 8
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
var _default = exports.default = PullRefresh;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
Object.defineProperty(exports, "usePullRefreshTokens", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _tokens.usePullRefreshTokens;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
var _PullRefresh = _interopRequireDefault(require("./PullRefresh"));
|
|
14
|
-
var _tokens = require("./tokens");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
var _default = exports.default = _PullRefresh.default;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.usePullRefreshTokens = void 0;
|
|
7
|
-
var _designSystem = require("../../design-system");
|
|
8
|
-
const createTokens = foundations => {
|
|
9
|
-
const {
|
|
10
|
-
palette
|
|
11
|
-
} = foundations;
|
|
12
|
-
return {
|
|
13
|
-
colors: {
|
|
14
|
-
text: palette.default[600],
|
|
15
|
-
success: palette.success?.[500] ?? '#4caf50'
|
|
16
|
-
},
|
|
17
|
-
sizing: {
|
|
18
|
-
headHeight: 50
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const usePullRefreshTokens = exports.usePullRefreshTokens = (0, _designSystem.createComponentTokensHook)('pullRefresh', createTokens);
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.Rate = void 0;
|
|
7
|
-
function _react() {
|
|
8
|
-
const data = _interopRequireWildcard(require("react"));
|
|
9
|
-
_react = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _reactNative() {
|
|
15
|
-
const data = require("react-native");
|
|
16
|
-
_reactNative = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
var _tokens = require("./tokens");
|
|
22
|
-
var _hooks = require("../../hooks");
|
|
23
|
-
var _utils = require("../../utils");
|
|
24
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
25
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
26
|
-
const DEFAULT_CHARACTER = '★';
|
|
27
|
-
const Rate = exports.Rate = /*#__PURE__*/_react().default.memo(props => {
|
|
28
|
-
const {
|
|
29
|
-
tokensOverride,
|
|
30
|
-
count: countProp,
|
|
31
|
-
allowHalf: allowHalfProp,
|
|
32
|
-
size: sizeProp,
|
|
33
|
-
gutter: gutterProp,
|
|
34
|
-
color,
|
|
35
|
-
voidColor,
|
|
36
|
-
disabledColor,
|
|
37
|
-
icon,
|
|
38
|
-
voidIcon,
|
|
39
|
-
character,
|
|
40
|
-
disabled: disabledProp,
|
|
41
|
-
readOnly: readOnlyProp,
|
|
42
|
-
touchable: touchableProp,
|
|
43
|
-
onIconPress,
|
|
44
|
-
iconStyle,
|
|
45
|
-
itemStyle,
|
|
46
|
-
style,
|
|
47
|
-
...rest
|
|
48
|
-
} = props;
|
|
49
|
-
const tokens = (0, _tokens.useRateTokens)(tokensOverride);
|
|
50
|
-
const count = countProp ?? tokens.defaults.count;
|
|
51
|
-
const allowHalf = allowHalfProp ?? tokens.defaults.allowHalf;
|
|
52
|
-
const size = sizeProp ?? tokens.defaults.size;
|
|
53
|
-
const gutter = gutterProp ?? tokens.defaults.gutter;
|
|
54
|
-
const disabled = disabledProp ?? tokens.defaults.disabled;
|
|
55
|
-
const readOnly = readOnlyProp ?? tokens.defaults.readOnly;
|
|
56
|
-
const touchable = touchableProp ?? tokens.defaults.touchable;
|
|
57
|
-
const resolvedCount = Math.max(1, Math.floor((0, _utils.parseNumber)(count, tokens.defaults.count)));
|
|
58
|
-
const resolvedSize = Math.max(0, (0, _utils.parseNumber)(size, tokens.defaults.size));
|
|
59
|
-
const resolvedGutter = Math.max(0, (0, _utils.parseNumber)(gutter, tokens.defaults.gutter));
|
|
60
|
-
const [rawValue, triggerChange] = (0, _hooks.useControllableValue)(props, {
|
|
61
|
-
defaultValue: 0
|
|
62
|
-
});
|
|
63
|
-
const normalizedValue = (0, _utils.clamp)(Number(rawValue ?? 0), 0, resolvedCount);
|
|
64
|
-
const displayValue = allowHalf ? readOnly ? normalizedValue : Math.floor(normalizedValue * 2) / 2 : Math.floor(normalizedValue);
|
|
65
|
-
const interactive = !disabled && !readOnly;
|
|
66
|
-
const minScore = allowHalf ? 0.5 : 1;
|
|
67
|
-
const activeTint = disabled ? disabledColor ?? tokens.colors.disabled : color ?? tokens.colors.active;
|
|
68
|
-
const voidTint = disabled ? disabledColor ?? tokens.colors.disabled : voidColor ?? tokens.colors.inactive;
|
|
69
|
-
const requestValueChange = nextScore => {
|
|
70
|
-
if (nextScore === normalizedValue) return false;
|
|
71
|
-
triggerChange(nextScore);
|
|
72
|
-
return true;
|
|
73
|
-
};
|
|
74
|
-
const evaluatePress = (index, event) => {
|
|
75
|
-
if (!interactive) return;
|
|
76
|
-
const baseScore = index + 1;
|
|
77
|
-
let nextScore = baseScore;
|
|
78
|
-
if (allowHalf && event) {
|
|
79
|
-
const nativeEvent = event.nativeEvent;
|
|
80
|
-
let x;
|
|
81
|
-
let width;
|
|
82
|
-
const locationX = nativeEvent.locationX;
|
|
83
|
-
if ((0, _utils.isFiniteNumber)(locationX)) {
|
|
84
|
-
x = locationX;
|
|
85
|
-
} else {
|
|
86
|
-
const clientX = nativeEvent.clientX;
|
|
87
|
-
if ((0, _utils.isFiniteNumber)(clientX)) {
|
|
88
|
-
const rect = event.currentTarget?.getBoundingClientRect?.();
|
|
89
|
-
if (rect) {
|
|
90
|
-
x = clientX - rect.left;
|
|
91
|
-
width = rect.width;
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
const offsetX = nativeEvent.offsetX;
|
|
95
|
-
if ((0, _utils.isFiniteNumber)(offsetX)) x = offsetX;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const threshold = (width ?? resolvedSize) / 2;
|
|
99
|
-
if (x !== undefined && x <= threshold) {
|
|
100
|
-
nextScore = baseScore - 0.5;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
nextScore = (0, _utils.clamp)(nextScore, minScore, resolvedCount);
|
|
104
|
-
if (requestValueChange(nextScore)) onIconPress?.(nextScore);
|
|
105
|
-
};
|
|
106
|
-
const valueFromLocationX = locationX => {
|
|
107
|
-
const stride = resolvedSize + resolvedGutter;
|
|
108
|
-
if (stride <= 0) return minScore;
|
|
109
|
-
const maxX = resolvedSize * resolvedCount + resolvedGutter * (resolvedCount - 1);
|
|
110
|
-
const x = (0, _utils.clamp)(locationX, 0, maxX);
|
|
111
|
-
const index = (0, _utils.clamp)(Math.floor(x / stride), 0, resolvedCount - 1);
|
|
112
|
-
const within = x - index * stride;
|
|
113
|
-
let nextScore = index + 1;
|
|
114
|
-
if (allowHalf) {
|
|
115
|
-
const withinIcon = Math.min(within, resolvedSize);
|
|
116
|
-
if (withinIcon <= resolvedSize / 2) {
|
|
117
|
-
nextScore -= 0.5;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return (0, _utils.clamp)(nextScore, minScore, resolvedCount);
|
|
121
|
-
};
|
|
122
|
-
const lastMoveValueRef = (0, _react().useRef)(null);
|
|
123
|
-
const gestureStartRef = (0, _react().useRef)(null);
|
|
124
|
-
const gestureDirectionRef = (0, _react().useRef)('');
|
|
125
|
-
const onStartShouldSetResponderCapture = event => {
|
|
126
|
-
if (!interactive || !touchable) return false;
|
|
127
|
-
gestureStartRef.current = {
|
|
128
|
-
pageX: event.nativeEvent.pageX,
|
|
129
|
-
pageY: event.nativeEvent.pageY
|
|
130
|
-
};
|
|
131
|
-
gestureDirectionRef.current = '';
|
|
132
|
-
lastMoveValueRef.current = null;
|
|
133
|
-
return false;
|
|
134
|
-
};
|
|
135
|
-
const onMoveShouldSetResponderCapture = event => {
|
|
136
|
-
if (!interactive || !touchable) return false;
|
|
137
|
-
const start = gestureStartRef.current;
|
|
138
|
-
if (!start) {
|
|
139
|
-
gestureStartRef.current = {
|
|
140
|
-
pageX: event.nativeEvent.pageX,
|
|
141
|
-
pageY: event.nativeEvent.pageY
|
|
142
|
-
};
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
const offsetX = Math.abs(event.nativeEvent.pageX - start.pageX);
|
|
146
|
-
const offsetY = Math.abs(event.nativeEvent.pageY - start.pageY);
|
|
147
|
-
if (offsetX > offsetY && offsetX > 10) {
|
|
148
|
-
gestureDirectionRef.current = 'horizontal';
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
if (offsetY > offsetX && offsetY > 10) {
|
|
152
|
-
gestureDirectionRef.current = 'vertical';
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
};
|
|
156
|
-
const handleResponderMove = event => {
|
|
157
|
-
if (!interactive || !touchable) return;
|
|
158
|
-
if (gestureDirectionRef.current !== 'horizontal') return;
|
|
159
|
-
event.preventDefault?.();
|
|
160
|
-
const nextScore = valueFromLocationX(event.nativeEvent.locationX);
|
|
161
|
-
if (lastMoveValueRef.current === nextScore) return;
|
|
162
|
-
lastMoveValueRef.current = nextScore;
|
|
163
|
-
if (requestValueChange(nextScore)) onIconPress?.(nextScore);
|
|
164
|
-
};
|
|
165
|
-
const handleResponderEnd = () => {
|
|
166
|
-
lastMoveValueRef.current = null;
|
|
167
|
-
gestureStartRef.current = null;
|
|
168
|
-
gestureDirectionRef.current = '';
|
|
169
|
-
};
|
|
170
|
-
const renderIconNode = (renderValue, tintColor) => {
|
|
171
|
-
if (/*#__PURE__*/_react().default.isValidElement(renderValue)) {
|
|
172
|
-
const element = renderValue;
|
|
173
|
-
const defaultStyle = {
|
|
174
|
-
color: tintColor,
|
|
175
|
-
fontSize: resolvedSize,
|
|
176
|
-
lineHeight: resolvedSize,
|
|
177
|
-
textAlign: 'center',
|
|
178
|
-
includeFontPadding: false
|
|
179
|
-
};
|
|
180
|
-
const layoutStyle = {
|
|
181
|
-
width: resolvedSize,
|
|
182
|
-
height: resolvedSize,
|
|
183
|
-
flexShrink: 0
|
|
184
|
-
};
|
|
185
|
-
return /*#__PURE__*/_react().default.cloneElement(element, {
|
|
186
|
-
style: _reactNative().StyleSheet.flatten([defaultStyle, element.props.style, iconStyle, layoutStyle])
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
190
|
-
style: [tokens.layout.character, iconStyle, {
|
|
191
|
-
color: tintColor,
|
|
192
|
-
fontSize: resolvedSize,
|
|
193
|
-
lineHeight: resolvedSize,
|
|
194
|
-
width: resolvedSize,
|
|
195
|
-
height: resolvedSize,
|
|
196
|
-
textAlign: 'center'
|
|
197
|
-
}]
|
|
198
|
-
}, renderValue ?? DEFAULT_CHARACTER);
|
|
199
|
-
};
|
|
200
|
-
const resolvedActiveIcon = icon ?? character ?? DEFAULT_CHARACTER;
|
|
201
|
-
const resolvedVoidIcon = voidIcon ?? character ?? DEFAULT_CHARACTER;
|
|
202
|
-
const renderItem = index => {
|
|
203
|
-
const score = index + 1;
|
|
204
|
-
const fill = (0, _utils.clamp)(displayValue - index, 0, 1);
|
|
205
|
-
const marginRight = index === resolvedCount - 1 ? 0 : resolvedGutter;
|
|
206
|
-
const isFull = fill === 1;
|
|
207
|
-
const activeIconWrapperStyle = {
|
|
208
|
-
width: fill * resolvedSize,
|
|
209
|
-
height: isFull ? resolvedSize : resolvedSize * 1.5,
|
|
210
|
-
top: isFull ? 0 : -resolvedSize * 0.25,
|
|
211
|
-
overflow: isFull ? 'visible' : 'hidden'
|
|
212
|
-
};
|
|
213
|
-
const activeIconInnerStyle = {
|
|
214
|
-
width: resolvedSize,
|
|
215
|
-
height: resolvedSize,
|
|
216
|
-
marginTop: isFull ? 0 : resolvedSize * 0.25,
|
|
217
|
-
justifyContent: 'center',
|
|
218
|
-
alignItems: 'center',
|
|
219
|
-
overflow: 'visible'
|
|
220
|
-
};
|
|
221
|
-
const iconContent = /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
222
|
-
style: [tokens.layout.iconBox, {
|
|
223
|
-
width: resolvedSize,
|
|
224
|
-
height: resolvedSize
|
|
225
|
-
}]
|
|
226
|
-
}, fill < 1 ? renderIconNode(resolvedVoidIcon, voidTint) : null, fill > 0 ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
227
|
-
pointerEvents: "none",
|
|
228
|
-
style: [tokens.layout.fill, activeIconWrapperStyle]
|
|
229
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
230
|
-
style: activeIconInnerStyle
|
|
231
|
-
}, renderIconNode(resolvedActiveIcon, activeTint))) : null);
|
|
232
|
-
if (!interactive) {
|
|
233
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
234
|
-
key: score,
|
|
235
|
-
style: [tokens.layout.item, {
|
|
236
|
-
marginRight
|
|
237
|
-
}, itemStyle],
|
|
238
|
-
accessibilityRole: "image",
|
|
239
|
-
accessibilityLabel: `评分 ${score}`
|
|
240
|
-
}, iconContent);
|
|
241
|
-
}
|
|
242
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
|
|
243
|
-
key: score,
|
|
244
|
-
accessibilityRole: "button",
|
|
245
|
-
accessibilityLabel: `评${allowHalf ? '半' : ''}分 ${score}`,
|
|
246
|
-
onPress: event => evaluatePress(index, event),
|
|
247
|
-
style: ({
|
|
248
|
-
pressed
|
|
249
|
-
}) => [tokens.layout.item, {
|
|
250
|
-
marginRight
|
|
251
|
-
}, itemStyle, pressed && {
|
|
252
|
-
opacity: tokens.states.pressedOpacity
|
|
253
|
-
}]
|
|
254
|
-
}, iconContent);
|
|
255
|
-
};
|
|
256
|
-
const items = [];
|
|
257
|
-
for (let i = 0; i < resolvedCount; i++) items.push(renderItem(i));
|
|
258
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({}, rest, {
|
|
259
|
-
style: [tokens.layout.container, style],
|
|
260
|
-
accessibilityRole: "radiogroup",
|
|
261
|
-
onStartShouldSetResponderCapture: onStartShouldSetResponderCapture,
|
|
262
|
-
onMoveShouldSetResponderCapture: onMoveShouldSetResponderCapture,
|
|
263
|
-
onResponderMove: handleResponderMove,
|
|
264
|
-
onResponderRelease: handleResponderEnd,
|
|
265
|
-
onResponderTerminate: handleResponderEnd
|
|
266
|
-
}), items);
|
|
267
|
-
});
|
|
268
|
-
Rate.displayName = 'Rate';
|
|
269
|
-
var _default = exports.default = Rate;
|