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,473 +0,0 @@
|
|
|
1
|
-
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); }
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { FlatList, Platform, View, StyleSheet, PanResponder } from 'react-native';
|
|
4
|
-
import { clamp } from '../../utils';
|
|
5
|
-
import { findEnabledIndex } from './utils';
|
|
6
|
-
const adjustIndex = (index, options) => {
|
|
7
|
-
const total = options.length;
|
|
8
|
-
if (!total) return 0;
|
|
9
|
-
const i = clamp(index, 0, total - 1);
|
|
10
|
-
const next = findEnabledIndex(options, i);
|
|
11
|
-
return next >= 0 ? next : i;
|
|
12
|
-
};
|
|
13
|
-
const indexToOffset = (index, itemHeight) => -index * itemHeight;
|
|
14
|
-
const offsetToIndex = (offset, itemHeight, total, options) => {
|
|
15
|
-
const minOffset = -Math.max(0, total - 1) * itemHeight;
|
|
16
|
-
const off = clamp(offset, minOffset, 0);
|
|
17
|
-
let index = Math.round(-off / itemHeight);
|
|
18
|
-
index = adjustIndex(index, options);
|
|
19
|
-
const snapOffset = indexToOffset(index, itemHeight);
|
|
20
|
-
return {
|
|
21
|
-
index,
|
|
22
|
-
snapOffset
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const shouldMomentum = (distance, duration) => duration < 500 && Math.abs(distance) > 8;
|
|
26
|
-
const momentumTarget = (distance, duration, currentOffset, itemHeight, minOffset) => {
|
|
27
|
-
const speed = Math.abs(distance / duration);
|
|
28
|
-
const extra = speed / 0.0025 * (distance < 0 ? -1 : 1);
|
|
29
|
-
const target = clamp(currentOffset + extra, minOffset, 0);
|
|
30
|
-
const snapIndex = Math.round(-target / itemHeight);
|
|
31
|
-
return indexToOffset(snapIndex, itemHeight);
|
|
32
|
-
};
|
|
33
|
-
const styles = StyleSheet.create({
|
|
34
|
-
column: {
|
|
35
|
-
flex: 1
|
|
36
|
-
},
|
|
37
|
-
option: {
|
|
38
|
-
justifyContent: 'center',
|
|
39
|
-
alignItems: 'center'
|
|
40
|
-
},
|
|
41
|
-
indicator: {
|
|
42
|
-
position: 'absolute',
|
|
43
|
-
left: 0,
|
|
44
|
-
right: 0,
|
|
45
|
-
borderTopWidth: StyleSheet.hairlineWidth,
|
|
46
|
-
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
47
|
-
zIndex: 3
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const getVelocityBucket = velocity => {
|
|
51
|
-
const abs = Math.abs(velocity);
|
|
52
|
-
if (abs > 1.2) return 2;
|
|
53
|
-
if (abs > 0.6) return 1;
|
|
54
|
-
return 0;
|
|
55
|
-
};
|
|
56
|
-
const WheelPickerInner = ({
|
|
57
|
-
data,
|
|
58
|
-
selectedIndex,
|
|
59
|
-
onChange,
|
|
60
|
-
onInteractStart,
|
|
61
|
-
onInteractEnd,
|
|
62
|
-
renderItem,
|
|
63
|
-
itemHeight,
|
|
64
|
-
visibleRest,
|
|
65
|
-
readOnly,
|
|
66
|
-
indicatorColor,
|
|
67
|
-
decelerationRate = Platform.select({
|
|
68
|
-
ios: 0.9975,
|
|
69
|
-
android: 0.989,
|
|
70
|
-
default: 0.989
|
|
71
|
-
}) ?? 'normal',
|
|
72
|
-
scrollEventThrottle = 16,
|
|
73
|
-
swipeDuration = 300
|
|
74
|
-
}) => {
|
|
75
|
-
const isWeb = Platform.OS === 'web';
|
|
76
|
-
const listRef = useRef(null);
|
|
77
|
-
const spacerHeight = visibleRest * itemHeight;
|
|
78
|
-
const total = data.length;
|
|
79
|
-
const maxIndex = Math.max(0, total - 1);
|
|
80
|
-
const minOffset = -maxIndex * itemHeight;
|
|
81
|
-
const containerHeight = itemHeight * (visibleRest * 2 + 1);
|
|
82
|
-
const rawSelectedIndex = clamp(selectedIndex, 0, maxIndex);
|
|
83
|
-
const enabledSelectedIndex = findEnabledIndex(data, rawSelectedIndex);
|
|
84
|
-
const safeSelectedIndex = enabledSelectedIndex >= 0 ? enabledSelectedIndex : rawSelectedIndex;
|
|
85
|
-
const visibleCount = visibleRest * 2 + 1;
|
|
86
|
-
const initialRenderCount = Math.min(total || visibleCount, visibleCount);
|
|
87
|
-
const maxBatchRenderCount = Math.min(total || visibleCount * 2, Math.max(visibleCount * 2, 10));
|
|
88
|
-
const windowSize = total > visibleCount * 12 ? 7 : 5;
|
|
89
|
-
const batchingPeriod = total > visibleCount * 20 ? 32 : 16;
|
|
90
|
-
const effectiveScrollThrottle = total > visibleCount * 20 ? 32 : scrollEventThrottle;
|
|
91
|
-
const webVirtualEnabled = total > visibleCount * 4;
|
|
92
|
-
const Spacer = useCallback(() => /*#__PURE__*/React.createElement(View, {
|
|
93
|
-
style: {
|
|
94
|
-
height: spacerHeight
|
|
95
|
-
}
|
|
96
|
-
}), [spacerHeight]);
|
|
97
|
-
const dragEndTimerRef = useRef(null);
|
|
98
|
-
const momentumRef = useRef(false);
|
|
99
|
-
const lastOffsetRef = useRef(0);
|
|
100
|
-
const clearDragEndTimer = useCallback(() => {
|
|
101
|
-
if (dragEndTimerRef.current) {
|
|
102
|
-
clearTimeout(dragEndTimerRef.current);
|
|
103
|
-
dragEndTimerRef.current = null;
|
|
104
|
-
}
|
|
105
|
-
}, []);
|
|
106
|
-
const emitIndexFromOffset = useCallback((offsetY, animated) => {
|
|
107
|
-
if (readOnly) return;
|
|
108
|
-
const {
|
|
109
|
-
index,
|
|
110
|
-
snapOffset
|
|
111
|
-
} = offsetToIndex(-offsetY, itemHeight, total, data);
|
|
112
|
-
const nextOffset = -snapOffset;
|
|
113
|
-
if (Math.abs(nextOffset - offsetY) > 0.5) {
|
|
114
|
-
listRef.current?.scrollToOffset({
|
|
115
|
-
offset: nextOffset,
|
|
116
|
-
animated
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
onChange(index);
|
|
120
|
-
}, [data, itemHeight, onChange, readOnly, total]);
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
const offset = safeSelectedIndex * itemHeight;
|
|
123
|
-
listRef.current?.scrollToOffset({
|
|
124
|
-
offset,
|
|
125
|
-
animated: false
|
|
126
|
-
});
|
|
127
|
-
}, [itemHeight, safeSelectedIndex]);
|
|
128
|
-
const [webOffset, setWebOffset] = useState(() => indexToOffset(safeSelectedIndex, itemHeight));
|
|
129
|
-
const webOffsetRef = useRef(webOffset);
|
|
130
|
-
const startOffsetRef = useRef(0);
|
|
131
|
-
const startTimeRef = useRef(0);
|
|
132
|
-
const [webTransition, setWebTransition] = useState(0);
|
|
133
|
-
const [webVelocityBucket, setWebVelocityBucket] = useState(0);
|
|
134
|
-
const webVelocityBucketRef = useRef(0);
|
|
135
|
-
const lastWheelTimeRef = useRef(null);
|
|
136
|
-
const wheelDeltaRef = useRef(0);
|
|
137
|
-
const wheelRafRef = useRef(null);
|
|
138
|
-
const pendingIndexRef = useRef(null);
|
|
139
|
-
const pendingTimerRef = useRef(null);
|
|
140
|
-
const rafIdRef = useRef(null);
|
|
141
|
-
const isInteractingRef = useRef(false);
|
|
142
|
-
const notifyInteractStart = useCallback(() => {
|
|
143
|
-
if (readOnly) return;
|
|
144
|
-
if (isInteractingRef.current) return;
|
|
145
|
-
isInteractingRef.current = true;
|
|
146
|
-
onInteractStart?.();
|
|
147
|
-
}, [onInteractStart, readOnly]);
|
|
148
|
-
const notifyInteractEnd = useCallback(() => {
|
|
149
|
-
if (!isInteractingRef.current) return;
|
|
150
|
-
isInteractingRef.current = false;
|
|
151
|
-
onInteractEnd?.();
|
|
152
|
-
}, [onInteractEnd]);
|
|
153
|
-
const stopRaf = useCallback(() => {
|
|
154
|
-
if (rafIdRef.current != null && typeof cancelAnimationFrame !== 'undefined') {
|
|
155
|
-
cancelAnimationFrame(rafIdRef.current);
|
|
156
|
-
rafIdRef.current = null;
|
|
157
|
-
}
|
|
158
|
-
if (wheelRafRef.current != null && typeof cancelAnimationFrame !== 'undefined') {
|
|
159
|
-
cancelAnimationFrame(wheelRafRef.current);
|
|
160
|
-
wheelRafRef.current = null;
|
|
161
|
-
}
|
|
162
|
-
}, []);
|
|
163
|
-
const clearPendingTimer = useCallback(() => {
|
|
164
|
-
if (pendingTimerRef.current) {
|
|
165
|
-
clearTimeout(pendingTimerRef.current);
|
|
166
|
-
pendingTimerRef.current = null;
|
|
167
|
-
}
|
|
168
|
-
}, []);
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
return () => {
|
|
171
|
-
clearDragEndTimer();
|
|
172
|
-
clearPendingTimer();
|
|
173
|
-
stopRaf();
|
|
174
|
-
};
|
|
175
|
-
}, [clearDragEndTimer, clearPendingTimer, stopRaf]);
|
|
176
|
-
const setVelocityBucket = useCallback(velocity => {
|
|
177
|
-
const next = getVelocityBucket(velocity);
|
|
178
|
-
if (next !== webVelocityBucketRef.current) {
|
|
179
|
-
webVelocityBucketRef.current = next;
|
|
180
|
-
setWebVelocityBucket(next);
|
|
181
|
-
}
|
|
182
|
-
}, []);
|
|
183
|
-
const updateWheelVelocity = useCallback(delta => {
|
|
184
|
-
const now = Date.now();
|
|
185
|
-
const last = lastWheelTimeRef.current;
|
|
186
|
-
if (last != null) {
|
|
187
|
-
const dt = Math.max(1, now - last);
|
|
188
|
-
setVelocityBucket(delta / dt);
|
|
189
|
-
}
|
|
190
|
-
lastWheelTimeRef.current = now;
|
|
191
|
-
}, [setVelocityBucket]);
|
|
192
|
-
useEffect(() => {
|
|
193
|
-
if (!isWeb) return;
|
|
194
|
-
clearPendingTimer();
|
|
195
|
-
pendingIndexRef.current = null;
|
|
196
|
-
setWebTransition(0);
|
|
197
|
-
const next = indexToOffset(safeSelectedIndex, itemHeight);
|
|
198
|
-
webOffsetRef.current = next;
|
|
199
|
-
setWebOffset(next);
|
|
200
|
-
}, [clearPendingTimer, isWeb, itemHeight, safeSelectedIndex, setWebTransition]);
|
|
201
|
-
const finalizePendingChange = useCallback(() => {
|
|
202
|
-
if (readOnly) return;
|
|
203
|
-
const nextIndex = pendingIndexRef.current;
|
|
204
|
-
if (nextIndex == null) return;
|
|
205
|
-
pendingIndexRef.current = null;
|
|
206
|
-
clearPendingTimer();
|
|
207
|
-
setWebTransition(0);
|
|
208
|
-
notifyInteractEnd();
|
|
209
|
-
onChange(nextIndex);
|
|
210
|
-
}, [clearPendingTimer, onChange, readOnly, setWebTransition]);
|
|
211
|
-
const startWebSnap = useCallback(targetIndex => {
|
|
212
|
-
if (readOnly) return;
|
|
213
|
-
notifyInteractStart();
|
|
214
|
-
const clampedIndex = clamp(targetIndex, 0, maxIndex);
|
|
215
|
-
const targetOffset = indexToOffset(clampedIndex, itemHeight);
|
|
216
|
-
clearPendingTimer();
|
|
217
|
-
pendingIndexRef.current = clampedIndex;
|
|
218
|
-
webOffsetRef.current = targetOffset;
|
|
219
|
-
setWebTransition(swipeDuration);
|
|
220
|
-
setWebOffset(targetOffset);
|
|
221
|
-
if (swipeDuration <= 0) {
|
|
222
|
-
finalizePendingChange();
|
|
223
|
-
} else {
|
|
224
|
-
pendingTimerRef.current = setTimeout(finalizePendingChange, swipeDuration + 80);
|
|
225
|
-
}
|
|
226
|
-
}, [clearPendingTimer, finalizePendingChange, itemHeight, maxIndex, readOnly, swipeDuration]);
|
|
227
|
-
const handleWheel = useCallback(event => {
|
|
228
|
-
if (readOnly) return;
|
|
229
|
-
const delta = event.nativeEvent?.deltaY ?? 0;
|
|
230
|
-
if (!delta) return;
|
|
231
|
-
wheelDeltaRef.current += delta;
|
|
232
|
-
if (wheelRafRef.current != null || typeof requestAnimationFrame === 'undefined') {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
wheelRafRef.current = requestAnimationFrame(() => {
|
|
236
|
-
wheelRafRef.current = null;
|
|
237
|
-
const queued = wheelDeltaRef.current;
|
|
238
|
-
wheelDeltaRef.current = 0;
|
|
239
|
-
if (!queued) return;
|
|
240
|
-
updateWheelVelocity(queued);
|
|
241
|
-
const direction = queued > 0 ? 1 : -1;
|
|
242
|
-
const {
|
|
243
|
-
index
|
|
244
|
-
} = offsetToIndex(webOffsetRef.current, itemHeight, total, data);
|
|
245
|
-
const nextIndex = clamp(index + direction, 0, maxIndex);
|
|
246
|
-
startWebSnap(nextIndex);
|
|
247
|
-
});
|
|
248
|
-
}, [data, itemHeight, maxIndex, readOnly, startWebSnap, total, updateWheelVelocity]);
|
|
249
|
-
const keyExtractor = useCallback((item, idx) => `${idx}-${String(item.value ?? '')}`, []);
|
|
250
|
-
const renderListItem = useCallback(({
|
|
251
|
-
item,
|
|
252
|
-
index
|
|
253
|
-
}) => {
|
|
254
|
-
const content = renderItem(item, index);
|
|
255
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
256
|
-
style: [styles.option, {
|
|
257
|
-
height: itemHeight
|
|
258
|
-
}]
|
|
259
|
-
}, content);
|
|
260
|
-
}, [itemHeight, renderItem]);
|
|
261
|
-
const webIndex = clamp(Math.round(-webOffset / itemHeight), 0, maxIndex);
|
|
262
|
-
const webRender = (() => {
|
|
263
|
-
if (!isWeb || total <= 0) {
|
|
264
|
-
return {
|
|
265
|
-
items: null,
|
|
266
|
-
topSpacer: null,
|
|
267
|
-
bottomSpacer: null
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
let startIndex = 0;
|
|
271
|
-
let endIndex = maxIndex;
|
|
272
|
-
if (webVirtualEnabled) {
|
|
273
|
-
const baseBuffer = Math.max(visibleCount * 2, 8);
|
|
274
|
-
const velocityBoost = webVelocityBucket === 2 ? visibleCount * 4 : webVelocityBucket === 1 ? visibleCount * 2 : 0;
|
|
275
|
-
const buffer = Math.min(baseBuffer + velocityBoost, Math.max(visibleCount * 6, 24));
|
|
276
|
-
startIndex = clamp(webIndex - buffer, 0, maxIndex);
|
|
277
|
-
endIndex = clamp(webIndex + buffer, 0, maxIndex);
|
|
278
|
-
}
|
|
279
|
-
const items = [];
|
|
280
|
-
for (let index = startIndex; index <= endIndex; index += 1) {
|
|
281
|
-
const item = data[index];
|
|
282
|
-
if (!item) continue;
|
|
283
|
-
const content = renderItem(item, index);
|
|
284
|
-
items.push(/*#__PURE__*/React.createElement(View, {
|
|
285
|
-
key: `${index}-${String(item.value ?? '')}`,
|
|
286
|
-
style: [styles.option, {
|
|
287
|
-
height: itemHeight
|
|
288
|
-
}]
|
|
289
|
-
}, content));
|
|
290
|
-
}
|
|
291
|
-
const topHeight = startIndex * itemHeight;
|
|
292
|
-
const bottomHeight = (maxIndex - endIndex) * itemHeight;
|
|
293
|
-
return {
|
|
294
|
-
items,
|
|
295
|
-
topSpacer: topHeight > 0 && /*#__PURE__*/React.createElement(View, {
|
|
296
|
-
style: {
|
|
297
|
-
height: topHeight
|
|
298
|
-
}
|
|
299
|
-
}),
|
|
300
|
-
bottomSpacer: bottomHeight > 0 && /*#__PURE__*/React.createElement(View, {
|
|
301
|
-
style: {
|
|
302
|
-
height: bottomHeight
|
|
303
|
-
}
|
|
304
|
-
})
|
|
305
|
-
};
|
|
306
|
-
})();
|
|
307
|
-
const webTransform = {
|
|
308
|
-
transform: [{
|
|
309
|
-
translateY: webOffset
|
|
310
|
-
}]
|
|
311
|
-
};
|
|
312
|
-
const webTransitionStyle = webTransition ? {
|
|
313
|
-
transitionProperty: 'transform',
|
|
314
|
-
transitionDuration: `${webTransition}ms`,
|
|
315
|
-
transitionTimingFunction: 'cubic-bezier(0.23, 1, 0.68, 1)',
|
|
316
|
-
willChange: 'transform'
|
|
317
|
-
} : undefined;
|
|
318
|
-
const handleWebTransitionEnd = useCallback(event => {
|
|
319
|
-
const propertyName = event.nativeEvent?.propertyName ?? event.propertyName;
|
|
320
|
-
if (propertyName && propertyName !== 'transform' && propertyName !== 'webkitTransform') return;
|
|
321
|
-
finalizePendingChange();
|
|
322
|
-
}, [finalizePendingChange]);
|
|
323
|
-
const panResponder = PanResponder.create({
|
|
324
|
-
onStartShouldSetPanResponder: () => !readOnly,
|
|
325
|
-
onMoveShouldSetPanResponder: () => !readOnly,
|
|
326
|
-
onPanResponderGrant: () => {
|
|
327
|
-
stopRaf();
|
|
328
|
-
pendingIndexRef.current = null;
|
|
329
|
-
notifyInteractStart();
|
|
330
|
-
setWebTransition(0);
|
|
331
|
-
startOffsetRef.current = webOffsetRef.current;
|
|
332
|
-
startTimeRef.current = Date.now();
|
|
333
|
-
},
|
|
334
|
-
onPanResponderMove: (_, gesture) => {
|
|
335
|
-
if (readOnly) return;
|
|
336
|
-
setVelocityBucket(gesture.vy);
|
|
337
|
-
const next = clamp(startOffsetRef.current + gesture.dy, minOffset, 0);
|
|
338
|
-
webOffsetRef.current = next;
|
|
339
|
-
if (typeof requestAnimationFrame === 'undefined') {
|
|
340
|
-
setWebOffset(next);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
if (rafIdRef.current != null) return;
|
|
344
|
-
rafIdRef.current = requestAnimationFrame(() => {
|
|
345
|
-
rafIdRef.current = null;
|
|
346
|
-
setWebOffset(webOffsetRef.current);
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
onPanResponderRelease: (_, gesture) => {
|
|
350
|
-
if (readOnly) return;
|
|
351
|
-
setVelocityBucket(0);
|
|
352
|
-
const duration = Date.now() - startTimeRef.current;
|
|
353
|
-
const distance = gesture.dy;
|
|
354
|
-
let target = clamp(startOffsetRef.current + distance, minOffset, 0);
|
|
355
|
-
if (shouldMomentum(distance, duration)) {
|
|
356
|
-
target = momentumTarget(distance, duration, startOffsetRef.current, itemHeight, minOffset);
|
|
357
|
-
}
|
|
358
|
-
const {
|
|
359
|
-
index
|
|
360
|
-
} = offsetToIndex(target, itemHeight, total, data);
|
|
361
|
-
startWebSnap(index);
|
|
362
|
-
},
|
|
363
|
-
onPanResponderTerminationRequest: () => false,
|
|
364
|
-
onPanResponderTerminate: () => {
|
|
365
|
-
notifyInteractEnd();
|
|
366
|
-
setWebTransition(0);
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
if (isWeb) {
|
|
370
|
-
return /*#__PURE__*/React.createElement(View, _extends({
|
|
371
|
-
style: [styles.column, {
|
|
372
|
-
height: containerHeight
|
|
373
|
-
}, webOnlyStyles.grab],
|
|
374
|
-
onWheel: handleWheel
|
|
375
|
-
}, panResponder.panHandlers), /*#__PURE__*/React.createElement(View, {
|
|
376
|
-
style: [styles.indicator, {
|
|
377
|
-
height: itemHeight,
|
|
378
|
-
top: itemHeight * visibleRest,
|
|
379
|
-
borderColor: indicatorColor
|
|
380
|
-
}],
|
|
381
|
-
pointerEvents: "none"
|
|
382
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
383
|
-
style: [webTransform, isWeb ? webTransitionStyle : undefined],
|
|
384
|
-
onTransitionEnd: handleWebTransitionEnd
|
|
385
|
-
}, /*#__PURE__*/React.createElement(Spacer, null), webRender.topSpacer, webRender.items, webRender.bottomSpacer, /*#__PURE__*/React.createElement(Spacer, null)));
|
|
386
|
-
}
|
|
387
|
-
const shouldCapture = !readOnly;
|
|
388
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
389
|
-
style: [styles.column, {
|
|
390
|
-
height: containerHeight
|
|
391
|
-
}],
|
|
392
|
-
collapsable: false
|
|
393
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
394
|
-
style: [styles.indicator, {
|
|
395
|
-
height: itemHeight,
|
|
396
|
-
top: itemHeight * visibleRest,
|
|
397
|
-
borderColor: indicatorColor
|
|
398
|
-
}],
|
|
399
|
-
pointerEvents: "none"
|
|
400
|
-
}), /*#__PURE__*/React.createElement(FlatList, {
|
|
401
|
-
ref: listRef,
|
|
402
|
-
data: data,
|
|
403
|
-
keyExtractor: keyExtractor,
|
|
404
|
-
initialScrollIndex: total > 0 ? safeSelectedIndex : undefined,
|
|
405
|
-
initialNumToRender: initialRenderCount,
|
|
406
|
-
maxToRenderPerBatch: maxBatchRenderCount,
|
|
407
|
-
windowSize: windowSize,
|
|
408
|
-
updateCellsBatchingPeriod: batchingPeriod,
|
|
409
|
-
renderItem: renderListItem,
|
|
410
|
-
getItemLayout: (_, index) => ({
|
|
411
|
-
length: itemHeight,
|
|
412
|
-
offset: spacerHeight + index * itemHeight,
|
|
413
|
-
index
|
|
414
|
-
}),
|
|
415
|
-
showsVerticalScrollIndicator: false,
|
|
416
|
-
scrollEventThrottle: effectiveScrollThrottle,
|
|
417
|
-
decelerationRate: decelerationRate,
|
|
418
|
-
snapToInterval: itemHeight,
|
|
419
|
-
snapToAlignment: "start",
|
|
420
|
-
bounces: false,
|
|
421
|
-
overScrollMode: "never",
|
|
422
|
-
nestedScrollEnabled: true,
|
|
423
|
-
onStartShouldSetResponderCapture: () => shouldCapture,
|
|
424
|
-
onMoveShouldSetResponderCapture: () => shouldCapture,
|
|
425
|
-
removeClippedSubviews: !isWeb,
|
|
426
|
-
collapsable: false,
|
|
427
|
-
ListHeaderComponent: Spacer,
|
|
428
|
-
ListFooterComponent: Spacer,
|
|
429
|
-
onScroll: e => {
|
|
430
|
-
lastOffsetRef.current = e.nativeEvent.contentOffset.y;
|
|
431
|
-
},
|
|
432
|
-
onScrollBeginDrag: () => {
|
|
433
|
-
momentumRef.current = false;
|
|
434
|
-
clearDragEndTimer();
|
|
435
|
-
notifyInteractStart();
|
|
436
|
-
},
|
|
437
|
-
onScrollEndDrag: e => {
|
|
438
|
-
if (readOnly) return;
|
|
439
|
-
const y = e.nativeEvent.contentOffset.y;
|
|
440
|
-
lastOffsetRef.current = y;
|
|
441
|
-
clearDragEndTimer();
|
|
442
|
-
dragEndTimerRef.current = setTimeout(() => {
|
|
443
|
-
if (!momentumRef.current) {
|
|
444
|
-
emitIndexFromOffset(lastOffsetRef.current, true);
|
|
445
|
-
notifyInteractEnd();
|
|
446
|
-
}
|
|
447
|
-
}, 80);
|
|
448
|
-
},
|
|
449
|
-
onMomentumScrollBegin: () => {
|
|
450
|
-
momentumRef.current = true;
|
|
451
|
-
clearDragEndTimer();
|
|
452
|
-
notifyInteractStart();
|
|
453
|
-
},
|
|
454
|
-
onMomentumScrollEnd: e => {
|
|
455
|
-
momentumRef.current = false;
|
|
456
|
-
clearDragEndTimer();
|
|
457
|
-
const y = e.nativeEvent.contentOffset.y;
|
|
458
|
-
lastOffsetRef.current = y;
|
|
459
|
-
emitIndexFromOffset(y, false);
|
|
460
|
-
notifyInteractEnd();
|
|
461
|
-
},
|
|
462
|
-
scrollEnabled: !readOnly
|
|
463
|
-
}));
|
|
464
|
-
};
|
|
465
|
-
const WheelPicker = /*#__PURE__*/React.memo(WheelPickerInner);
|
|
466
|
-
const webOnlyStyles = StyleSheet.create({
|
|
467
|
-
grab: {
|
|
468
|
-
cursor: 'pointer',
|
|
469
|
-
userSelect: 'none',
|
|
470
|
-
touchAction: 'none'
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
export default WheelPicker;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../utils';
|
|
2
|
-
export const toArrayValue = value => {
|
|
3
|
-
if (Array.isArray(value)) return value.filter(v => v !== undefined && v !== null);
|
|
4
|
-
if (value === undefined || value === null) return [];
|
|
5
|
-
return [value];
|
|
6
|
-
};
|
|
7
|
-
const isColumnWithOptions = col => !!col && isObject(col) && 'options' in col && Array.isArray(col.options);
|
|
8
|
-
const hasChildren = option => {
|
|
9
|
-
return !!option && isObject(option) && Array.isArray(option.children) && option.children.length > 0;
|
|
10
|
-
};
|
|
11
|
-
export const findEnabledIndex = (options, startIndex) => {
|
|
12
|
-
if (!options.length) return -1;
|
|
13
|
-
const clamp = Math.min(Math.max(startIndex, 0), options.length - 1);
|
|
14
|
-
if (!options[clamp]?.disabled) return clamp;
|
|
15
|
-
for (let i = clamp + 1; i < options.length; i += 1) {
|
|
16
|
-
if (!options[i]?.disabled) return i;
|
|
17
|
-
}
|
|
18
|
-
for (let i = clamp - 1; i >= 0; i -= 1) {
|
|
19
|
-
if (!options[i]?.disabled) return i;
|
|
20
|
-
}
|
|
21
|
-
return -1;
|
|
22
|
-
};
|
|
23
|
-
const normalizeMultiple = (columnsList, defaults, rawValue) => {
|
|
24
|
-
const values = [];
|
|
25
|
-
const options = [];
|
|
26
|
-
columnsList.forEach((opts, index) => {
|
|
27
|
-
const current = rawValue[index];
|
|
28
|
-
const defaultIndex = defaults[index] !== undefined ? opts.findIndex(item => item.value === defaults[index]) : -1;
|
|
29
|
-
const currentIndex = opts.findIndex(item => item.value === current);
|
|
30
|
-
const startIndex = currentIndex >= 0 ? currentIndex : defaultIndex >= 0 ? defaultIndex : 0;
|
|
31
|
-
const targetIndex = findEnabledIndex(opts, startIndex);
|
|
32
|
-
const target = targetIndex >= 0 ? opts[targetIndex] : undefined;
|
|
33
|
-
const valid = currentIndex >= 0 && !opts[currentIndex]?.disabled;
|
|
34
|
-
values[index] = valid ? current : target?.value ?? defaults[index] ?? opts[0]?.value;
|
|
35
|
-
options[index] = target;
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
columns: columnsList,
|
|
39
|
-
values,
|
|
40
|
-
options
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const normalizeCascade = (rootOptions, rawValue) => {
|
|
44
|
-
const columns = [];
|
|
45
|
-
const values = [];
|
|
46
|
-
const options = [];
|
|
47
|
-
let currentOptions = rootOptions;
|
|
48
|
-
let depth = 0;
|
|
49
|
-
while (currentOptions && currentOptions.length && depth < 10) {
|
|
50
|
-
columns.push(currentOptions);
|
|
51
|
-
const current = rawValue[depth];
|
|
52
|
-
const startIndex = currentOptions.findIndex(item => item.value === current || String(item.value) === String(current));
|
|
53
|
-
const targetIndex = findEnabledIndex(currentOptions, startIndex >= 0 ? startIndex : 0);
|
|
54
|
-
const target = targetIndex >= 0 ? currentOptions[targetIndex] : currentOptions[0];
|
|
55
|
-
values[depth] = target?.value;
|
|
56
|
-
options[depth] = target;
|
|
57
|
-
if (target && hasChildren(target)) {
|
|
58
|
-
currentOptions = target.children;
|
|
59
|
-
depth += 1;
|
|
60
|
-
} else {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
columns,
|
|
66
|
-
values,
|
|
67
|
-
options
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
export const prepareColumns = (columnsInput = []) => {
|
|
71
|
-
if (!Array.isArray(columnsInput) || columnsInput.length === 0) {
|
|
72
|
-
return {
|
|
73
|
-
type: 'single',
|
|
74
|
-
columnsList: [],
|
|
75
|
-
defaults: [],
|
|
76
|
-
cascadeRoot: []
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const everyPlainOption = columnsInput.every(item => !Array.isArray(item) && !isColumnWithOptions(item));
|
|
80
|
-
const cascade = everyPlainOption && columnsInput.some(item => hasChildren(item));
|
|
81
|
-
if (cascade) {
|
|
82
|
-
return {
|
|
83
|
-
type: 'cascade',
|
|
84
|
-
columnsList: [],
|
|
85
|
-
defaults: [],
|
|
86
|
-
cascadeRoot: columnsInput
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const asArray = columnsInput;
|
|
90
|
-
const columnsList = [];
|
|
91
|
-
const defaults = [];
|
|
92
|
-
const treatAsSingleColumn = everyPlainOption && !cascade;
|
|
93
|
-
if (treatAsSingleColumn) {
|
|
94
|
-
columnsList.push(columnsInput);
|
|
95
|
-
defaults.push(undefined);
|
|
96
|
-
} else {
|
|
97
|
-
asArray.forEach(col => {
|
|
98
|
-
if (Array.isArray(col)) {
|
|
99
|
-
columnsList.push(col);
|
|
100
|
-
defaults.push(undefined);
|
|
101
|
-
} else if (isColumnWithOptions(col)) {
|
|
102
|
-
const c = col;
|
|
103
|
-
columnsList.push(c.options ?? []);
|
|
104
|
-
defaults.push(c.defaultValue);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
type: 'multiple',
|
|
110
|
-
columnsList,
|
|
111
|
-
defaults
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
export const normalizePicker = (prepared, rawValueInput = []) => {
|
|
115
|
-
const rawValue = Array.isArray(rawValueInput) ? rawValueInput : [];
|
|
116
|
-
if (prepared.type === 'cascade' && prepared.cascadeRoot?.length) {
|
|
117
|
-
return normalizeCascade(prepared.cascadeRoot, rawValue);
|
|
118
|
-
}
|
|
119
|
-
return normalizeMultiple(prepared.columnsList, prepared.defaults, rawValue);
|
|
120
|
-
};
|
|
121
|
-
export const shallowEqualArray = (a = [], b = []) => {
|
|
122
|
-
if (a.length !== b.length) return false;
|
|
123
|
-
for (let i = 0; i < a.length; i += 1) {
|
|
124
|
-
if (a[i] !== b[i]) return false;
|
|
125
|
-
}
|
|
126
|
-
return true;
|
|
127
|
-
};
|