react-native-system-ui 0.0.5 → 0.0.7
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/README.md +12 -4
- 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 +63 -22
- 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 +63 -22
- 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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.SwiperItem = void 0;
|
|
7
7
|
function _react() {
|
|
8
8
|
const data = _interopRequireWildcard(require("react"));
|
|
9
9
|
_react = function () {
|
|
@@ -19,775 +19,319 @@ function _reactNative() {
|
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
21
|
var _number = require("../../utils/number");
|
|
22
|
-
var _validate = require("../../utils/validate");
|
|
23
|
-
var _SwiperItem = _interopRequireDefault(require("./SwiperItem"));
|
|
24
22
|
var _SwiperPagIndicator = _interopRequireDefault(require("./SwiperPagIndicator"));
|
|
25
|
-
var _utils = require("./utils");
|
|
26
|
-
var _useSwiperWeb = require("./useSwiperWeb");
|
|
27
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
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); }
|
|
29
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 SwiperItem = exports.SwiperItem = /*#__PURE__*/(0, _react().forwardRef)((props, ref) => {
|
|
27
|
+
const {
|
|
28
|
+
style,
|
|
29
|
+
children,
|
|
30
|
+
testID
|
|
31
|
+
} = props;
|
|
32
|
+
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
33
|
+
ref: ref,
|
|
34
|
+
style: [styles.item, style],
|
|
35
|
+
testID: testID
|
|
36
|
+
}, children);
|
|
37
|
+
});
|
|
38
|
+
SwiperItem.displayName = 'SwiperItem';
|
|
39
|
+
const DEFAULT_AUTOPLAY_INTERVAL = 3000;
|
|
40
|
+
const LOOP_RENDER_ALL_THRESHOLD = 10;
|
|
30
41
|
const SwiperImpl = (props, ref) => {
|
|
31
42
|
const {
|
|
43
|
+
data,
|
|
44
|
+
renderItem,
|
|
45
|
+
children,
|
|
32
46
|
initialSwipe = 0,
|
|
33
47
|
touchable = true,
|
|
34
|
-
autoplay = false,
|
|
35
48
|
loop = true,
|
|
49
|
+
autoplay = false,
|
|
36
50
|
vertical = false,
|
|
37
|
-
duration = 300,
|
|
38
|
-
enabled = true,
|
|
39
|
-
rubberband = true,
|
|
40
51
|
onChange,
|
|
41
|
-
indicator,
|
|
52
|
+
indicator = true,
|
|
42
53
|
indicatorProps,
|
|
43
|
-
slideSize = 100,
|
|
44
|
-
trackOffset = 0,
|
|
45
|
-
autoHeight = false,
|
|
46
|
-
stuckAtBoundary = false,
|
|
47
|
-
preventScroll = true,
|
|
48
54
|
style,
|
|
49
|
-
children,
|
|
50
|
-
data,
|
|
51
|
-
renderItem,
|
|
52
55
|
testID
|
|
53
56
|
} = props;
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
57
|
+
const flatListRef = (0, _react().useRef)(null);
|
|
58
|
+
const autoplayTimerRef = (0, _react().useRef)(null);
|
|
59
|
+
const isInteractingRef = (0, _react().useRef)(false);
|
|
60
|
+
const isAnimatingRef = (0, _react().useRef)(false);
|
|
61
|
+
const queuedIndexRef = (0, _react().useRef)(null);
|
|
62
|
+
const isMomentumRef = (0, _react().useRef)(false);
|
|
63
|
+
const isWeb = _reactNative().Platform.OS === 'web';
|
|
58
64
|
const {
|
|
59
65
|
width: windowWidth,
|
|
60
66
|
height: windowHeight
|
|
61
67
|
} = (0, _reactNative().useWindowDimensions)();
|
|
62
|
-
const
|
|
63
|
-
const viewportHeight = windowHeight || _utils.FALLBACK_HEIGHT;
|
|
64
|
-
const [containerLayout, setContainerLayout] = (0, _react().useState)({
|
|
68
|
+
const [layout, setLayout] = (0, _react().useState)({
|
|
65
69
|
width: 0,
|
|
66
70
|
height: 0
|
|
67
71
|
});
|
|
68
|
-
const
|
|
69
|
-
const autoplayTimerRef = (0, _react().useRef)(null);
|
|
70
|
-
const isDraggingRef = (0, _react().useRef)(false);
|
|
71
|
-
const isScrollingRef = (0, _react().useRef)(false);
|
|
72
|
-
const nativeMomentumRef = (0, _react().useRef)(false);
|
|
73
|
-
const prevIndexRef = (0, _react().useRef)(initialSwipeValue);
|
|
74
|
-
const currentDisplayIndexRef = (0, _react().useRef)(initialSwipeValue);
|
|
75
|
-
const desiredIndexRef = (0, _react().useRef)(initialSwipeValue);
|
|
76
|
-
const isWeb = _reactNative().Platform.OS === 'web';
|
|
77
|
-
const nativeQueuedScrollRef = (0, _react().useRef)(null);
|
|
78
|
-
const nativeScrollSeqRef = (0, _react().useRef)(0);
|
|
79
|
-
const nativeScrollEndTimerRef = (0, _react().useRef)(null);
|
|
80
|
-
const scrollToIndexSafe = (0, _react().useCallback)((index, animated) => {
|
|
81
|
-
try {
|
|
82
|
-
flatListRef.current?.scrollToIndex({
|
|
83
|
-
index,
|
|
84
|
-
animated
|
|
85
|
-
});
|
|
86
|
-
} catch {}
|
|
87
|
-
}, []);
|
|
88
|
-
const clearNativeScrollEndTimer = (0, _react().useCallback)(() => {
|
|
89
|
-
if (nativeScrollEndTimerRef.current) {
|
|
90
|
-
clearTimeout(nativeScrollEndTimerRef.current);
|
|
91
|
-
nativeScrollEndTimerRef.current = null;
|
|
92
|
-
}
|
|
93
|
-
}, []);
|
|
94
|
-
const validChildren = children ? _react().Children.toArray(children).filter(child => {
|
|
95
|
-
if (! /*#__PURE__*/(0, _react().isValidElement)(child)) return false;
|
|
96
|
-
if (child.type === _SwiperItem.default) return true;
|
|
97
|
-
const type = child.type;
|
|
98
|
-
return type.displayName === 'SwiperItem';
|
|
99
|
-
}) : [];
|
|
100
|
-
const itemsData = data ? data : validChildren.length > 0 ? validChildren.map((_, idx) => ({
|
|
101
|
-
type: 'child',
|
|
102
|
-
index: idx
|
|
103
|
-
})) : [];
|
|
104
|
-
const count = itemsData.length;
|
|
105
|
-
const slideRatio = slideSizePct / 100;
|
|
106
|
-
const offsetRatio = trackOffsetPct / 100;
|
|
107
|
-
const shouldLoop = loop && count > 1 && slideRatio * (count - 1) >= 1;
|
|
108
|
-
const loopData = !shouldLoop || count <= 1 ? itemsData : [...itemsData.slice(-1), ...itemsData, ...itemsData.slice(0, 1)];
|
|
109
|
-
const displayData = shouldLoop ? loopData : itemsData;
|
|
110
|
-
const displayCount = displayData.length;
|
|
111
|
-
const getDisplayIndex = (0, _react().useCallback)(index => {
|
|
112
|
-
if (!shouldLoop) return index;
|
|
113
|
-
if (index === 0) return count - 1;
|
|
114
|
-
if (index === displayCount - 1) return 0;
|
|
115
|
-
return index - 1;
|
|
116
|
-
}, [shouldLoop, count, displayCount]);
|
|
117
|
-
const handleContainerLayout = (0, _react().useCallback)(e => {
|
|
72
|
+
const handleLayout = (0, _react().useCallback)(event => {
|
|
118
73
|
const {
|
|
119
74
|
width,
|
|
120
75
|
height
|
|
121
|
-
} =
|
|
122
|
-
|
|
76
|
+
} = event.nativeEvent.layout;
|
|
77
|
+
setLayout(prev => prev.width === width && prev.height === height ? prev : {
|
|
123
78
|
width,
|
|
124
79
|
height
|
|
125
80
|
});
|
|
126
81
|
}, []);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
82
|
+
const childItems = (0, _react().useMemo)(() => {
|
|
83
|
+
if (!children) return [];
|
|
84
|
+
return _react().Children.toArray(children).filter(child => /*#__PURE__*/(0, _react().isValidElement)(child));
|
|
85
|
+
}, [children]);
|
|
86
|
+
const usingData = Array.isArray(data);
|
|
87
|
+
const baseItems = (0, _react().useMemo)(() => usingData ? data : childItems, [usingData, data, childItems]);
|
|
88
|
+
const count = baseItems.length;
|
|
89
|
+
const shouldLoop = loop && count > 1;
|
|
90
|
+
const displayData = (0, _react().useMemo)(() => {
|
|
91
|
+
if (!shouldLoop) return baseItems;
|
|
92
|
+
const head = baseItems[count - 1];
|
|
93
|
+
const tail = baseItems[0];
|
|
94
|
+
return [head, ...baseItems, tail];
|
|
95
|
+
}, [baseItems, shouldLoop, count]);
|
|
96
|
+
const displayCount = displayData.length;
|
|
97
|
+
const loopRenderAll = shouldLoop && displayCount <= LOOP_RENDER_ALL_THRESHOLD;
|
|
98
|
+
const getRealIndex = (0, _react().useCallback)(displayIndex => {
|
|
99
|
+
if (!shouldLoop) return (0, _number.clamp)(displayIndex, 0, count - 1);
|
|
100
|
+
if (displayIndex === 0) return count - 1;
|
|
101
|
+
if (displayIndex === displayCount - 1) return 0;
|
|
102
|
+
return displayIndex - 1;
|
|
103
|
+
}, [shouldLoop, count, displayCount]);
|
|
104
|
+
const getDisplayIndex = (0, _react().useCallback)(realIndex => {
|
|
105
|
+
if (!shouldLoop) return (0, _number.clamp)(realIndex, 0, count - 1);
|
|
106
|
+
return (0, _number.clamp)(realIndex, 0, count - 1) + 1;
|
|
107
|
+
}, [shouldLoop, count]);
|
|
108
|
+
const initialRealIndex = (0, _number.clamp)(initialSwipe, 0, Math.max(0, count - 1));
|
|
109
|
+
const initialDisplayIndex = getDisplayIndex(initialRealIndex);
|
|
110
|
+
const currentIndexRef = (0, _react().useRef)(initialRealIndex);
|
|
111
|
+
const [currentIndex, setCurrentIndex] = (0, _react().useState)(initialRealIndex);
|
|
112
|
+
const layoutReady = layout.width > 0 && layout.height > 0;
|
|
113
|
+
const mainSize = vertical ? layout.height || windowHeight || 1 : layout.width || windowWidth || 1;
|
|
114
|
+
const crossSize = vertical ? layout.width || windowWidth || 1 : layout.height || windowHeight || 1;
|
|
115
|
+
const itemStyle = (0, _react().useMemo)(() => ({
|
|
116
|
+
width: vertical ? crossSize : mainSize,
|
|
117
|
+
height: vertical ? mainSize : crossSize
|
|
118
|
+
}), [vertical, mainSize, crossSize]);
|
|
119
|
+
const clearAutoplay = (0, _react().useCallback)(() => {
|
|
120
|
+
if (autoplayTimerRef.current) {
|
|
121
|
+
clearTimeout(autoplayTimerRef.current);
|
|
122
|
+
autoplayTimerRef.current = null;
|
|
123
|
+
}
|
|
165
124
|
}, []);
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
panResponder,
|
|
179
|
-
stopWebSnapAnim,
|
|
180
|
-
cancelWebRaf,
|
|
181
|
-
webSnapAnimRef
|
|
182
|
-
} = (0, _useSwiperWeb.useSwiperWeb)({
|
|
183
|
-
isWeb,
|
|
184
|
-
enabledState,
|
|
185
|
-
touchable,
|
|
186
|
-
vertical,
|
|
187
|
-
count,
|
|
188
|
-
shouldLoop,
|
|
189
|
-
displayCount,
|
|
190
|
-
slideSizeValue,
|
|
191
|
-
nonLoopMinOffset,
|
|
192
|
-
nonLoopMaxOffset,
|
|
193
|
-
durationMs,
|
|
194
|
-
preventScroll,
|
|
195
|
-
trackOffsetPx,
|
|
196
|
-
swipeToRef,
|
|
197
|
-
onDragStart: () => onDragStartRef.current(),
|
|
198
|
-
onDragEnd: () => onDragEndRef.current()
|
|
199
|
-
});
|
|
200
|
-
(0, _react().useEffect)(() => {
|
|
201
|
-
return () => {
|
|
202
|
-
cancelWebRaf();
|
|
203
|
-
stopWebSnapAnim();
|
|
204
|
-
clearNativeScrollEndTimer();
|
|
205
|
-
};
|
|
206
|
-
}, [cancelWebRaf, stopWebSnapAnim, clearNativeScrollEndTimer]);
|
|
207
|
-
const finishNativeScroll = (0, _react().useCallback)(() => {
|
|
208
|
-
clearNativeScrollEndTimer();
|
|
209
|
-
isScrollingRef.current = false;
|
|
210
|
-
nativeMomentumRef.current = false;
|
|
211
|
-
const queued = nativeQueuedScrollRef.current;
|
|
212
|
-
if (queued && flatListRef.current) {
|
|
213
|
-
nativeQueuedScrollRef.current = null;
|
|
214
|
-
const nextRealIndex = getDisplayIndex(queued.index);
|
|
215
|
-
(0, _utils.runAfterFrames)(1, () => {
|
|
216
|
-
swipeToRef.current(nextRealIndex, queued.animated);
|
|
125
|
+
const updateIndex = (0, _react().useCallback)(next => {
|
|
126
|
+
const clamped = (0, _number.clamp)(next, 0, Math.max(0, count - 1));
|
|
127
|
+
if (currentIndexRef.current === clamped) return;
|
|
128
|
+
currentIndexRef.current = clamped;
|
|
129
|
+
setCurrentIndex(clamped);
|
|
130
|
+
onChange?.(clamped);
|
|
131
|
+
}, [count, onChange]);
|
|
132
|
+
const scrollToDisplayIndex = (0, _react().useCallback)((displayIndex, animated) => {
|
|
133
|
+
try {
|
|
134
|
+
flatListRef.current?.scrollToIndex({
|
|
135
|
+
index: displayIndex,
|
|
136
|
+
animated
|
|
217
137
|
});
|
|
218
|
-
}
|
|
219
|
-
}, [
|
|
220
|
-
const scheduleNativeScrollFallback = (0, _react().useCallback)(() => {
|
|
221
|
-
clearNativeScrollEndTimer();
|
|
222
|
-
const seq = nativeScrollSeqRef.current + 1;
|
|
223
|
-
nativeScrollSeqRef.current = seq;
|
|
224
|
-
const timeout = Math.max(700, durationMs + 500);
|
|
225
|
-
nativeScrollEndTimerRef.current = setTimeout(() => {
|
|
226
|
-
if (nativeScrollSeqRef.current !== seq) return;
|
|
227
|
-
if (isDraggingRef.current) return;
|
|
228
|
-
if (!isScrollingRef.current) return;
|
|
229
|
-
finishNativeScroll();
|
|
230
|
-
}, timeout);
|
|
231
|
-
}, [clearNativeScrollEndTimer, durationMs, finishNativeScroll]);
|
|
232
|
-
(0, _react().useEffect)(() => {
|
|
233
|
-
setEnabledState(enabled);
|
|
234
|
-
}, [enabled]);
|
|
235
|
-
const currentRef = (0, _react().useRef)(current);
|
|
236
|
-
(0, _react().useEffect)(() => {
|
|
237
|
-
currentRef.current = current;
|
|
238
|
-
desiredIndexRef.current = getDisplayIndex(current);
|
|
239
|
-
}, [current, getDisplayIndex]);
|
|
240
|
-
const handleItemLayout = (0, _react().useCallback)((displayIndex, e) => {
|
|
241
|
-
if (!autoHeightEnabled) return;
|
|
242
|
-
const height = e.nativeEvent.layout.height;
|
|
243
|
-
if (!height) return;
|
|
244
|
-
const realIndex = getDisplayIndex(displayIndex);
|
|
245
|
-
const prevHeight = measuredHeightsRef.current[realIndex];
|
|
246
|
-
if (prevHeight != null && Math.abs(prevHeight - height) < 0.5) return;
|
|
247
|
-
measuredHeightsRef.current[realIndex] = height;
|
|
248
|
-
const activeRealIndex = getDisplayIndex(currentRef.current);
|
|
249
|
-
if (realIndex === activeRealIndex) {
|
|
250
|
-
setAutoHeightValue(height);
|
|
251
|
-
}
|
|
252
|
-
}, [autoHeightEnabled, getDisplayIndex]);
|
|
253
|
-
(0, _react().useEffect)(() => {
|
|
254
|
-
if (!autoHeightEnabled) return;
|
|
255
|
-
measuredHeightsRef.current = {};
|
|
256
|
-
setAutoHeightValue(undefined);
|
|
257
|
-
}, [autoHeightEnabled, slideSizeValue, count]);
|
|
258
|
-
(0, _react().useEffect)(() => {
|
|
259
|
-
if (!autoHeightEnabled) return;
|
|
260
|
-
const activeRealIndex = getDisplayIndex(current);
|
|
261
|
-
const height = measuredHeightsRef.current[activeRealIndex];
|
|
262
|
-
if (height == null) return;
|
|
263
|
-
setAutoHeightValue(height);
|
|
264
|
-
}, [autoHeightEnabled, current, getDisplayIndex]);
|
|
265
|
-
const containerAutoHeightStyle = autoHeightEnabled && autoHeightValue != null ? {
|
|
266
|
-
height: autoHeightValue
|
|
267
|
-
} : undefined;
|
|
268
|
-
const nativeLastAlignedMainAxisRef = (0, _react().useRef)(0);
|
|
269
|
-
(0, _react().useEffect)(() => {
|
|
270
|
-
if (isWeb) return;
|
|
271
|
-
if (count === 0) return;
|
|
272
|
-
if (!flatListRef.current) return;
|
|
273
|
-
if (isDraggingRef.current || isScrollingRef.current) return;
|
|
274
|
-
const mainAxisMeasured = vertical ? containerLayout.height : containerLayout.width;
|
|
275
|
-
if (mainAxisMeasured <= 0) return;
|
|
276
|
-
const lastAligned = nativeLastAlignedMainAxisRef.current;
|
|
277
|
-
if (lastAligned > 0 && Math.abs(mainAxisMeasured - lastAligned) < 0.5) return;
|
|
278
|
-
nativeLastAlignedMainAxisRef.current = mainAxisMeasured;
|
|
279
|
-
(0, _utils.runAfterFrames)(2, () => {
|
|
280
|
-
scrollToIndexSafe(currentRef.current, false);
|
|
281
|
-
});
|
|
282
|
-
}, [isWeb, count, vertical, containerLayout.height, containerLayout.width]);
|
|
138
|
+
} catch {}
|
|
139
|
+
}, []);
|
|
283
140
|
const swipeTo = (0, _react().useCallback)((index, animated = true) => {
|
|
284
141
|
if (count === 0) return;
|
|
142
|
+
if (animated && isAnimatingRef.current) {
|
|
143
|
+
queuedIndexRef.current = index;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
285
146
|
const targetRealIndex = (0, _number.clamp)(index, 0, count - 1);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
let jumpDisplayIndex = null;
|
|
293
|
-
if (shouldLoop) {
|
|
294
|
-
if (fromRealIndex === count - 1 && targetRealIndex === 0) {
|
|
295
|
-
targetIndex = displayCount - 1;
|
|
296
|
-
needsJump = true;
|
|
297
|
-
jumpOffset = -1 * slideSizeValue;
|
|
298
|
-
jumpDisplayIndex = 1;
|
|
299
|
-
} else if (fromRealIndex === 0 && targetRealIndex === count - 1) {
|
|
300
|
-
targetIndex = 0;
|
|
301
|
-
needsJump = true;
|
|
302
|
-
jumpOffset = -count * slideSizeValue;
|
|
303
|
-
jumpDisplayIndex = count;
|
|
304
|
-
} else {
|
|
305
|
-
targetIndex = targetRealIndex + 1;
|
|
147
|
+
let targetDisplayIndex = getDisplayIndex(targetRealIndex);
|
|
148
|
+
let resolvedAnimated = animated;
|
|
149
|
+
if (isWeb && shouldLoop && animated) {
|
|
150
|
+
const currentRealIndex = currentIndexRef.current;
|
|
151
|
+
if (currentRealIndex === count - 1 && targetRealIndex === 0 || currentRealIndex === 0 && targetRealIndex === count - 1) {
|
|
152
|
+
resolvedAnimated = false;
|
|
306
153
|
}
|
|
307
|
-
} else {
|
|
308
|
-
targetIndex = targetRealIndex;
|
|
309
154
|
}
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const offset = shouldLoop ? -targetIndex * slideSizeValue : -1 * (nonLoopSnapOffsets?.[targetIndex] ?? slideSizeValue * targetIndex);
|
|
317
|
-
webOffsetRef.current = offset;
|
|
318
|
-
if (needsJump) {
|
|
319
|
-
if (animated) {
|
|
320
|
-
const animValue = vertical ? webTranslateYAnim : webTranslateXAnim;
|
|
321
|
-
const anim = _reactNative().Animated.timing(animValue, {
|
|
322
|
-
toValue: offset,
|
|
323
|
-
duration: durationMs,
|
|
324
|
-
easing: _reactNative().Easing.out(_reactNative().Easing.cubic),
|
|
325
|
-
useNativeDriver: false
|
|
326
|
-
});
|
|
327
|
-
webSnapAnimRef.current = anim;
|
|
328
|
-
anim.start(({
|
|
329
|
-
finished
|
|
330
|
-
}) => {
|
|
331
|
-
webSnapAnimRef.current = null;
|
|
332
|
-
if (autoplay && enabledState) startAutoplay();
|
|
333
|
-
if (!finished || jumpOffset === null || jumpDisplayIndex === null) return;
|
|
334
|
-
webOffsetRef.current = jumpOffset;
|
|
335
|
-
if (vertical) {
|
|
336
|
-
webTranslateYAnim.setValue(jumpOffset);
|
|
337
|
-
} else {
|
|
338
|
-
webTranslateXAnim.setValue(jumpOffset);
|
|
339
|
-
}
|
|
340
|
-
setCurrentSafe(jumpDisplayIndex);
|
|
341
|
-
});
|
|
342
|
-
setCurrentSafe(targetIndex);
|
|
343
|
-
} else {
|
|
344
|
-
if (vertical) {
|
|
345
|
-
webTranslateYAnim.setValue(jumpOffset);
|
|
346
|
-
} else {
|
|
347
|
-
webTranslateXAnim.setValue(jumpOffset);
|
|
348
|
-
}
|
|
349
|
-
webOffsetRef.current = jumpOffset;
|
|
350
|
-
setCurrentSafe(jumpDisplayIndex);
|
|
351
|
-
if (autoplay && enabledState) startAutoplay();
|
|
352
|
-
}
|
|
353
|
-
} else {
|
|
354
|
-
const animValue = vertical ? webTranslateYAnim : webTranslateXAnim;
|
|
355
|
-
if (animated) {
|
|
356
|
-
const anim = _reactNative().Animated.timing(animValue, {
|
|
357
|
-
toValue: offset,
|
|
358
|
-
duration: durationMs,
|
|
359
|
-
easing: _reactNative().Easing.out(_reactNative().Easing.cubic),
|
|
360
|
-
useNativeDriver: false
|
|
361
|
-
});
|
|
362
|
-
webSnapAnimRef.current = anim;
|
|
363
|
-
anim.start(() => {
|
|
364
|
-
webSnapAnimRef.current = null;
|
|
365
|
-
if (autoplay && enabledState) startAutoplay();
|
|
366
|
-
});
|
|
367
|
-
} else {
|
|
368
|
-
animValue.setValue(offset);
|
|
369
|
-
if (autoplay && enabledState) startAutoplay();
|
|
370
|
-
}
|
|
371
|
-
setCurrentSafe(targetIndex);
|
|
155
|
+
if (shouldLoop && resolvedAnimated) {
|
|
156
|
+
const currentDisplayIndex = getDisplayIndex(currentIndexRef.current);
|
|
157
|
+
if (currentDisplayIndex === count && targetRealIndex === 0) {
|
|
158
|
+
targetDisplayIndex = displayCount - 1;
|
|
159
|
+
} else if (currentDisplayIndex === 1 && targetRealIndex === count - 1) {
|
|
160
|
+
targetDisplayIndex = 0;
|
|
372
161
|
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
index: targetIndex,
|
|
382
|
-
animated
|
|
383
|
-
};
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
if (isScrollingRef.current && animated) {
|
|
387
|
-
nativeQueuedScrollRef.current = {
|
|
388
|
-
index: targetIndex,
|
|
389
|
-
animated
|
|
390
|
-
};
|
|
391
|
-
scheduleNativeScrollFallback();
|
|
392
|
-
scrollToIndexSafe(targetIndex, true);
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
isScrollingRef.current = true;
|
|
396
|
-
if (animated) {
|
|
397
|
-
scheduleNativeScrollFallback();
|
|
398
|
-
} else {
|
|
399
|
-
clearNativeScrollEndTimer();
|
|
400
|
-
}
|
|
401
|
-
scrollToIndexSafe(targetIndex, animated);
|
|
402
|
-
if (!animated) {
|
|
403
|
-
setCurrentSafe(targetIndex);
|
|
404
|
-
if (autoplay && enabledState) startAutoplay();
|
|
405
|
-
}
|
|
406
|
-
if (needsJump && jumpDisplayIndex != null && !animated) {
|
|
407
|
-
(0, _utils.runAfterFrames)(2, () => {
|
|
408
|
-
flatListRef.current?.scrollToIndex({
|
|
409
|
-
index: jumpDisplayIndex,
|
|
410
|
-
animated: false
|
|
411
|
-
});
|
|
412
|
-
setCurrentSafe(jumpDisplayIndex);
|
|
413
|
-
});
|
|
162
|
+
}
|
|
163
|
+
const currentRealIndex = currentIndexRef.current;
|
|
164
|
+
const currentDisplayIndex = getDisplayIndex(currentRealIndex);
|
|
165
|
+
if (targetRealIndex === currentRealIndex && targetDisplayIndex === currentDisplayIndex) {
|
|
166
|
+
if (queuedIndexRef.current != null) {
|
|
167
|
+
const next = queuedIndexRef.current;
|
|
168
|
+
queuedIndexRef.current = null;
|
|
169
|
+
swipeTo(next, true);
|
|
414
170
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (resolvedAnimated) {
|
|
174
|
+
isAnimatingRef.current = true;
|
|
175
|
+
}
|
|
176
|
+
scrollToDisplayIndex(targetDisplayIndex, resolvedAnimated);
|
|
177
|
+
if (!resolvedAnimated) {
|
|
178
|
+
updateIndex(targetRealIndex);
|
|
179
|
+
if (queuedIndexRef.current != null) {
|
|
180
|
+
const next = queuedIndexRef.current;
|
|
181
|
+
queuedIndexRef.current = null;
|
|
182
|
+
swipeTo(next, true);
|
|
419
183
|
}
|
|
420
184
|
}
|
|
421
|
-
}, [count,
|
|
422
|
-
(0, _react().
|
|
423
|
-
|
|
424
|
-
|
|
185
|
+
}, [count, getDisplayIndex, scrollToDisplayIndex, shouldLoop, displayCount, updateIndex, isWeb]);
|
|
186
|
+
const resolveAutoplayInterval = (0, _react().useCallback)(() => {
|
|
187
|
+
if (typeof autoplay === 'number') return Math.max(0, autoplay);
|
|
188
|
+
if (autoplay) return DEFAULT_AUTOPLAY_INTERVAL;
|
|
189
|
+
return 0;
|
|
190
|
+
}, [autoplay]);
|
|
191
|
+
const scheduleAutoplay = (0, _react().useCallback)(() => {
|
|
192
|
+
const interval = resolveAutoplayInterval();
|
|
193
|
+
if (!interval || count <= 1) return;
|
|
194
|
+
if (isInteractingRef.current && !isWeb) return;
|
|
195
|
+
clearAutoplay();
|
|
196
|
+
autoplayTimerRef.current = setTimeout(() => {
|
|
197
|
+
if (isInteractingRef.current && !isWeb) return;
|
|
198
|
+
const nextIndex = shouldLoop ? (currentIndexRef.current + 1) % count : (0, _number.clamp)(currentIndexRef.current + 1, 0, count - 1);
|
|
199
|
+
swipeTo(nextIndex, true);
|
|
200
|
+
}, interval);
|
|
201
|
+
}, [resolveAutoplayInterval, count, clearAutoplay, shouldLoop, swipeTo]);
|
|
425
202
|
const swipeNext = (0, _react().useCallback)(() => {
|
|
426
203
|
if (count === 0) return;
|
|
427
|
-
const
|
|
428
|
-
swipeTo(
|
|
429
|
-
}, [count, swipeTo]);
|
|
204
|
+
const next = shouldLoop ? (currentIndexRef.current + 1) % count : (0, _number.clamp)(currentIndexRef.current + 1, 0, count - 1);
|
|
205
|
+
swipeTo(next, true);
|
|
206
|
+
}, [count, shouldLoop, swipeTo]);
|
|
430
207
|
const swipePrev = (0, _react().useCallback)(() => {
|
|
431
208
|
if (count === 0) return;
|
|
432
|
-
const
|
|
433
|
-
swipeTo(
|
|
434
|
-
}, [count, swipeTo]);
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
isScrollingRef.current = false;
|
|
456
|
-
nativeMomentumRef.current = false;
|
|
457
|
-
if (!slideSizeValue) return;
|
|
458
|
-
let index = Math.round(offset / slideSizeValue);
|
|
459
|
-
if (shouldLoop) {
|
|
460
|
-
if (index === 0) {
|
|
461
|
-
(0, _utils.runAfterFrames)(2, () => {
|
|
462
|
-
flatListRef.current?.scrollToIndex({
|
|
463
|
-
index: count,
|
|
464
|
-
animated: false
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
index = count;
|
|
468
|
-
} else if (index === displayCount - 1) {
|
|
469
|
-
(0, _utils.runAfterFrames)(2, () => {
|
|
470
|
-
flatListRef.current?.scrollToIndex({
|
|
471
|
-
index: 1,
|
|
472
|
-
animated: false
|
|
473
|
-
});
|
|
474
|
-
});
|
|
475
|
-
index = 1;
|
|
476
|
-
}
|
|
477
|
-
} else {
|
|
478
|
-
index = (0, _number.clamp)(index, 0, count - 1);
|
|
479
|
-
}
|
|
480
|
-
setCurrentSafe(index);
|
|
481
|
-
desiredIndexRef.current = getDisplayIndex(index);
|
|
482
|
-
const queued = nativeQueuedScrollRef.current;
|
|
483
|
-
if (queued && flatListRef.current) {
|
|
484
|
-
nativeQueuedScrollRef.current = null;
|
|
485
|
-
const nextDisplayIndex = getDisplayIndex(queued.index);
|
|
486
|
-
(0, _utils.runAfterFrames)(1, () => {
|
|
487
|
-
swipeTo(nextDisplayIndex, queued.animated);
|
|
488
|
-
});
|
|
489
|
-
} else if (autoplay && enabledState) {
|
|
490
|
-
startAutoplay();
|
|
491
|
-
}
|
|
492
|
-
}, [clearNativeScrollEndTimer, count, displayCount, getDisplayIndex, setCurrentSafe, shouldLoop, slideSizeValue, swipeTo, autoplay, enabledState, startAutoplay]);
|
|
493
|
-
const handleScrollEnd = (0, _react().useCallback)(event => {
|
|
494
|
-
if (count === 0) return;
|
|
495
|
-
const {
|
|
496
|
-
contentOffset
|
|
497
|
-
} = event.nativeEvent;
|
|
498
|
-
handleNativeScrollEndByOffset(vertical ? contentOffset.y : contentOffset.x);
|
|
499
|
-
}, [count, handleNativeScrollEndByOffset, vertical]);
|
|
209
|
+
const next = shouldLoop ? (currentIndexRef.current - 1 + count) % count : (0, _number.clamp)(currentIndexRef.current - 1, 0, count - 1);
|
|
210
|
+
swipeTo(next, true);
|
|
211
|
+
}, [count, shouldLoop, swipeTo]);
|
|
212
|
+
const flushQueuedSwipe = () => {
|
|
213
|
+
if (queuedIndexRef.current == null) return;
|
|
214
|
+
const next = queuedIndexRef.current;
|
|
215
|
+
queuedIndexRef.current = null;
|
|
216
|
+
swipeTo(next, true);
|
|
217
|
+
};
|
|
218
|
+
(0, _react().useImperativeHandle)(ref, () => ({
|
|
219
|
+
swipeTo,
|
|
220
|
+
swipeNext,
|
|
221
|
+
swipePrev,
|
|
222
|
+
getCurrentIndex: () => currentIndexRef.current
|
|
223
|
+
}), [swipeTo, swipeNext, swipePrev]);
|
|
224
|
+
(0, _react().useEffect)(() => {
|
|
225
|
+
if (!layoutReady || count === 0) return;
|
|
226
|
+
scrollToDisplayIndex(initialDisplayIndex, false);
|
|
227
|
+
}, [layoutReady, count, initialDisplayIndex, scrollToDisplayIndex]);
|
|
228
|
+
(0, _react().useEffect)(() => {
|
|
229
|
+
scheduleAutoplay();
|
|
230
|
+
return clearAutoplay;
|
|
231
|
+
}, [scheduleAutoplay, clearAutoplay, currentIndex]);
|
|
500
232
|
const handleScrollBeginDrag = () => {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
stopAutoplay();
|
|
233
|
+
isInteractingRef.current = true;
|
|
234
|
+
clearAutoplay();
|
|
504
235
|
};
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
236
|
+
const handleScroll = event => {
|
|
237
|
+
if (!isWeb || count <= 1) return;
|
|
238
|
+
const offset = vertical ? event.nativeEvent.contentOffset.y : event.nativeEvent.contentOffset.x;
|
|
239
|
+
const displayIndex = Math.round(offset / mainSize);
|
|
240
|
+
const nextDisplayIndex = shouldLoop ? (0, _number.clamp)(displayIndex, 0, displayCount - 1) : (0, _number.clamp)(displayIndex, 0, count - 1);
|
|
241
|
+
updateIndex(getRealIndex(nextDisplayIndex));
|
|
242
|
+
const alignedOffset = Math.round(offset / mainSize) * mainSize;
|
|
243
|
+
if (Math.abs(offset - alignedOffset) < 0.5) {
|
|
244
|
+
isAnimatingRef.current = false;
|
|
245
|
+
isInteractingRef.current = false;
|
|
246
|
+
isMomentumRef.current = false;
|
|
247
|
+
scheduleAutoplay();
|
|
248
|
+
flushQueuedSwipe();
|
|
249
|
+
}
|
|
514
250
|
};
|
|
515
251
|
const handleMomentumScrollBegin = () => {
|
|
516
|
-
|
|
517
|
-
isScrollingRef.current = true;
|
|
252
|
+
isMomentumRef.current = true;
|
|
518
253
|
};
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
const flushIndicator = () => {
|
|
523
|
-
const next = indicatorPendingRef.current;
|
|
524
|
-
if (next == null) return;
|
|
525
|
-
indicatorPendingRef.current = null;
|
|
526
|
-
setIndicatorIndex(prev => prev === next ? prev : next);
|
|
254
|
+
const handleScrollEndDrag = event => {
|
|
255
|
+
if (isMomentumRef.current) return;
|
|
256
|
+
handleScrollEnd(event);
|
|
527
257
|
};
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
return;
|
|
258
|
+
const handleScrollEnd = event => {
|
|
259
|
+
if (count === 0) return;
|
|
260
|
+
const offset = vertical ? event.nativeEvent.contentOffset.y : event.nativeEvent.contentOffset.x;
|
|
261
|
+
const displayIndex = Math.round(offset / mainSize);
|
|
262
|
+
let nextDisplayIndex = displayIndex;
|
|
263
|
+
if (shouldLoop) {
|
|
264
|
+
if (displayIndex === 0) nextDisplayIndex = count;
|
|
265
|
+
if (displayIndex === displayCount - 1) nextDisplayIndex = 1;
|
|
537
266
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
flushIndicator();
|
|
541
|
-
}, 16);
|
|
542
|
-
};
|
|
543
|
-
(0, _react().useEffect)(() => {
|
|
544
|
-
setIndicatorIndex(prev => {
|
|
545
|
-
const next = getDisplayIndex(current);
|
|
546
|
-
return prev === next ? prev : next;
|
|
547
|
-
});
|
|
548
|
-
}, [current, getDisplayIndex]);
|
|
549
|
-
(0, _react().useEffect)(() => {
|
|
550
|
-
return () => {
|
|
551
|
-
if (indicatorRafIdRef.current != null) {
|
|
552
|
-
if (canUseRaf) {
|
|
553
|
-
cancelAnimationFrame(indicatorRafIdRef.current);
|
|
554
|
-
} else {
|
|
555
|
-
clearTimeout(indicatorRafIdRef.current);
|
|
556
|
-
}
|
|
557
|
-
indicatorRafIdRef.current = null;
|
|
558
|
-
}
|
|
559
|
-
indicatorPendingRef.current = null;
|
|
560
|
-
};
|
|
561
|
-
}, []);
|
|
562
|
-
const handleScroll = (0, _react().useCallback)(event => {
|
|
563
|
-
if (isWeb || count <= 1 || !slideSizeValue) return;
|
|
564
|
-
const {
|
|
565
|
-
contentOffset
|
|
566
|
-
} = event.nativeEvent;
|
|
567
|
-
const offset = vertical ? contentOffset.y : contentOffset.x;
|
|
568
|
-
const displayIndex = shouldLoop ? (0, _number.clamp)(Math.round(offset / slideSizeValue), 0, displayCount - 1) : (0, _number.clamp)(Math.round(offset / slideSizeValue), 0, count - 1);
|
|
569
|
-
scheduleIndicator(getDisplayIndex(displayIndex));
|
|
570
|
-
}, [count, displayCount, getDisplayIndex, isWeb, scheduleIndicator, shouldLoop, slideSizeValue, vertical]);
|
|
571
|
-
(0, _react().useEffect)(() => {
|
|
572
|
-
onDragStartRef.current = () => {
|
|
573
|
-
isDraggingRef.current = true;
|
|
574
|
-
stopAutoplay();
|
|
575
|
-
};
|
|
576
|
-
onDragEndRef.current = () => {
|
|
577
|
-
isDraggingRef.current = false;
|
|
578
|
-
};
|
|
579
|
-
}, [stopAutoplay]);
|
|
580
|
-
(0, _react().useEffect)(() => {
|
|
581
|
-
startAutoplay();
|
|
582
|
-
return stopAutoplay;
|
|
583
|
-
}, [startAutoplay, stopAutoplay]);
|
|
584
|
-
(0, _react().useImperativeHandle)(ref, () => ({
|
|
585
|
-
activeIndex: getDisplayIndex(current),
|
|
586
|
-
swipeTo: (index, animated = true) => {
|
|
587
|
-
swipeTo(index, animated);
|
|
588
|
-
},
|
|
589
|
-
swipeNext,
|
|
590
|
-
swipePrev,
|
|
591
|
-
enable: () => {
|
|
592
|
-
setEnabledState(true);
|
|
593
|
-
},
|
|
594
|
-
disable: () => {
|
|
595
|
-
setEnabledState(false);
|
|
596
|
-
},
|
|
597
|
-
getCurrentIndex: () => getDisplayIndex(current),
|
|
598
|
-
getPrevIndex: () => prevIndexRef.current,
|
|
599
|
-
goToFirstIndex: () => {
|
|
600
|
-
swipeTo(0);
|
|
601
|
-
},
|
|
602
|
-
goToLastIndex: () => {
|
|
603
|
-
swipeTo(count - 1);
|
|
267
|
+
if (nextDisplayIndex !== displayIndex) {
|
|
268
|
+
scrollToDisplayIndex(nextDisplayIndex, false);
|
|
604
269
|
}
|
|
605
|
-
|
|
270
|
+
updateIndex(getRealIndex(nextDisplayIndex));
|
|
271
|
+
isInteractingRef.current = false;
|
|
272
|
+
isAnimatingRef.current = false;
|
|
273
|
+
isMomentumRef.current = false;
|
|
274
|
+
scheduleAutoplay();
|
|
275
|
+
flushQueuedSwipe();
|
|
276
|
+
};
|
|
606
277
|
const renderIndicator = () => {
|
|
607
278
|
if (indicator === false || count <= 1) return null;
|
|
608
|
-
if (typeof indicator === 'function') return indicator(count,
|
|
279
|
+
if (typeof indicator === 'function') return indicator(count, currentIndex);
|
|
609
280
|
return /*#__PURE__*/_react().default.createElement(_SwiperPagIndicator.default, _extends({}, indicatorProps, {
|
|
610
281
|
total: count,
|
|
611
|
-
current:
|
|
282
|
+
current: currentIndex,
|
|
612
283
|
vertical: vertical
|
|
613
284
|
}));
|
|
614
285
|
};
|
|
615
|
-
(0, _react().
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
if (nextDisplay === currentDisplayIndexRef.current) return;
|
|
619
|
-
prevIndexRef.current = currentDisplayIndexRef.current;
|
|
620
|
-
currentDisplayIndexRef.current = nextDisplay;
|
|
621
|
-
onChange(nextDisplay);
|
|
622
|
-
}, [current, onChange, count, getDisplayIndex]);
|
|
623
|
-
const renderChildItem = (0, _react().useCallback)(({
|
|
624
|
-
item,
|
|
625
|
-
index
|
|
626
|
-
}) => {
|
|
627
|
-
const marker = item;
|
|
628
|
-
if (marker.type !== 'child') return null;
|
|
629
|
-
const childIndex = typeof marker.index === 'number' ? marker.index : -1;
|
|
630
|
-
const child = validChildren[childIndex];
|
|
631
|
-
if (!child) return null;
|
|
632
|
-
if (!autoHeightEnabled) {
|
|
633
|
-
const element = child;
|
|
634
|
-
return /*#__PURE__*/(0, _react().cloneElement)(element, {
|
|
635
|
-
style: [element.props.style, itemSizeStyle]
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
const element = child;
|
|
639
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
640
|
-
style: itemSizeStyle,
|
|
641
|
-
onLayout: e => handleItemLayout(index, e),
|
|
642
|
-
collapsable: false
|
|
643
|
-
}, /*#__PURE__*/(0, _react().cloneElement)(element, {
|
|
644
|
-
style: [element.props.style, styles.autoHeightChild]
|
|
645
|
-
}));
|
|
646
|
-
}, [validChildren, itemSizeStyle, autoHeightEnabled, handleItemLayout]);
|
|
647
|
-
const renderDataItem = (0, _react().useCallback)(info => {
|
|
648
|
-
if (!renderItem) return null;
|
|
649
|
-
const item = renderItem(info);
|
|
650
|
-
if (!item) return null;
|
|
651
|
-
const itemIndex = info.index;
|
|
652
|
-
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
653
|
-
style: itemSizeStyle,
|
|
654
|
-
onLayout: autoHeightEnabled ? e => handleItemLayout(itemIndex, e) : undefined,
|
|
655
|
-
collapsable: false
|
|
656
|
-
}, item);
|
|
657
|
-
}, [renderItem, itemSizeStyle, autoHeightEnabled, handleItemLayout]);
|
|
658
|
-
const getItemKey = (0, _react().useCallback)((_item, index) => {
|
|
659
|
-
if (shouldLoop && count > 1) {
|
|
660
|
-
if (index === 0) return `loop-last-${count - 1}`;
|
|
661
|
-
if (index === displayCount - 1) return `loop-first-0`;
|
|
662
|
-
return `item-${index - 1}`;
|
|
663
|
-
}
|
|
664
|
-
return `item-${index}`;
|
|
665
|
-
}, [shouldLoop, count, displayCount]);
|
|
666
|
-
const getItemLayout = (0, _react().useCallback)((_, index) => {
|
|
667
|
-
const offset = !shouldLoop && nonLoopSnapOffsets ? nonLoopSnapOffsets[index] ?? slideSizeValue * index : slideSizeValue * index;
|
|
668
|
-
return {
|
|
669
|
-
length: slideSizeValue,
|
|
670
|
-
offset,
|
|
671
|
-
index
|
|
672
|
-
};
|
|
673
|
-
}, [nonLoopSnapOffsets, shouldLoop, slideSizeValue]);
|
|
674
|
-
const snapToOffsets = (() => {
|
|
675
|
-
if (slideSizePct === 100 && trackOffsetPct === 0) return undefined;
|
|
676
|
-
if (!shouldLoop && nonLoopSnapOffsets) return nonLoopSnapOffsets;
|
|
677
|
-
return displayData.map((_, index) => slideSizeValue * index);
|
|
678
|
-
})();
|
|
679
|
-
(0, _react().useEffect)(() => {
|
|
680
|
-
if (!isWeb) return;
|
|
681
|
-
const initialIndex = getInitialIndex();
|
|
682
|
-
const initialOffset = shouldLoop ? -initialIndex * slideSizeValue : -1 * (nonLoopSnapOffsets?.[initialIndex] ?? slideSizeValue * initialIndex);
|
|
683
|
-
webOffsetRef.current = initialOffset;
|
|
684
|
-
if (vertical) webTranslateYAnim.setValue(initialOffset);else webTranslateXAnim.setValue(initialOffset);
|
|
685
|
-
}, [isWeb, getInitialIndex, nonLoopSnapOffsets, shouldLoop, slideSizeValue, vertical, webTranslateXAnim, webTranslateYAnim]);
|
|
686
|
-
(0, _react().useEffect)(() => {
|
|
687
|
-
if (!isWeb || count === 0) return;
|
|
688
|
-
const offset = shouldLoop ? -currentRef.current * slideSizeValue : -1 * (nonLoopSnapOffsets?.[currentRef.current] ?? slideSizeValue * currentRef.current);
|
|
689
|
-
webOffsetRef.current = offset;
|
|
690
|
-
if (vertical) webTranslateYAnim.setValue(offset);else webTranslateXAnim.setValue(offset);
|
|
691
|
-
}, [isWeb, count, nonLoopSnapOffsets, shouldLoop, slideSizeValue, vertical, webTranslateXAnim, webTranslateYAnim]);
|
|
692
|
-
if (count === 0) {
|
|
693
|
-
return null;
|
|
694
|
-
}
|
|
695
|
-
if (isWeb) {
|
|
286
|
+
const renderSlide = (0, _react().useCallback)(info => {
|
|
287
|
+
const content = usingData ? renderItem?.(info) ?? null : info.item;
|
|
288
|
+
if (!content) return null;
|
|
696
289
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
697
|
-
style: [styles.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
style: {
|
|
702
|
-
overflow: 'hidden',
|
|
703
|
-
width: '100%',
|
|
704
|
-
height: '100%'
|
|
705
|
-
}
|
|
706
|
-
}, /*#__PURE__*/_react().default.createElement(_reactNative().Animated.View, _extends({}, panResponder?.panHandlers || {}, {
|
|
707
|
-
style: [{
|
|
708
|
-
flexDirection: vertical ? 'column' : 'row',
|
|
709
|
-
width: vertical ? '100%' : displayCount * slideSizeValue,
|
|
710
|
-
height: vertical ? displayCount * slideSizeValue : '100%',
|
|
711
|
-
transform: webTrackTransform
|
|
712
|
-
}]
|
|
713
|
-
}), displayData.map((item, index) => /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
714
|
-
key: getItemKey(item, index),
|
|
715
|
-
style: [itemSizeStyle, styles.webSlideWrapper]
|
|
716
|
-
}, data && renderDataItem({
|
|
717
|
-
item,
|
|
718
|
-
index
|
|
719
|
-
}) || renderChildItem({
|
|
720
|
-
item,
|
|
721
|
-
index
|
|
722
|
-
}))))), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
723
|
-
pointerEvents: "none",
|
|
724
|
-
style: styles.indicatorOverlay
|
|
725
|
-
}, renderIndicator()));
|
|
726
|
-
}
|
|
290
|
+
style: [styles.slide, itemStyle]
|
|
291
|
+
}, content);
|
|
292
|
+
}, [usingData, renderItem, itemStyle]);
|
|
293
|
+
if (count === 0) return null;
|
|
727
294
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
728
|
-
style: [styles.container,
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
collapsable: false
|
|
295
|
+
style: [styles.container, style],
|
|
296
|
+
onLayout: handleLayout,
|
|
297
|
+
testID: testID
|
|
732
298
|
}, /*#__PURE__*/_react().default.createElement(_reactNative().FlatList, {
|
|
733
299
|
ref: flatListRef,
|
|
734
300
|
data: displayData,
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
getItemLayout: getItemLayout,
|
|
301
|
+
renderItem: renderSlide,
|
|
302
|
+
keyExtractor: (_item, index) => `swiper-${index}`,
|
|
738
303
|
horizontal: !vertical,
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
304
|
+
getItemLayout: (_, index) => ({
|
|
305
|
+
length: mainSize,
|
|
306
|
+
offset: mainSize * index,
|
|
307
|
+
index
|
|
308
|
+
}),
|
|
309
|
+
initialScrollIndex: layoutReady ? initialDisplayIndex : undefined,
|
|
310
|
+
scrollEnabled: touchable && count > 1,
|
|
311
|
+
removeClippedSubviews: !shouldLoop || !loopRenderAll,
|
|
312
|
+
disableVirtualization: shouldLoop && loopRenderAll,
|
|
313
|
+
initialNumToRender: shouldLoop ? loopRenderAll ? displayCount : 3 : 3,
|
|
314
|
+
maxToRenderPerBatch: shouldLoop ? loopRenderAll ? displayCount : 3 : 3,
|
|
315
|
+
windowSize: shouldLoop ? loopRenderAll ? displayCount : 7 : 5,
|
|
316
|
+
pagingEnabled: true,
|
|
317
|
+
snapToInterval: mainSize,
|
|
747
318
|
decelerationRate: "fast",
|
|
748
|
-
scrollEnabled: enabledState && touchable && count > 1,
|
|
749
|
-
pagingEnabled: false,
|
|
750
|
-
nestedScrollEnabled: preventScroll === false,
|
|
751
|
-
directionalLockEnabled: preventScroll !== false,
|
|
752
|
-
collapsable: false,
|
|
753
319
|
showsHorizontalScrollIndicator: false,
|
|
754
320
|
showsVerticalScrollIndicator: false,
|
|
755
|
-
bounces: rubberband && !shouldLoop,
|
|
756
|
-
scrollEventThrottle: 16,
|
|
757
321
|
onScrollBeginDrag: handleScrollBeginDrag,
|
|
322
|
+
onScroll: handleScroll,
|
|
323
|
+
scrollEventThrottle: 16,
|
|
758
324
|
onScrollEndDrag: handleScrollEndDrag,
|
|
759
325
|
onMomentumScrollBegin: handleMomentumScrollBegin,
|
|
760
326
|
onMomentumScrollEnd: handleScrollEnd,
|
|
761
|
-
onScroll: handleScroll,
|
|
762
|
-
initialScrollIndex: getInitialIndex(),
|
|
763
327
|
onScrollToIndexFailed: info => {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
} finally {
|
|
772
|
-
isScrollingRef.current = false;
|
|
773
|
-
const queued = nativeQueuedScrollRef.current;
|
|
774
|
-
if (queued && flatListRef.current) {
|
|
775
|
-
nativeQueuedScrollRef.current = null;
|
|
776
|
-
const nextDisplayIndex = getDisplayIndex(queued.index);
|
|
777
|
-
(0, _utils.runAfterFrames)(1, () => {
|
|
778
|
-
swipeTo(nextDisplayIndex, queued.animated);
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
},
|
|
784
|
-
style: isWeb && {
|
|
785
|
-
cursor: 'grab'
|
|
786
|
-
} || undefined,
|
|
787
|
-
contentContainerStyle: [isWeb && {
|
|
788
|
-
userSelect: 'none'
|
|
789
|
-
} || undefined, !isWeb && nativeTrackContentPaddingStyle || undefined],
|
|
790
|
-
testID: `${testID}-flatlist`
|
|
328
|
+
scrollToDisplayIndex(info.index, false);
|
|
329
|
+
isAnimatingRef.current = false;
|
|
330
|
+
isInteractingRef.current = false;
|
|
331
|
+
updateIndex(getRealIndex(info.index));
|
|
332
|
+
scheduleAutoplay();
|
|
333
|
+
flushQueuedSwipe();
|
|
334
|
+
}
|
|
791
335
|
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
792
336
|
pointerEvents: "none",
|
|
793
337
|
style: styles.indicatorOverlay
|
|
@@ -800,13 +344,11 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
800
344
|
position: 'relative',
|
|
801
345
|
overflow: 'hidden'
|
|
802
346
|
},
|
|
803
|
-
|
|
804
|
-
flex:
|
|
805
|
-
width: '100%'
|
|
347
|
+
slide: {
|
|
348
|
+
flex: 1
|
|
806
349
|
},
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
flexGrow: 0
|
|
350
|
+
item: {
|
|
351
|
+
flex: 1
|
|
810
352
|
},
|
|
811
353
|
indicatorOverlay: {
|
|
812
354
|
position: 'absolute',
|
|
@@ -814,13 +356,8 @@ const styles = _reactNative().StyleSheet.create({
|
|
|
814
356
|
right: 0,
|
|
815
357
|
top: 0,
|
|
816
358
|
bottom: 0,
|
|
817
|
-
zIndex:
|
|
818
|
-
elevation:
|
|
359
|
+
zIndex: 10,
|
|
360
|
+
elevation: 10
|
|
819
361
|
}
|
|
820
362
|
});
|
|
821
|
-
const webContainerStyle = _reactNative().Platform.OS === 'web' ? {
|
|
822
|
-
cursor: 'grab',
|
|
823
|
-
userSelect: 'none',
|
|
824
|
-
WebkitUserSelect: 'none'
|
|
825
|
-
} : undefined;
|
|
826
363
|
var _default = exports.default = Swiper;
|