react-native-system-ui 0.0.7 → 1.0.1
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 +46 -31
- package/dist/cjs/components/action-sheet/ActionSheet.js +128 -142
- package/dist/cjs/components/action-sheet/tokens.js +16 -27
- package/dist/cjs/components/area/Area.js +57 -70
- package/dist/cjs/components/area/tokens.js +6 -3
- package/dist/cjs/components/avatar/Avatar.js +38 -36
- package/dist/cjs/components/badge/Badge.js +68 -73
- package/dist/cjs/components/badge/tokens.js +6 -8
- package/dist/cjs/components/button/Button.js +135 -176
- package/dist/cjs/components/button/ButtonGroup.js +11 -45
- package/dist/cjs/components/button/tokens.js +1 -8
- package/dist/cjs/components/calendar/Calendar.js +212 -223
- package/dist/cjs/components/calendar/tokens.js +3 -3
- package/dist/cjs/components/cascader/Cascader.js +257 -267
- package/dist/cjs/components/cascader/tokens.js +2 -2
- package/dist/cjs/components/cascader/useCascaderExtend.js +25 -29
- package/dist/cjs/components/cell/Cell.js +94 -104
- package/dist/cjs/components/cell/CellGroup.js +37 -49
- package/dist/cjs/components/checkbox/Checkbox.js +140 -132
- package/dist/cjs/components/checkbox/CheckboxGroup.js +21 -51
- package/dist/cjs/components/checkbox/tokens.js +7 -10
- package/dist/cjs/components/circle/Circle.js +87 -74
- package/dist/cjs/components/collapse/Collapse.js +88 -104
- package/dist/cjs/components/config-provider/ConfigProvider.js +17 -4
- package/dist/cjs/components/config-provider/DirectionContext.js +15 -0
- package/dist/cjs/components/config-provider/index.js +7 -0
- package/dist/cjs/components/config-provider/locale/en-US.js +32 -0
- package/dist/cjs/components/config-provider/locale/zh-CN.js +32 -0
- package/dist/cjs/components/config-provider/useDirection.js +16 -0
- package/dist/cjs/components/count-down/CountDown.js +32 -27
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +80 -104
- package/dist/cjs/components/datetime-picker/tokens.js +14 -3
- package/dist/cjs/components/dialog/Dialog.js +159 -121
- package/dist/cjs/components/dialog/imperative.js +24 -43
- package/dist/cjs/components/dialog/tokens.js +1 -0
- package/dist/cjs/components/divider/Divider.js +57 -62
- package/dist/cjs/components/empty/Empty.js +53 -52
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +74 -0
- package/dist/cjs/components/error-boundary/index.js +19 -0
- package/dist/cjs/components/field/Field.js +109 -106
- package/dist/cjs/components/flex/Flex.js +32 -32
- package/dist/cjs/components/flex/FlexItem.js +27 -27
- package/dist/cjs/components/form/Form.js +178 -196
- package/dist/cjs/components/form/FormItem.js +87 -109
- package/dist/cjs/components/form/FormList.js +57 -45
- package/dist/cjs/components/form/tokens.js +6 -3
- package/dist/cjs/components/form/utils.js +15 -34
- package/dist/cjs/components/grid/Grid.js +44 -43
- package/dist/cjs/components/grid/GridItem.js +92 -86
- package/dist/cjs/components/image/Image.js +76 -79
- package/dist/cjs/components/image/tokens.js +5 -3
- package/dist/cjs/components/image-preview/ImagePreview.js +125 -113
- package/dist/cjs/components/image-preview/imperative.js +4 -13
- package/dist/cjs/components/image-preview/tokens.js +3 -1
- package/dist/cjs/components/index.js +13 -0
- package/dist/cjs/components/input/Input.js +40 -35
- package/dist/cjs/components/loading/Loading.js +32 -33
- package/dist/cjs/components/nav-bar/NavBar.js +88 -100
- package/dist/cjs/components/nav-bar/tokens.js +4 -10
- package/dist/cjs/components/notice-bar/NoticeBar.js +81 -80
- package/dist/cjs/components/notice-bar/tokens.js +3 -1
- package/dist/cjs/components/notify/Notify.js +89 -84
- package/dist/cjs/components/notify/imperative.js +32 -55
- package/dist/cjs/components/notify/tokens.js +2 -11
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +277 -283
- package/dist/cjs/components/number-keyboard/tokens.js +7 -1
- package/dist/cjs/components/overlay/Overlay.js +37 -52
- package/dist/cjs/components/overlay/tokens.js +5 -3
- package/dist/cjs/components/password-input/PasswordInput.js +114 -95
- package/dist/cjs/components/picker/Picker.js +465 -454
- package/dist/cjs/components/picker/tokens.js +1 -1
- package/dist/cjs/components/popup/Popup.js +269 -299
- package/dist/cjs/components/popup/tokens.js +1 -0
- package/dist/cjs/components/portal/Portal.js +12 -30
- package/dist/cjs/components/portal/PortalHost.js +151 -234
- package/dist/cjs/components/progress/Progress.js +103 -101
- package/dist/cjs/components/progress/tokens.js +1 -0
- package/dist/cjs/components/radio/Radio.js +98 -91
- package/dist/cjs/components/radio/RadioGroup.js +13 -45
- package/dist/cjs/components/radio/tokens.js +7 -10
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +22 -26
- package/dist/cjs/components/search/Search.js +65 -57
- package/dist/cjs/components/selector/Selector.js +21 -27
- package/dist/cjs/components/share-sheet/ShareSheet.js +165 -161
- package/dist/cjs/components/share-sheet/tokens.js +3 -1
- package/dist/cjs/components/sidebar/Sidebar.js +51 -51
- package/dist/cjs/components/sidebar/SidebarContext.js +1 -2
- package/dist/cjs/components/sidebar/SidebarItem.js +19 -21
- package/dist/cjs/components/sidebar/tokens.js +4 -4
- package/dist/cjs/components/skeleton/Skeleton.js +71 -77
- package/dist/cjs/components/skeleton/tokens.js +1 -2
- package/dist/cjs/components/slider/Slider.js +156 -135
- package/dist/cjs/components/space/Space.js +57 -76
- package/dist/cjs/components/space/tokens.js +7 -1
- package/dist/cjs/components/stepper/Stepper.js +182 -158
- package/dist/cjs/components/stepper/tokens.js +1 -0
- package/dist/cjs/components/swiper/Swiper.js +256 -255
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +26 -27
- package/dist/cjs/components/swiper/tokens.js +10 -3
- package/dist/cjs/components/switch/Switch.js +23 -25
- package/dist/cjs/components/tabbar/Tabbar.js +48 -40
- package/dist/cjs/components/tabbar/TabbarContext.js +1 -2
- package/dist/cjs/components/tabbar/TabbarItem.js +65 -68
- package/dist/cjs/components/tabs/Tabs.js +402 -439
- package/dist/cjs/components/tabs/tokens.js +3 -1
- package/dist/cjs/components/tag/Tag.js +68 -59
- package/dist/cjs/components/toast/Toast.js +91 -90
- package/dist/cjs/components/toast/imperative.js +16 -41
- package/dist/cjs/components/toast/tokens.js +1 -0
- package/dist/cjs/components/typography/Typography.js +25 -25
- package/dist/cjs/components/water-mark/WaterMark.js +80 -78
- package/dist/cjs/design-system/Text.js +38 -0
- package/dist/cjs/design-system/ThemeProvider.js +5 -11
- package/dist/cjs/design-system/createComponentTokensHook.js +11 -13
- package/dist/cjs/design-system/index.js +7 -0
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
- package/dist/cjs/design-system/presets.js +2 -3
- package/dist/cjs/design-system/tokens.js +2 -11
- package/dist/cjs/hooks/animation/index.js +25 -0
- package/dist/cjs/hooks/animation/useAnimatedTransition.js +72 -0
- package/dist/cjs/hooks/animation/useReducedMotion.js +75 -0
- package/dist/cjs/hooks/aria/useAriaListBox.js +8 -16
- package/dist/cjs/hooks/aria/useAriaOverlay.js +3 -3
- package/dist/cjs/hooks/aria/useAriaPress.js +8 -21
- package/dist/cjs/hooks/aria/useAriaToggle.js +3 -3
- package/dist/cjs/hooks/gesture/useGestureScroll.js +60 -61
- package/dist/cjs/hooks/index.js +12 -0
- package/dist/cjs/hooks/overlay/OverlayStackStore.js +49 -69
- package/dist/cjs/hooks/overlay/useOverlayStack.js +13 -19
- package/dist/cjs/hooks/useControllableValue.js +13 -24
- package/dist/cjs/hooks/useCountDown.js +30 -38
- package/dist/cjs/hooks/useHairline.js +17 -29
- package/dist/cjs/hooks/useSafeAreaPadding.js +1 -4
- package/dist/cjs/index.js +67 -1
- package/dist/cjs/platform/animation.js +10 -2
- package/dist/cjs/platform/measure.js +21 -37
- package/dist/cjs/utils/color.js +20 -39
- package/dist/cjs/utils/compare.js +7 -12
- package/dist/cjs/utils/createPlatformShadow.js +28 -39
- package/dist/cjs/utils/date.js +20 -50
- package/dist/cjs/utils/deepMerge.js +16 -26
- package/dist/cjs/utils/hairline.js +75 -71
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/number.js +21 -29
- package/dist/cjs/utils/render.js +21 -0
- package/dist/cjs/utils/rtl.js +25 -0
- package/dist/cjs/utils/string.js +8 -25
- package/dist/cjs/utils/validate.js +2 -4
- package/dist/es/components/action-sheet/ActionSheet.js +130 -144
- package/dist/es/components/action-sheet/tokens.js +16 -27
- package/dist/es/components/area/Area.js +58 -71
- package/dist/es/components/area/tokens.js +6 -3
- package/dist/es/components/avatar/Avatar.js +38 -36
- package/dist/es/components/avatar/index.js +1 -2
- package/dist/es/components/badge/Badge.js +70 -75
- package/dist/es/components/badge/tokens.js +6 -8
- package/dist/es/components/button/Button.js +136 -177
- package/dist/es/components/button/ButtonGroup.js +12 -46
- package/dist/es/components/button/tokens.js +2 -3
- package/dist/es/components/calendar/Calendar.js +214 -225
- package/dist/es/components/calendar/tokens.js +3 -3
- package/dist/es/components/cascader/Cascader.js +260 -270
- package/dist/es/components/cascader/tokens.js +2 -2
- package/dist/es/components/cascader/useCascaderExtend.js +25 -29
- package/dist/es/components/cell/Cell.js +95 -105
- package/dist/es/components/cell/CellGroup.js +37 -48
- package/dist/es/components/checkbox/Checkbox.js +141 -133
- package/dist/es/components/checkbox/CheckboxGroup.js +22 -52
- package/dist/es/components/checkbox/tokens.js +7 -10
- package/dist/es/components/circle/Circle.js +87 -73
- package/dist/es/components/collapse/Collapse.js +90 -105
- package/dist/es/components/config-provider/ConfigProvider.js +11 -4
- package/dist/es/components/config-provider/DirectionContext.js +2 -0
- package/dist/es/components/config-provider/index.js +1 -0
- package/dist/es/components/config-provider/locale/en-US.js +32 -0
- package/dist/es/components/config-provider/locale/zh-CN.js +32 -0
- package/dist/es/components/config-provider/useDirection.js +3 -0
- package/dist/es/components/count-down/CountDown.js +35 -30
- package/dist/es/components/datetime-picker/DatetimePicker.js +80 -104
- package/dist/es/components/datetime-picker/tokens.js +14 -3
- package/dist/es/components/dialog/Dialog.js +160 -121
- package/dist/es/components/dialog/imperative.js +24 -43
- package/dist/es/components/dialog/tokens.js +1 -0
- package/dist/es/components/divider/Divider.js +59 -63
- package/dist/es/components/empty/Empty.js +54 -52
- package/dist/es/components/error-boundary/ErrorBoundary.js +62 -0
- package/dist/es/components/error-boundary/index.js +1 -0
- package/dist/es/components/field/Field.js +109 -106
- package/dist/es/components/flex/Flex.js +32 -31
- package/dist/es/components/flex/FlexItem.js +28 -27
- package/dist/es/components/form/Form.js +179 -197
- package/dist/es/components/form/FormItem.js +86 -107
- package/dist/es/components/form/FormList.js +57 -45
- package/dist/es/components/form/tokens.js +6 -3
- package/dist/es/components/form/utils.js +15 -34
- package/dist/es/components/grid/Grid.js +44 -42
- package/dist/es/components/grid/GridItem.js +94 -87
- package/dist/es/components/image/Image.js +79 -82
- package/dist/es/components/image/tokens.js +5 -3
- package/dist/es/components/image-preview/ImagePreview.js +125 -113
- package/dist/es/components/image-preview/imperative.js +4 -13
- package/dist/es/components/image-preview/tokens.js +3 -1
- package/dist/es/components/index.js +3 -1
- package/dist/es/components/input/Input.js +41 -36
- package/dist/es/components/loading/Loading.js +34 -34
- package/dist/es/components/nav-bar/NavBar.js +88 -100
- package/dist/es/components/nav-bar/tokens.js +4 -4
- package/dist/es/components/notice-bar/NoticeBar.js +81 -79
- package/dist/es/components/notice-bar/tokens.js +3 -1
- package/dist/es/components/notify/Notify.js +93 -87
- package/dist/es/components/notify/imperative.js +33 -56
- package/dist/es/components/notify/tokens.js +2 -5
- package/dist/es/components/number-keyboard/NumberKeyboard.js +277 -283
- package/dist/es/components/number-keyboard/tokens.js +7 -1
- package/dist/es/components/overlay/Overlay.js +36 -51
- package/dist/es/components/overlay/tokens.js +5 -3
- package/dist/es/components/password-input/PasswordInput.js +114 -95
- package/dist/es/components/picker/Picker.js +465 -454
- package/dist/es/components/picker/tokens.js +1 -1
- package/dist/es/components/popup/Popup.js +269 -298
- package/dist/es/components/popup/tokens.js +1 -0
- package/dist/es/components/portal/Portal.js +13 -30
- package/dist/es/components/portal/PortalHost.js +152 -234
- package/dist/es/components/progress/Progress.js +103 -101
- package/dist/es/components/progress/tokens.js +1 -0
- package/dist/es/components/radio/Radio.js +100 -93
- package/dist/es/components/radio/RadioGroup.js +15 -46
- package/dist/es/components/radio/tokens.js +7 -10
- package/dist/es/components/safe-area-view/SafeAreaView.js +22 -25
- package/dist/es/components/search/Search.js +66 -58
- package/dist/es/components/selector/Selector.js +21 -27
- package/dist/es/components/share-sheet/ShareSheet.js +167 -163
- package/dist/es/components/share-sheet/tokens.js +3 -1
- package/dist/es/components/sidebar/Sidebar.js +53 -53
- package/dist/es/components/sidebar/SidebarContext.js +1 -2
- package/dist/es/components/sidebar/SidebarItem.js +19 -20
- package/dist/es/components/sidebar/tokens.js +4 -4
- package/dist/es/components/skeleton/Skeleton.js +71 -77
- package/dist/es/components/skeleton/tokens.js +1 -2
- package/dist/es/components/slider/Slider.js +156 -134
- package/dist/es/components/space/Space.js +59 -78
- package/dist/es/components/space/tokens.js +7 -1
- package/dist/es/components/stepper/Stepper.js +183 -159
- package/dist/es/components/stepper/tokens.js +1 -0
- package/dist/es/components/swiper/Swiper.js +258 -257
- package/dist/es/components/swiper/SwiperPagIndicator.js +26 -27
- package/dist/es/components/swiper/tokens.js +10 -3
- package/dist/es/components/switch/Switch.js +23 -25
- package/dist/es/components/tabbar/Tabbar.js +49 -41
- package/dist/es/components/tabbar/TabbarContext.js +1 -2
- package/dist/es/components/tabbar/TabbarItem.js +66 -69
- package/dist/es/components/tabs/Tabs.js +403 -440
- package/dist/es/components/tabs/tokens.js +3 -1
- package/dist/es/components/tag/Tag.js +71 -61
- package/dist/es/components/toast/Toast.js +94 -91
- package/dist/es/components/toast/imperative.js +16 -41
- package/dist/es/components/toast/tokens.js +1 -0
- package/dist/es/components/typography/Typography.js +25 -25
- package/dist/es/components/water-mark/WaterMark.js +81 -79
- package/dist/es/design-system/Text.js +19 -0
- package/dist/es/design-system/ThemeProvider.js +5 -11
- package/dist/es/design-system/createComponentTokensHook.js +11 -13
- package/dist/es/design-system/index.js +1 -0
- package/dist/es/design-system/mergeTokensOverride.js +1 -4
- package/dist/es/design-system/presets.js +2 -3
- package/dist/es/design-system/tokens.js +1 -9
- package/dist/es/hooks/animation/index.js +2 -0
- package/dist/es/hooks/animation/useAnimatedTransition.js +53 -0
- package/dist/es/hooks/animation/useReducedMotion.js +54 -0
- package/dist/es/hooks/aria/useAriaListBox.js +8 -16
- package/dist/es/hooks/aria/useAriaOverlay.js +3 -3
- package/dist/es/hooks/aria/useAriaPress.js +8 -21
- package/dist/es/hooks/aria/useAriaToggle.js +3 -3
- package/dist/es/hooks/gesture/useGestureScroll.js +60 -61
- package/dist/es/hooks/index.js +1 -0
- package/dist/es/hooks/overlay/OverlayStackStore.js +49 -69
- package/dist/es/hooks/overlay/useOverlayStack.js +13 -19
- package/dist/es/hooks/useControllableValue.js +13 -24
- package/dist/es/hooks/useCountDown.js +30 -38
- package/dist/es/hooks/useHairline.js +16 -28
- package/dist/es/hooks/useSafeAreaPadding.js +1 -4
- package/dist/es/index.js +8 -1
- package/dist/es/platform/animation.js +9 -1
- package/dist/es/platform/measure.js +21 -37
- package/dist/es/utils/color.js +18 -35
- package/dist/es/utils/compare.js +7 -12
- package/dist/es/utils/createPlatformShadow.js +28 -39
- package/dist/es/utils/date.js +20 -50
- package/dist/es/utils/deepMerge.js +16 -26
- package/dist/es/utils/hairline.js +74 -65
- package/dist/es/utils/index.js +2 -0
- package/dist/es/utils/number.js +21 -29
- package/dist/es/utils/render.js +7 -0
- package/dist/es/utils/rtl.js +17 -0
- package/dist/es/utils/string.js +8 -25
- package/dist/es/utils/validate.js +1 -2
- package/dist/types/components/action-sheet/ActionSheet.d.ts +1 -1
- package/dist/types/components/area/Area.d.ts +1 -1
- package/dist/types/components/area/tokens.d.ts +4 -0
- package/dist/types/components/avatar/Avatar.d.ts +1 -1
- package/dist/types/components/avatar/index.d.ts +1 -2
- package/dist/types/components/badge/Badge.d.ts +1 -1
- package/dist/types/components/button/Button.d.ts +1 -1
- package/dist/types/components/button/index.d.ts +1 -1
- package/dist/types/components/calendar/Calendar.d.ts +1 -1
- package/dist/types/components/cascader/Cascader.d.ts +1 -1
- package/dist/types/components/cell/Cell.d.ts +1 -1
- package/dist/types/components/cell/CellGroup.d.ts +1 -1
- package/dist/types/components/cell/index.d.ts +2 -2
- package/dist/types/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/types/components/circle/Circle.d.ts +1 -1
- package/dist/types/components/collapse/Collapse.d.ts +1 -2
- package/dist/types/components/config-provider/DirectionContext.d.ts +3 -0
- package/dist/types/components/config-provider/index.d.ts +2 -1
- package/dist/types/components/config-provider/locale/en-US.d.ts +32 -0
- package/dist/types/components/config-provider/locale/zh-CN.d.ts +32 -0
- package/dist/types/components/config-provider/useDirection.d.ts +1 -0
- package/dist/types/components/count-down/CountDown.d.ts +1 -1
- package/dist/types/components/datetime-picker/DatetimePicker.d.ts +1 -1
- package/dist/types/components/datetime-picker/tokens.d.ts +12 -0
- package/dist/types/components/dialog/Dialog.d.ts +1 -1
- package/dist/types/components/dialog/tokens.d.ts +1 -0
- package/dist/types/components/divider/Divider.d.ts +1 -1
- package/dist/types/components/empty/Empty.d.ts +1 -1
- package/dist/types/components/error-boundary/ErrorBoundary.d.ts +6 -0
- package/dist/types/components/error-boundary/index.d.ts +2 -0
- package/dist/types/components/field/Field.d.ts +1 -1
- package/dist/types/components/flex/Flex.d.ts +1 -1
- package/dist/types/components/flex/FlexItem.d.ts +1 -1
- package/dist/types/components/flex/index.d.ts +2 -2
- package/dist/types/components/form/Form.d.ts +1 -1
- package/dist/types/components/form/FormItem.d.ts +2 -1
- package/dist/types/components/form/index.d.ts +2 -2
- package/dist/types/components/form/tokens.d.ts +4 -0
- package/dist/types/components/grid/Grid.d.ts +1 -1
- package/dist/types/components/grid/GridItem.d.ts +1 -1
- package/dist/types/components/grid/index.d.ts +2 -2
- package/dist/types/components/image/Image.d.ts +1 -1
- package/dist/types/components/image-preview/ImagePreview.d.ts +1 -1
- package/dist/types/components/image-preview/tokens.d.ts +1 -0
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/input/Input.d.ts +3 -3
- package/dist/types/components/loading/Loading.d.ts +1 -1
- package/dist/types/components/nav-bar/NavBar.d.ts +1 -1
- package/dist/types/components/nav-bar/tokens.d.ts +1 -1
- package/dist/types/components/notice-bar/NoticeBar.d.ts +1 -1
- package/dist/types/components/notice-bar/tokens.d.ts +1 -0
- package/dist/types/components/notify/Notify.d.ts +2 -2
- package/dist/types/components/notify/index.d.ts +1 -1
- package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
- package/dist/types/components/overlay/Overlay.d.ts +1 -5
- package/dist/types/components/overlay/tokens.d.ts +3 -0
- package/dist/types/components/password-input/PasswordInput.d.ts +1 -1
- package/dist/types/components/picker/Picker.d.ts +6 -6
- package/dist/types/components/popup/Popup.d.ts +3 -42
- package/dist/types/components/popup/tokens.d.ts +1 -0
- package/dist/types/components/portal/Portal.d.ts +9 -6
- package/dist/types/components/portal/PortalHost.d.ts +1 -1
- package/dist/types/components/radio/RadioGroup.d.ts +1 -1
- package/dist/types/components/safe-area-view/SafeAreaView.d.ts +1 -1
- package/dist/types/components/search/Search.d.ts +1 -1
- package/dist/types/components/share-sheet/ShareSheet.d.ts +1 -1
- package/dist/types/components/share-sheet/tokens.d.ts +1 -0
- package/dist/types/components/sidebar/Sidebar.d.ts +1 -1
- package/dist/types/components/sidebar/SidebarContext.d.ts +1 -1
- package/dist/types/components/sidebar/SidebarItem.d.ts +1 -1
- package/dist/types/components/sidebar/index.d.ts +2 -2
- package/dist/types/components/skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/slider/Slider.d.ts +1 -1
- package/dist/types/components/stepper/Stepper.d.ts +1 -1
- package/dist/types/components/stepper/tokens.d.ts +1 -0
- package/dist/types/components/swiper/Swiper.d.ts +1 -1
- package/dist/types/components/swiper/index.d.ts +1 -1
- package/dist/types/components/swiper/tokens.d.ts +8 -0
- package/dist/types/components/tabbar/Tabbar.d.ts +2 -2
- package/dist/types/components/tabbar/TabbarContext.d.ts +1 -1
- package/dist/types/components/tabbar/TabbarItem.d.ts +2 -2
- package/dist/types/components/tabs/Tabs.d.ts +1 -1
- package/dist/types/components/tabs/index.d.ts +1 -1
- package/dist/types/components/tabs/tokens.d.ts +1 -0
- package/dist/types/components/tag/Tag.d.ts +1 -1
- package/dist/types/components/toast/Toast.d.ts +2 -2
- package/dist/types/components/toast/index.d.ts +1 -1
- package/dist/types/components/toast/tokens.d.ts +1 -0
- package/dist/types/components/water-mark/WaterMark.d.ts +1 -1
- package/dist/types/design-system/Text.d.ts +3 -0
- package/dist/types/design-system/index.d.ts +1 -0
- package/dist/types/design-system/tokens.d.ts +0 -1
- package/dist/types/hooks/animation/index.d.ts +3 -0
- package/dist/types/hooks/animation/useAnimatedTransition.d.ts +13 -0
- package/dist/types/hooks/animation/useReducedMotion.d.ts +3 -0
- package/dist/types/hooks/aria/useAriaOverlay.d.ts +1 -1
- package/dist/types/hooks/gesture/useGestureScroll.d.ts +11 -10
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/overlay/OverlayStackStore.d.ts +8 -8
- package/dist/types/hooks/useCountDown.d.ts +1 -1
- package/dist/types/hooks/useHairline.d.ts +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/platform/animation.d.ts +8 -0
- package/dist/types/platform/measure.d.ts +1 -1
- package/dist/types/utils/color.d.ts +0 -2
- package/dist/types/utils/compare.d.ts +1 -1
- package/dist/types/utils/createPlatformShadow.d.ts +2 -2
- package/dist/types/utils/date.d.ts +2 -2
- package/dist/types/utils/hairline.d.ts +5 -10
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/number.d.ts +2 -2
- package/dist/types/utils/render.d.ts +5 -0
- package/dist/types/utils/rtl.d.ts +5 -0
- package/dist/types/utils/validate.d.ts +0 -1
- package/package.json +25 -4
|
@@ -1,27 +1,23 @@
|
|
|
1
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, { memo, useCallback, useEffect, useImperativeHandle, useRef, useState, useMemo, Children, isValidElement
|
|
2
|
+
import React, { memo, useCallback, useEffect, useImperativeHandle, useRef, useState, useMemo, Children, isValidElement } from 'react';
|
|
3
3
|
import { Animated, Pressable, StyleSheet, Text, ScrollView, View, Platform } from 'react-native';
|
|
4
4
|
import { useAriaPress, useControllableValue } from '../../hooks';
|
|
5
|
+
import { useReducedMotion } from '../../hooks/animation';
|
|
6
|
+
import { createHairlineView } from '../../utils/hairline';
|
|
5
7
|
import { parseNumberLike } from '../../utils/number';
|
|
6
8
|
import { isBoolean, isFunction, isObject, isRenderable, isText } from '../../utils/validate';
|
|
7
9
|
import { useTabsTokens } from './tokens';
|
|
8
10
|
const TabPane = () => null;
|
|
9
11
|
TabPane.displayName = 'Tabs.TabPane';
|
|
10
|
-
const
|
|
11
|
-
const requestFrame =
|
|
12
|
+
const hasRaf = typeof requestAnimationFrame === 'function' && typeof cancelAnimationFrame === 'function';
|
|
13
|
+
const requestFrame = hasRaf ? requestAnimationFrame : cb => setTimeout(cb, 16);
|
|
12
14
|
const cancelFrame = id => {
|
|
13
|
-
if (id
|
|
14
|
-
if (canUseRaf) {
|
|
15
|
-
cancelAnimationFrame(id);
|
|
16
|
-
} else {
|
|
17
|
-
clearTimeout(id);
|
|
18
|
-
}
|
|
15
|
+
if (id != null) (hasRaf ? cancelAnimationFrame : clearTimeout)(id);
|
|
19
16
|
};
|
|
20
17
|
const isTabPaneElement = child => {
|
|
21
18
|
if (! /*#__PURE__*/React.isValidElement(child)) return false;
|
|
22
19
|
if (child.type === TabPane) return true;
|
|
23
|
-
|
|
24
|
-
return type.displayName === 'Tabs.TabPane';
|
|
20
|
+
return child.type.displayName === 'Tabs.TabPane';
|
|
25
21
|
};
|
|
26
22
|
const useTabsAnimation = ({
|
|
27
23
|
type,
|
|
@@ -36,43 +32,52 @@ const useTabsAnimation = ({
|
|
|
36
32
|
layoutMap,
|
|
37
33
|
navContainerWidthRef
|
|
38
34
|
}) => {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
35
|
+
const indX = useRef(new Animated.Value(0)).current;
|
|
36
|
+
const indW = useRef(new Animated.Value(0)).current;
|
|
37
|
+
const indInitRef = useRef(false);
|
|
38
|
+
const animRef = useRef(null);
|
|
42
39
|
const animateIndicator = useCallback((name, immediate) => {
|
|
43
40
|
if (name == null || type !== 'line') return false;
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
x: Math.max(
|
|
49
|
-
width:
|
|
41
|
+
const eqW = !scrollable && align !== 'start' && navContainerWidthRef.current > 0 && panes.length > 0;
|
|
42
|
+
const idx = nameIndexMap.get(name) ?? -1;
|
|
43
|
+
const eqTabW = eqW ? navContainerWidthRef.current / panes.length : 0;
|
|
44
|
+
const lay = eqW ? {
|
|
45
|
+
x: Math.max(idx, 0) * eqTabW,
|
|
46
|
+
width: eqTabW
|
|
50
47
|
} : layoutMap.current.get(name);
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
toValue,
|
|
48
|
+
if (!lay || idx < 0) return false;
|
|
49
|
+
animRef.current?.stop();
|
|
50
|
+
const timing = (v, to) => Animated.timing(v, {
|
|
51
|
+
toValue: to,
|
|
56
52
|
duration: immediate || !animated ? 0 : resolvedDuration,
|
|
57
|
-
useNativeDriver: false
|
|
53
|
+
useNativeDriver: false,
|
|
54
|
+
isInteraction: false
|
|
55
|
+
});
|
|
56
|
+
const tW = resolvedLineWidth ?? lay.width;
|
|
57
|
+
const tX = resolvedLineWidth ? lay.x + (lay.width - tW) / 2 : lay.x;
|
|
58
|
+
const anim = Animated.parallel([timing(indX, tX), timing(indW, tW)]);
|
|
59
|
+
animRef.current = anim;
|
|
60
|
+
anim.start(({
|
|
61
|
+
finished
|
|
62
|
+
}) => {
|
|
63
|
+
if (finished) animRef.current = null;
|
|
58
64
|
});
|
|
59
|
-
const targetWidth = resolvedLineWidth ?? layout.width;
|
|
60
|
-
const targetX = resolvedLineWidth ? layout.x + (layout.width - targetWidth) / 2 : layout.x;
|
|
61
|
-
Animated.parallel([timing(indicatorX, targetX), timing(indicatorWidth, targetWidth)]).start();
|
|
62
65
|
return true;
|
|
63
|
-
}, [align, animated,
|
|
66
|
+
}, [align, animated, indW, indX, nameIndexMap, panes.length, resolvedDuration, resolvedLineWidth, scrollable, type, layoutMap, navContainerWidthRef]);
|
|
64
67
|
useEffect(() => {
|
|
65
68
|
if (currentName == null) return;
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
indicatorInitializedRef.current = true;
|
|
70
|
-
}
|
|
69
|
+
const should = indInitRef.current;
|
|
70
|
+
const did = animateIndicator(currentName, !should);
|
|
71
|
+
if (did && !indInitRef.current) indInitRef.current = true;
|
|
71
72
|
}, [animateIndicator, currentName]);
|
|
73
|
+
useEffect(() => () => {
|
|
74
|
+
animRef.current?.stop();
|
|
75
|
+
animRef.current = null;
|
|
76
|
+
}, []);
|
|
72
77
|
return {
|
|
73
|
-
indicatorX,
|
|
74
|
-
indicatorWidth,
|
|
75
|
-
indicatorInitializedRef,
|
|
78
|
+
indicatorX: indX,
|
|
79
|
+
indicatorWidth: indW,
|
|
80
|
+
indicatorInitializedRef: indInitRef,
|
|
76
81
|
animateIndicator
|
|
77
82
|
};
|
|
78
83
|
};
|
|
@@ -85,106 +90,86 @@ const useTabsScroll = ({
|
|
|
85
90
|
navContainerWidthRef,
|
|
86
91
|
navContentWidthRef
|
|
87
92
|
}) => {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const
|
|
93
|
+
const navScrRef = useRef(null);
|
|
94
|
+
const navX = useRef(new Animated.Value(0)).current;
|
|
95
|
+
const navAnimRef = useRef(null);
|
|
96
|
+
const autoScrRef = useRef(false);
|
|
97
|
+
const lastXRef = useRef(0);
|
|
98
|
+
const frameRef = useRef(null);
|
|
94
99
|
const scrollIntoView = useCallback(immediate => {
|
|
95
100
|
if (!scrollable || currentName == null) return;
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
if (navScrollAnimRef.current) {
|
|
110
|
-
navScrollAnimRef.current.stop();
|
|
111
|
-
navScrollAnimRef.current = null;
|
|
112
|
-
}
|
|
113
|
-
cancelFrame(navAutoScrollFrameRef.current);
|
|
114
|
-
navAutoScrollFrameRef.current = null;
|
|
101
|
+
const lay = layoutMap.current.get(currentName);
|
|
102
|
+
const ctrW = navContainerWidthRef.current;
|
|
103
|
+
if (!lay || !ctrW) return;
|
|
104
|
+
const cntW = navContentWidthRef.current;
|
|
105
|
+
const tX = lay.x - (ctrW - lay.width) / 2;
|
|
106
|
+
const maxS = Math.max(cntW - ctrW, 0);
|
|
107
|
+
const clampX = Math.max(0, Math.min(tX, maxS));
|
|
108
|
+
if (maxS <= 0 || Math.abs(clampX - lastXRef.current) < 1) return;
|
|
109
|
+
navAnimRef.current?.stop();
|
|
110
|
+
navAnimRef.current = null;
|
|
111
|
+
cancelFrame(frameRef.current);
|
|
112
|
+
frameRef.current = null;
|
|
115
113
|
if (immediate || !animated) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
autoScrRef.current = true;
|
|
115
|
+
navX.setValue(clampX);
|
|
116
|
+
frameRef.current = requestFrame(() => {
|
|
117
|
+
frameRef.current = null;
|
|
118
|
+
autoScrRef.current = false;
|
|
121
119
|
});
|
|
122
120
|
return;
|
|
123
121
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
toValue:
|
|
122
|
+
navX.setValue(lastXRef.current);
|
|
123
|
+
autoScrRef.current = true;
|
|
124
|
+
navAnimRef.current = Animated.timing(navX, {
|
|
125
|
+
toValue: clampX,
|
|
128
126
|
duration: resolvedDuration,
|
|
129
|
-
useNativeDriver: false
|
|
127
|
+
useNativeDriver: false,
|
|
128
|
+
isInteraction: false
|
|
130
129
|
});
|
|
131
|
-
|
|
130
|
+
navAnimRef.current.start(({
|
|
132
131
|
finished
|
|
133
132
|
}) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
navLastScrollXRef.current = clampedX;
|
|
133
|
+
navAnimRef.current = null;
|
|
134
|
+
autoScrRef.current = false;
|
|
135
|
+
if (finished) lastXRef.current = clampX;
|
|
140
136
|
});
|
|
141
|
-
}, [animated, currentName,
|
|
137
|
+
}, [animated, currentName, navX, resolvedDuration, scrollable, layoutMap, navContainerWidthRef, navContentWidthRef]);
|
|
142
138
|
useEffect(() => {
|
|
143
139
|
if (!scrollable) return;
|
|
144
|
-
const
|
|
140
|
+
const id = navX.addListener(({
|
|
145
141
|
value
|
|
146
142
|
}) => {
|
|
147
|
-
const prev =
|
|
148
|
-
|
|
149
|
-
if (Math.abs(value - prev)
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
navScrollRef.current?.scrollTo({
|
|
143
|
+
const prev = lastXRef.current;
|
|
144
|
+
lastXRef.current = value;
|
|
145
|
+
if (Math.abs(value - prev) >= 0.5) navScrRef.current?.scrollTo({
|
|
153
146
|
x: value,
|
|
154
147
|
y: 0,
|
|
155
148
|
animated: false
|
|
156
149
|
});
|
|
157
150
|
});
|
|
158
|
-
return () =>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return () => {
|
|
164
|
-
cancelFrame(navAutoScrollFrameRef.current);
|
|
165
|
-
navAutoScrollFrameRef.current = null;
|
|
166
|
-
};
|
|
151
|
+
return () => navX.removeListener(id);
|
|
152
|
+
}, [navX, scrollable]);
|
|
153
|
+
useEffect(() => () => {
|
|
154
|
+
cancelFrame(frameRef.current);
|
|
155
|
+
frameRef.current = null;
|
|
167
156
|
}, []);
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
navLastScrollXRef.current = event.nativeEvent.contentOffset.x;
|
|
157
|
+
const onNavBeginDrag = useCallback(e => {
|
|
158
|
+
autoScrRef.current = false;
|
|
159
|
+
navAnimRef.current?.stop();
|
|
160
|
+
navAnimRef.current = null;
|
|
161
|
+
lastXRef.current = e.nativeEvent.contentOffset.x;
|
|
175
162
|
}, []);
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
navLastScrollXRef.current = event.nativeEvent.contentOffset.x;
|
|
163
|
+
const onNavScroll = useCallback(e => {
|
|
164
|
+
if (autoScrRef.current) return;
|
|
165
|
+
lastXRef.current = e.nativeEvent.contentOffset.x;
|
|
181
166
|
}, []);
|
|
182
167
|
return {
|
|
183
|
-
navScrollRef,
|
|
184
|
-
navScrollX,
|
|
168
|
+
navScrollRef: navScrRef,
|
|
169
|
+
navScrollX: navX,
|
|
185
170
|
scrollIntoView,
|
|
186
|
-
handleNavScrollBeginDrag,
|
|
187
|
-
handleNavScroll
|
|
171
|
+
handleNavScrollBeginDrag: onNavBeginDrag,
|
|
172
|
+
handleNavScroll: onNavScroll
|
|
188
173
|
};
|
|
189
174
|
};
|
|
190
175
|
const TabBarItemInner = ({
|
|
@@ -205,33 +190,45 @@ const TabBarItemInner = ({
|
|
|
205
190
|
onLayout,
|
|
206
191
|
isLast
|
|
207
192
|
}) => {
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
onPress:
|
|
193
|
+
const dis = !!pane.disabled;
|
|
194
|
+
const aria = useAriaPress({
|
|
195
|
+
onPress: e => onSelect(pane, pane.index, e),
|
|
211
196
|
extraProps: {
|
|
212
197
|
accessibilityRole: 'tab',
|
|
213
198
|
accessibilityState: {
|
|
214
199
|
selected: isActive,
|
|
215
|
-
disabled:
|
|
200
|
+
disabled: dis
|
|
216
201
|
},
|
|
217
202
|
testID: `rv-tabs-item-${pane.name}`
|
|
218
203
|
}
|
|
219
204
|
});
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
|
|
205
|
+
const isCap = type === 'capsule';
|
|
206
|
+
const isJ = type === 'jumbo';
|
|
207
|
+
const isC = type === 'card';
|
|
208
|
+
const rTitle = isFunction(pane.title) ? pane.title(isActive) : pane.title ?? pane.name;
|
|
209
|
+
const rDesc = isFunction(pane.description) ? pane.description(isActive) : pane.description;
|
|
210
|
+
const actClr = titleActiveColor ?? (isC ? tokens.colors.cardActiveText : isCap ? tokens.colors.capsuleActiveText : color ?? tokens.colors.textActive);
|
|
211
|
+
const inactClr = titleInactiveColor ?? (isC ? color ?? tokens.colors.cardBorder : isCap ? tokens.colors.capsuleText : tokens.colors.text);
|
|
212
|
+
const txtClr = pane.disabled ? tokens.colors.textDisabled : isActive ? actClr : inactClr;
|
|
213
|
+
const descClr = dis ? tokens.colors.textDisabled : isJ ? isActive ? tokens.colors.jumboDescriptionActive : tokens.colors.jumboDescription : isActive ? tokens.colors.descriptionActive : tokens.colors.description;
|
|
214
|
+
const flex = !scrollable && (align !== 'start' || isC);
|
|
215
|
+
const compact = isC || isJ || isCap;
|
|
216
|
+
const hPad = compact ? 0 : tokens.tabList.paddingHorizontal;
|
|
217
|
+
const vPad = compact ? 0 : tokens.tabList.paddingVertical;
|
|
218
|
+
const lblWrap = [S.lblW, isJ && S.lblWJ, isC && S.cardLbl, isC && {
|
|
219
|
+
paddingHorizontal: tokens.card.paddingHorizontal,
|
|
220
|
+
paddingVertical: tokens.card.paddingVertical
|
|
221
|
+
}, isCap && {
|
|
222
|
+
flex: 1,
|
|
223
|
+
alignSelf: 'stretch',
|
|
224
|
+
paddingHorizontal: tokens.capsule.paddingHorizontal,
|
|
225
|
+
paddingVertical: tokens.capsule.paddingVertical
|
|
226
|
+
}, isJ && {
|
|
227
|
+
paddingHorizontal: tokens.jumbo.paddingHorizontal,
|
|
228
|
+
paddingVertical: tokens.jumbo.paddingVertical,
|
|
229
|
+
alignItems: 'center'
|
|
230
|
+
}].filter(Boolean);
|
|
231
|
+
const lblTxtWrap = isCap ? [{
|
|
235
232
|
flex: 1,
|
|
236
233
|
alignSelf: 'stretch',
|
|
237
234
|
justifyContent: 'center',
|
|
@@ -239,89 +236,71 @@ const TabBarItemInner = ({
|
|
|
239
236
|
borderRadius: tokens.capsule.radius,
|
|
240
237
|
backgroundColor: isActive ? color ?? tokens.colors.capsuleActiveBackground : tokens.colors.capsuleBackground
|
|
241
238
|
}] : null;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
labelWrapperStyles.push(styles.cardLabel);
|
|
247
|
-
labelWrapperStyles.push({
|
|
248
|
-
paddingHorizontal: tokens.card.paddingHorizontal,
|
|
249
|
-
paddingVertical: tokens.card.paddingVertical
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
if (isCapsule) {
|
|
253
|
-
labelWrapperStyles.push({
|
|
254
|
-
flex: 1,
|
|
255
|
-
alignSelf: 'stretch'
|
|
256
|
-
});
|
|
257
|
-
labelWrapperStyles.push({
|
|
258
|
-
paddingHorizontal: tokens.capsule.paddingHorizontal,
|
|
259
|
-
paddingVertical: tokens.capsule.paddingVertical
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
if (isJumbo) {
|
|
263
|
-
labelWrapperStyles.push({
|
|
264
|
-
paddingHorizontal: tokens.jumbo.paddingHorizontal,
|
|
265
|
-
paddingVertical: tokens.jumbo.paddingVertical,
|
|
266
|
-
alignItems: 'center'
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
const titleTextStyle = [styles.title, {
|
|
270
|
-
color: textColor,
|
|
271
|
-
fontSize: isJumbo ? tokens.typography.jumboTitleSize : tokens.typography.titleSize,
|
|
239
|
+
const titleStyleArr = [S.title, {
|
|
240
|
+
color: txtClr,
|
|
241
|
+
fontFamily: tokens.typography.fontFamily,
|
|
242
|
+
fontSize: isJ ? tokens.typography.jumboTitleSize : tokens.typography.titleSize,
|
|
272
243
|
fontWeight: isActive ? tokens.typography.titleActiveWeight : tokens.typography.titleWeight,
|
|
273
|
-
lineHeight:
|
|
244
|
+
lineHeight: isJ ? tokens.typography.jumboLineHeight : undefined,
|
|
274
245
|
textAlign: 'center'
|
|
275
|
-
}, ellipsis && !
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
numberOfLines: ellipsis && !isJumbo ? 1 : undefined
|
|
279
|
-
}, renderTitle);
|
|
280
|
-
const descriptionMarginTop = isJumbo ? tokens.spacing.jumboDescriptionMarginTop : tokens.spacing.descriptionMarginTop;
|
|
281
|
-
const descriptionJumboStyle = isJumbo ? {
|
|
246
|
+
}, ellipsis && !isJ ? S.ellipsis : null, titleStyle];
|
|
247
|
+
const descMT = isJ ? tokens.spacing.jumboDescriptionMarginTop : tokens.spacing.descriptionMarginTop;
|
|
248
|
+
const descJStyle = isJ ? {
|
|
282
249
|
backgroundColor: isActive ? tokens.colors.jumboDescriptionActiveBackground : tokens.colors.jumboDescriptionBackground,
|
|
283
250
|
paddingHorizontal: tokens.jumbo.descriptionPaddingHorizontal,
|
|
284
251
|
paddingVertical: tokens.jumbo.descriptionPaddingVertical,
|
|
285
252
|
borderRadius: tokens.jumbo.descriptionRadius
|
|
286
253
|
} : null;
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
marginTop: descriptionMarginTop,
|
|
295
|
-
alignItems: 'center'
|
|
296
|
-
}, descriptionJumboStyle];
|
|
297
|
-
return /*#__PURE__*/React.createElement(Pressable, _extends({}, ariaPress.interactionProps, {
|
|
298
|
-
onLayout: event => onLayout(pane.name, event),
|
|
299
|
-
style: [styles.tabItem, shouldFlex ? styles.flexItem : null, {
|
|
300
|
-
paddingHorizontal: horizontalPadding,
|
|
301
|
-
paddingVertical: verticalPadding
|
|
302
|
-
}, isCard ? {
|
|
303
|
-
borderRightWidth: isLast ? 0 : StyleSheet.hairlineWidth,
|
|
304
|
-
borderRightColor: color ?? tokens.colors.cardBorder,
|
|
254
|
+
const onLay = useCallback(e => onLayout(pane.name, e), [onLayout, pane.name]);
|
|
255
|
+
return /*#__PURE__*/React.createElement(Pressable, _extends({}, aria.interactionProps, {
|
|
256
|
+
onLayout: onLay,
|
|
257
|
+
style: [S.tabI, flex ? S.flexI : null, {
|
|
258
|
+
paddingHorizontal: hPad,
|
|
259
|
+
paddingVertical: vPad
|
|
260
|
+
}, isC ? {
|
|
305
261
|
backgroundColor: isActive ? color ?? tokens.colors.cardActiveBackground : tokens.colors.cardBackground
|
|
306
262
|
} : null, tabStyle]
|
|
307
263
|
}), /*#__PURE__*/React.createElement(View, {
|
|
308
|
-
style:
|
|
309
|
-
},
|
|
310
|
-
style:
|
|
311
|
-
},
|
|
312
|
-
style:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
264
|
+
style: lblWrap
|
|
265
|
+
}, lblTxtWrap ? /*#__PURE__*/React.createElement(View, {
|
|
266
|
+
style: lblTxtWrap
|
|
267
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
268
|
+
style: titleStyleArr,
|
|
269
|
+
numberOfLines: ellipsis && !isJ ? 1 : undefined
|
|
270
|
+
}, rTitle)) : /*#__PURE__*/React.createElement(Text, {
|
|
271
|
+
style: titleStyleArr,
|
|
272
|
+
numberOfLines: ellipsis && !isJ ? 1 : undefined
|
|
273
|
+
}, rTitle), isRenderable(rDesc) && (isText(rDesc) ? /*#__PURE__*/React.createElement(Text, {
|
|
274
|
+
style: [S.descTxt, {
|
|
275
|
+
color: descClr,
|
|
276
|
+
fontFamily: tokens.typography.fontFamily,
|
|
277
|
+
fontSize: tokens.typography.descriptionSize,
|
|
278
|
+
marginTop: descMT,
|
|
279
|
+
textAlign: 'center'
|
|
280
|
+
}, descJStyle, descriptionStyle]
|
|
281
|
+
}, rDesc) : /*#__PURE__*/React.createElement(View, {
|
|
282
|
+
style: [{
|
|
283
|
+
marginTop: descMT,
|
|
284
|
+
alignItems: 'center'
|
|
285
|
+
}, descJStyle]
|
|
286
|
+
}, rDesc)), isRenderable(pane.badge) && /*#__PURE__*/React.createElement(View, {
|
|
287
|
+
style: {
|
|
317
288
|
marginTop: tokens.spacing.badgeMarginTop
|
|
318
|
-
}
|
|
289
|
+
}
|
|
319
290
|
}, isText(pane.badge) ? /*#__PURE__*/React.createElement(Text, {
|
|
320
|
-
style:
|
|
291
|
+
style: {
|
|
321
292
|
color: tokens.colors.badgeText,
|
|
293
|
+
fontFamily: tokens.typography.fontFamily,
|
|
322
294
|
fontSize: tokens.typography.badgeTextSize
|
|
323
|
-
}
|
|
324
|
-
}, pane.badge) : pane.badge))
|
|
295
|
+
}
|
|
296
|
+
}, pane.badge) : pane.badge)), isC && !isLast && /*#__PURE__*/React.createElement(View, {
|
|
297
|
+
style: createHairlineView({
|
|
298
|
+
position: 'right',
|
|
299
|
+
color: color ?? tokens.colors.cardBorder,
|
|
300
|
+
top: 0,
|
|
301
|
+
bottom: 0
|
|
302
|
+
})
|
|
303
|
+
}));
|
|
325
304
|
};
|
|
326
305
|
const TabBarItem = /*#__PURE__*/memo(TabBarItemInner);
|
|
327
306
|
const TabsBaseInner = (props, ref) => {
|
|
@@ -360,6 +339,7 @@ const TabsBaseInner = (props, ref) => {
|
|
|
360
339
|
...rest
|
|
361
340
|
} = props;
|
|
362
341
|
const tokens = useTabsTokens(tokensOverride);
|
|
342
|
+
const reducedMotion = useReducedMotion();
|
|
363
343
|
const type = typeProp ?? tokens.defaults.type;
|
|
364
344
|
const align = alignProp ?? tokens.defaults.align;
|
|
365
345
|
const ellipsis = ellipsisProp ?? tokens.defaults.ellipsis;
|
|
@@ -369,18 +349,18 @@ const TabsBaseInner = (props, ref) => {
|
|
|
369
349
|
const lazyRender = lazyRenderProp ?? tokens.defaults.lazyRender;
|
|
370
350
|
const background = backgroundProp ?? tokens.tabList.background;
|
|
371
351
|
const parsedLineWidth = parseNumberLike(lineWidth ?? tokens.indicator.width);
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
const
|
|
352
|
+
const resLineW = parsedLineWidth != null && parsedLineWidth < 0 ? undefined : parsedLineWidth;
|
|
353
|
+
const resLineH = Math.max(0, parseNumberLike(lineHeight) ?? tokens.indicator.height);
|
|
354
|
+
const resDur = reducedMotion ? 0 : Math.max(0, parseNumberLike(duration) ?? tokens.defaults.duration);
|
|
355
|
+
const resSwipeTh = Math.max(0, parseNumberLike(swipeThreshold) ?? tokens.defaults.swipeThreshold);
|
|
356
|
+
const swipeCfg = !swipeable ? undefined : isObject(swipeable) ? {
|
|
377
357
|
autoHeight: swipeable.autoHeight ?? true,
|
|
378
358
|
preventScroll: swipeable.preventScroll ?? true
|
|
379
359
|
} : {
|
|
380
360
|
autoHeight: true,
|
|
381
361
|
preventScroll: true
|
|
382
362
|
};
|
|
383
|
-
const
|
|
363
|
+
const isSwipe = !!swipeCfg;
|
|
384
364
|
const panes = useMemo(() => {
|
|
385
365
|
const result = [];
|
|
386
366
|
let paneIndex = 0;
|
|
@@ -388,13 +368,11 @@ const TabsBaseInner = (props, ref) => {
|
|
|
388
368
|
Children.forEach(nodes, node => {
|
|
389
369
|
if (! /*#__PURE__*/isValidElement(node)) return;
|
|
390
370
|
const element = node;
|
|
391
|
-
if (element.type === Fragment) {
|
|
371
|
+
if (element.type === React.Fragment) {
|
|
392
372
|
walk(element.props.children);
|
|
393
373
|
return;
|
|
394
374
|
}
|
|
395
|
-
if (!isTabPaneElement(element))
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
375
|
+
if (!isTabPaneElement(element)) return;
|
|
398
376
|
const paneProps = element.props;
|
|
399
377
|
const name = paneProps.name ?? paneIndex;
|
|
400
378
|
result.push({
|
|
@@ -410,75 +388,69 @@ const TabsBaseInner = (props, ref) => {
|
|
|
410
388
|
return result;
|
|
411
389
|
}, [children]);
|
|
412
390
|
const firstPaneName = panes[0]?.name;
|
|
413
|
-
const [
|
|
391
|
+
const [actVal, setActVal] = useControllableValue(props, {
|
|
414
392
|
defaultValue: firstPaneName,
|
|
415
393
|
valuePropName: 'active',
|
|
416
394
|
defaultValuePropName: 'defaultActive',
|
|
417
395
|
trigger: 'onChange'
|
|
418
396
|
});
|
|
419
|
-
const
|
|
420
|
-
const
|
|
397
|
+
const curName = actVal == null ? firstPaneName : panes.some(pane => pane.name === actVal) ? actVal : firstPaneName;
|
|
398
|
+
const curNameRef = useRef(curName);
|
|
421
399
|
useEffect(() => {
|
|
422
|
-
|
|
423
|
-
}, [
|
|
424
|
-
const
|
|
400
|
+
curNameRef.current = curName;
|
|
401
|
+
}, [curName]);
|
|
402
|
+
const nameIdxMap = useMemo(() => {
|
|
425
403
|
const map = new Map();
|
|
426
404
|
panes.forEach(pane => {
|
|
427
405
|
map.set(pane.name, pane.index);
|
|
428
406
|
});
|
|
429
407
|
return map;
|
|
430
408
|
}, [panes]);
|
|
431
|
-
const
|
|
432
|
-
const
|
|
409
|
+
const actIdx = curName == null ? -1 : nameIdxMap.get(curName) ?? -1;
|
|
410
|
+
const visRef = useRef(new Set());
|
|
411
|
+
const layMap = useRef(new Map());
|
|
412
|
+
const navCtrWRef = useRef(0);
|
|
413
|
+
const navCntWRef = useRef(0);
|
|
414
|
+
const navCntSyncRef = useRef(null);
|
|
415
|
+
const paneLayMap = useRef(new Map());
|
|
416
|
+
const swipeScrRef = useRef(null);
|
|
417
|
+
const swipeChgRef = useRef(false);
|
|
418
|
+
const [ctrW, setCtrW] = useState(0);
|
|
419
|
+
const [swipeH, setSwipeH] = useState(undefined);
|
|
433
420
|
useEffect(() => {
|
|
434
|
-
if (
|
|
435
|
-
|
|
436
|
-
}, [
|
|
421
|
+
if (curName == null) return;
|
|
422
|
+
visRef.current.add(curName);
|
|
423
|
+
}, [curName]);
|
|
437
424
|
useEffect(() => {
|
|
438
425
|
const validNames = new Set(panes.map(pane => pane.name));
|
|
439
|
-
Array.from(
|
|
440
|
-
if (!validNames.has(name))
|
|
426
|
+
Array.from(paneLayMap.current.keys()).forEach(name => {
|
|
427
|
+
if (!validNames.has(name)) paneLayMap.current.delete(name);
|
|
441
428
|
});
|
|
442
|
-
Array.from(
|
|
443
|
-
if (!validNames.has(name))
|
|
429
|
+
Array.from(layMap.current.keys()).forEach(name => {
|
|
430
|
+
if (!validNames.has(name)) layMap.current.delete(name);
|
|
444
431
|
});
|
|
445
432
|
}, [panes]);
|
|
446
|
-
const
|
|
433
|
+
const trackPaneLay = isSwipe && swipeCfg?.autoHeight;
|
|
447
434
|
useEffect(() => {
|
|
448
|
-
if (!
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
}, [shouldTrackPaneLayouts]);
|
|
435
|
+
if (!trackPaneLay) paneLayMap.current.clear();
|
|
436
|
+
}, [trackPaneLay]);
|
|
452
437
|
useEffect(() => {
|
|
453
|
-
if (!
|
|
454
|
-
|
|
438
|
+
if (!isSwipe || !swipeCfg?.autoHeight) {
|
|
439
|
+
setSwipeH(undefined);
|
|
455
440
|
return;
|
|
456
441
|
}
|
|
457
|
-
const layout =
|
|
458
|
-
if (layout)
|
|
459
|
-
|
|
460
|
-
} else {
|
|
461
|
-
setSwipeableHeight(undefined);
|
|
462
|
-
}
|
|
463
|
-
}, [currentName, isSwipeable, swipeableConfig?.autoHeight]);
|
|
464
|
-
const layoutMap = useRef(new Map());
|
|
465
|
-
const navContainerWidthRef = useRef(0);
|
|
466
|
-
const navContentWidthRef = useRef(0);
|
|
467
|
-
const navContentSizeSyncFrameRef = useRef(null);
|
|
468
|
-
const paneLayoutMap = useRef(new Map());
|
|
469
|
-
const swipeableScrollRef = useRef(null);
|
|
470
|
-
const swipeableChangeByScrollRef = useRef(false);
|
|
471
|
-
const [containerWidth, setContainerWidth] = useState(0);
|
|
472
|
-
const [swipeableHeight, setSwipeableHeight] = useState(undefined);
|
|
442
|
+
const layout = curName != null ? paneLayMap.current.get(curName) : undefined;
|
|
443
|
+
if (layout) setSwipeH(layout.height);else setSwipeH(undefined);
|
|
444
|
+
}, [curName, isSwipe, swipeCfg?.autoHeight]);
|
|
473
445
|
useEffect(() => {
|
|
474
446
|
return () => {
|
|
475
|
-
cancelFrame(
|
|
476
|
-
|
|
447
|
+
cancelFrame(navCntSyncRef.current);
|
|
448
|
+
navCntSyncRef.current = null;
|
|
477
449
|
};
|
|
478
450
|
}, []);
|
|
479
|
-
const scrollable = isBoolean(scrollableProp) ? scrollableProp : panes.length >
|
|
480
|
-
const
|
|
481
|
-
const
|
|
451
|
+
const scrollable = isBoolean(scrollableProp) ? scrollableProp : panes.length > resSwipeTh || ellipsis === false;
|
|
452
|
+
const indColor = color ?? tokens.colors.indicator;
|
|
453
|
+
const indRad = resLineH ? resLineH / 2 : tokens.indicator.radius;
|
|
482
454
|
const {
|
|
483
455
|
indicatorX,
|
|
484
456
|
indicatorWidth,
|
|
@@ -490,13 +462,13 @@ const TabsBaseInner = (props, ref) => {
|
|
|
490
462
|
scrollable,
|
|
491
463
|
align,
|
|
492
464
|
panes,
|
|
493
|
-
nameIndexMap,
|
|
494
|
-
resolvedLineWidth,
|
|
495
|
-
resolvedLineHeight,
|
|
496
|
-
resolvedDuration,
|
|
497
|
-
currentName,
|
|
498
|
-
layoutMap,
|
|
499
|
-
navContainerWidthRef
|
|
465
|
+
nameIndexMap: nameIdxMap,
|
|
466
|
+
resolvedLineWidth: resLineW,
|
|
467
|
+
resolvedLineHeight: resLineH,
|
|
468
|
+
resolvedDuration: resDur,
|
|
469
|
+
currentName: curName,
|
|
470
|
+
layoutMap: layMap,
|
|
471
|
+
navContainerWidthRef: navCtrWRef
|
|
500
472
|
});
|
|
501
473
|
const {
|
|
502
474
|
navScrollRef,
|
|
@@ -506,171 +478,162 @@ const TabsBaseInner = (props, ref) => {
|
|
|
506
478
|
} = useTabsScroll({
|
|
507
479
|
scrollable,
|
|
508
480
|
animated,
|
|
509
|
-
currentName,
|
|
510
|
-
resolvedDuration,
|
|
511
|
-
layoutMap,
|
|
512
|
-
navContainerWidthRef,
|
|
513
|
-
navContentWidthRef
|
|
481
|
+
currentName: curName,
|
|
482
|
+
resolvedDuration: resDur,
|
|
483
|
+
layoutMap: layMap,
|
|
484
|
+
navContainerWidthRef: navCtrWRef,
|
|
485
|
+
navContentWidthRef: navCntWRef
|
|
514
486
|
});
|
|
515
|
-
const
|
|
487
|
+
const onTabLayout = useCallback((name, event) => {
|
|
516
488
|
const {
|
|
517
489
|
x,
|
|
518
490
|
width
|
|
519
491
|
} = event.nativeEvent.layout;
|
|
520
|
-
|
|
492
|
+
layMap.current.set(name, {
|
|
521
493
|
x,
|
|
522
494
|
width
|
|
523
495
|
});
|
|
524
|
-
if (name ===
|
|
496
|
+
if (name === curNameRef.current) {
|
|
525
497
|
const shouldAnimate = indicatorInitializedRef.current;
|
|
526
498
|
const didAnimate = animateIndicator(name, !shouldAnimate);
|
|
527
499
|
if (didAnimate && !indicatorInitializedRef.current) indicatorInitializedRef.current = true;
|
|
528
500
|
}
|
|
529
501
|
}, [animateIndicator, indicatorInitializedRef]);
|
|
530
|
-
const
|
|
502
|
+
const onNavCtrLayout = useCallback(event => {
|
|
531
503
|
const {
|
|
532
504
|
width
|
|
533
505
|
} = event.nativeEvent.layout;
|
|
534
|
-
|
|
535
|
-
if (!scrollable && align !== 'start' && type === 'line' &&
|
|
506
|
+
navCtrWRef.current = width;
|
|
507
|
+
if (!scrollable && align !== 'start' && type === 'line' && curName !== undefined && curName !== null) {
|
|
536
508
|
const shouldAnimate = indicatorInitializedRef.current;
|
|
537
|
-
const didAnimate = animateIndicator(
|
|
509
|
+
const didAnimate = animateIndicator(curName, !shouldAnimate);
|
|
538
510
|
if (didAnimate && !indicatorInitializedRef.current) indicatorInitializedRef.current = true;
|
|
539
511
|
}
|
|
540
|
-
}, [align, animateIndicator,
|
|
541
|
-
const
|
|
542
|
-
const
|
|
543
|
-
|
|
512
|
+
}, [align, animateIndicator, curName, scrollable, type, indicatorInitializedRef]);
|
|
513
|
+
const onCtrLayout = useCallback(event => {
|
|
514
|
+
const nextW = event.nativeEvent.layout.width;
|
|
515
|
+
setCtrW(prev => prev === nextW ? prev : nextW);
|
|
544
516
|
}, []);
|
|
545
|
-
const
|
|
546
|
-
|
|
517
|
+
const beforeChgRef = useRef(beforeChange);
|
|
518
|
+
beforeChgRef.current = beforeChange;
|
|
519
|
+
const runBeforeChg = useCallback(name => {
|
|
520
|
+
if (!beforeChgRef.current) return Promise.resolve(true);
|
|
547
521
|
try {
|
|
548
|
-
return Promise.resolve(
|
|
522
|
+
return Promise.resolve(beforeChgRef.current(name)).then(res => res !== false).catch(() => false);
|
|
549
523
|
} catch (error) {
|
|
550
524
|
return Promise.resolve(false);
|
|
551
525
|
}
|
|
552
|
-
}, [
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
const seq =
|
|
557
|
-
|
|
526
|
+
}, []);
|
|
527
|
+
const chgSeqRef = useRef(0);
|
|
528
|
+
const reqChg = useCallback((name, index) => {
|
|
529
|
+
chgSeqRef.current += 1;
|
|
530
|
+
const seq = chgSeqRef.current;
|
|
531
|
+
runBeforeChg(name).then(canChange => {
|
|
558
532
|
if (!canChange) return;
|
|
559
|
-
if (
|
|
560
|
-
|
|
533
|
+
if (chgSeqRef.current !== seq) return;
|
|
534
|
+
setActVal(name, index);
|
|
561
535
|
});
|
|
562
|
-
}, [
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
536
|
+
}, [runBeforeChg, setActVal]);
|
|
537
|
+
const onPaneLayout = useCallback((name, event) => {
|
|
538
|
+
if (isSwipe && swipeCfg?.autoHeight) {
|
|
565
539
|
const {
|
|
566
540
|
height
|
|
567
541
|
} = event.nativeEvent.layout;
|
|
568
|
-
|
|
542
|
+
paneLayMap.current.set(name, {
|
|
569
543
|
height
|
|
570
544
|
});
|
|
571
|
-
if (name ===
|
|
545
|
+
if (name === curName) setSwipeH(height);
|
|
572
546
|
}
|
|
573
|
-
}, [
|
|
574
|
-
const
|
|
547
|
+
}, [curName, isSwipe, swipeCfg?.autoHeight]);
|
|
548
|
+
const swipeEndIdxRef = useRef(null);
|
|
575
549
|
useEffect(() => {
|
|
576
|
-
|
|
577
|
-
}, [
|
|
578
|
-
const
|
|
579
|
-
if (!
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
const nextPane = panes[
|
|
584
|
-
if (!nextPane || nextPane.name ===
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}, [
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
}, [
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
}, [
|
|
550
|
+
swipeEndIdxRef.current = null;
|
|
551
|
+
}, [curName]);
|
|
552
|
+
const onSwipeEnd = useCallback(offsetX => {
|
|
553
|
+
if (!isSwipe || ctrW <= 0) return;
|
|
554
|
+
const pageIdx = Math.round(offsetX / ctrW);
|
|
555
|
+
if (swipeEndIdxRef.current === pageIdx) return;
|
|
556
|
+
swipeEndIdxRef.current = pageIdx;
|
|
557
|
+
const nextPane = panes[pageIdx];
|
|
558
|
+
if (!nextPane || nextPane.name === curNameRef.current) return;
|
|
559
|
+
swipeChgRef.current = true;
|
|
560
|
+
reqChg(nextPane.name, nextPane.index);
|
|
561
|
+
}, [ctrW, isSwipe, panes, reqChg]);
|
|
562
|
+
const onSwipeMomentumScrollEnd = useCallback(event => {
|
|
563
|
+
onSwipeEnd(event.nativeEvent.contentOffset.x);
|
|
564
|
+
}, [onSwipeEnd]);
|
|
565
|
+
const onSwipeScrollEndDrag = useCallback(event => {
|
|
566
|
+
onSwipeEnd(event.nativeEvent.contentOffset.x);
|
|
567
|
+
}, [onSwipeEnd]);
|
|
594
568
|
useEffect(() => {
|
|
595
|
-
if (!
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
if (swipeableChangeByScrollRef.current) {
|
|
599
|
-
swipeableChangeByScrollRef.current = false;
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
if (activeIndex < 0) {
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
const node = swipeableScrollRef.current?.getNode?.() ?? swipeableScrollRef.current;
|
|
606
|
-
if (!node?.scrollTo) {
|
|
569
|
+
if (!isSwipe || !swipeScrRef.current || ctrW <= 0) return;
|
|
570
|
+
if (swipeChgRef.current) {
|
|
571
|
+
swipeChgRef.current = false;
|
|
607
572
|
return;
|
|
608
573
|
}
|
|
574
|
+
if (actIdx < 0) return;
|
|
575
|
+
const node = swipeScrRef.current?.getNode?.() ?? swipeScrRef.current;
|
|
576
|
+
if (!node?.scrollTo) return;
|
|
609
577
|
node.scrollTo({
|
|
610
|
-
x:
|
|
578
|
+
x: ctrW * actIdx,
|
|
611
579
|
y: 0,
|
|
612
580
|
animated: true
|
|
613
581
|
});
|
|
614
|
-
}, [
|
|
615
|
-
const
|
|
582
|
+
}, [actIdx, ctrW, isSwipe]);
|
|
583
|
+
const onClickTabRef = useRef(onClickTab);
|
|
584
|
+
onClickTabRef.current = onClickTab;
|
|
585
|
+
const onSel = useCallback((pane, index, event) => {
|
|
616
586
|
const payload = {
|
|
617
587
|
name: pane.name,
|
|
618
588
|
index,
|
|
619
589
|
disabled: !!pane.disabled,
|
|
620
590
|
event
|
|
621
591
|
};
|
|
622
|
-
|
|
623
|
-
if (pane.disabled || pane.name ===
|
|
624
|
-
|
|
625
|
-
}, [
|
|
592
|
+
onClickTabRef.current?.(payload);
|
|
593
|
+
if (pane.disabled || pane.name === curNameRef.current) return;
|
|
594
|
+
reqChg(pane.name, index);
|
|
595
|
+
}, [reqChg]);
|
|
626
596
|
const scrollTo = useCallback((name, _options) => {
|
|
627
597
|
const target = panes.find(pane => pane.name === name && !pane.disabled);
|
|
628
598
|
if (!target) return;
|
|
629
|
-
|
|
630
|
-
}, [panes,
|
|
599
|
+
setActVal(target.name, target.index);
|
|
600
|
+
}, [panes, setActVal]);
|
|
631
601
|
useImperativeHandle(ref, () => ({
|
|
632
602
|
scrollTo
|
|
633
603
|
}), [scrollTo]);
|
|
634
|
-
const
|
|
604
|
+
const firstRndRef = useRef(true);
|
|
635
605
|
useEffect(() => {
|
|
636
|
-
if (
|
|
637
|
-
|
|
606
|
+
if (firstRndRef.current) {
|
|
607
|
+
firstRndRef.current = false;
|
|
638
608
|
scrollIntoView(true);
|
|
639
609
|
}
|
|
640
610
|
}, [scrollIntoView]);
|
|
641
611
|
useEffect(() => {
|
|
642
|
-
if (!
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const
|
|
647
|
-
const
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
borderRadius: indicatorCornerRadius,
|
|
661
|
-
backgroundColor: indicatorColor,
|
|
662
|
-
width: indicatorWidth,
|
|
663
|
-
bottom: indicatorBottom,
|
|
664
|
-
transform: [{
|
|
665
|
-
translateX: indicatorX
|
|
666
|
-
}]
|
|
612
|
+
if (!firstRndRef.current) scrollIntoView();
|
|
613
|
+
}, [curName, scrollIntoView]);
|
|
614
|
+
const hasBorder = border ?? false;
|
|
615
|
+
const showInd = type === 'line';
|
|
616
|
+
const navH = type === 'jumbo' ? tokens.jumbo.height : type === 'card' ? tokens.card.height : tokens.tabList.height;
|
|
617
|
+
const navPB = Platform.OS === 'web' && type !== 'line' && type !== 'card' ? tokens.tabList.paddingBottom : 0;
|
|
618
|
+
const indBot = showInd ? type === 'line' ? 0 : tokens.indicator.offset : 0;
|
|
619
|
+
if (panes.length === 0) return null;
|
|
620
|
+
const indicatorNode = showInd ? /*#__PURE__*/React.createElement(Animated.View, {
|
|
621
|
+
testID: "rv-tabs-indicator",
|
|
622
|
+
style: [S.ind, {
|
|
623
|
+
height: resLineH,
|
|
624
|
+
borderRadius: indRad,
|
|
625
|
+
backgroundColor: indColor,
|
|
626
|
+
width: indicatorWidth,
|
|
627
|
+
bottom: indBot,
|
|
628
|
+
transform: [{
|
|
629
|
+
translateX: indicatorX
|
|
667
630
|
}]
|
|
668
|
-
}
|
|
669
|
-
}
|
|
631
|
+
}]
|
|
632
|
+
}) : null;
|
|
670
633
|
const navItems = useMemo(() => panes.map(pane => /*#__PURE__*/React.createElement(TabBarItem, {
|
|
671
634
|
key: pane.key,
|
|
672
635
|
pane: pane,
|
|
673
|
-
isActive: pane.name ===
|
|
636
|
+
isActive: pane.name === curName,
|
|
674
637
|
align: align,
|
|
675
638
|
scrollable: scrollable,
|
|
676
639
|
type: type,
|
|
@@ -682,21 +645,21 @@ const TabsBaseInner = (props, ref) => {
|
|
|
682
645
|
tabStyle: tabStyle,
|
|
683
646
|
titleStyle: titleStyle,
|
|
684
647
|
descriptionStyle: descriptionStyle,
|
|
685
|
-
onSelect:
|
|
686
|
-
onLayout:
|
|
648
|
+
onSelect: onSel,
|
|
649
|
+
onLayout: onTabLayout,
|
|
687
650
|
isLast: pane.index === panes.length - 1
|
|
688
|
-
})), [align, color,
|
|
689
|
-
const
|
|
690
|
-
const prev =
|
|
691
|
-
|
|
692
|
-
if (prev === 0 ||
|
|
651
|
+
})), [align, color, curName, descriptionStyle, ellipsis, onSel, onTabLayout, panes, scrollable, tabStyle, titleActiveColor, titleInactiveColor, titleStyle, tokens, type]);
|
|
652
|
+
const onNavCntSizeChg = useCallback(w => {
|
|
653
|
+
const prev = navCntWRef.current;
|
|
654
|
+
navCntWRef.current = w;
|
|
655
|
+
if (prev === 0 || firstRndRef.current) {
|
|
693
656
|
scrollIntoView(true);
|
|
694
657
|
return;
|
|
695
658
|
}
|
|
696
659
|
if (Math.abs(w - prev) > 1) {
|
|
697
|
-
cancelFrame(
|
|
698
|
-
|
|
699
|
-
|
|
660
|
+
cancelFrame(navCntSyncRef.current);
|
|
661
|
+
navCntSyncRef.current = requestFrame(() => {
|
|
662
|
+
navCntSyncRef.current = null;
|
|
700
663
|
scrollIntoView();
|
|
701
664
|
});
|
|
702
665
|
}
|
|
@@ -709,50 +672,56 @@ const TabsBaseInner = (props, ref) => {
|
|
|
709
672
|
scrollEventThrottle: 16,
|
|
710
673
|
onScrollBeginDrag: handleNavScrollBeginDrag,
|
|
711
674
|
onScroll: handleNavScroll,
|
|
712
|
-
onContentSizeChange:
|
|
713
|
-
contentContainerStyle:
|
|
675
|
+
onContentSizeChange: onNavCntSizeChg,
|
|
676
|
+
contentContainerStyle: S.navC
|
|
714
677
|
}, navItems, indicatorNode) : /*#__PURE__*/React.createElement(View, {
|
|
715
678
|
accessibilityRole: "tablist",
|
|
716
|
-
style: [
|
|
679
|
+
style: [S.navC, S.navCSta]
|
|
717
680
|
}, navItems, indicatorNode);
|
|
718
681
|
const navContent = /*#__PURE__*/React.createElement(View, {
|
|
719
|
-
style: [
|
|
720
|
-
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
721
|
-
borderBottomColor: tokens.colors.border
|
|
722
|
-
} : null, {
|
|
682
|
+
style: [S.wrap, {
|
|
723
683
|
backgroundColor: background
|
|
724
684
|
}, tabBarStyle]
|
|
725
685
|
}, navLeft && /*#__PURE__*/React.createElement(View, {
|
|
726
|
-
style:
|
|
686
|
+
style: {
|
|
727
687
|
paddingHorizontal: tokens.spacing.navSidePaddingHorizontal
|
|
728
|
-
}
|
|
688
|
+
}
|
|
729
689
|
}, navLeft), /*#__PURE__*/React.createElement(View, {
|
|
730
|
-
style: [
|
|
731
|
-
minHeight:
|
|
732
|
-
paddingBottom:
|
|
690
|
+
style: [S.nav, {
|
|
691
|
+
minHeight: navH + navPB,
|
|
692
|
+
paddingBottom: navPB
|
|
733
693
|
}, type === 'card' ? {
|
|
734
|
-
borderWidth: StyleSheet.hairlineWidth,
|
|
735
694
|
borderRadius: tokens.card.radius,
|
|
736
|
-
borderColor: color ?? tokens.colors.cardBorder,
|
|
737
695
|
marginHorizontal: tokens.card.marginHorizontal,
|
|
738
696
|
overflow: 'hidden'
|
|
739
697
|
} : null],
|
|
740
|
-
onLayout:
|
|
741
|
-
}, navBody
|
|
742
|
-
style:
|
|
698
|
+
onLayout: onNavCtrLayout
|
|
699
|
+
}, navBody, type === 'card' && /*#__PURE__*/React.createElement(View, {
|
|
700
|
+
style: createHairlineView({
|
|
701
|
+
position: 'all',
|
|
702
|
+
color: color ?? tokens.colors.cardBorder,
|
|
703
|
+
borderRadius: tokens.card.radius
|
|
704
|
+
})
|
|
705
|
+
})), navRight && /*#__PURE__*/React.createElement(View, {
|
|
706
|
+
style: {
|
|
743
707
|
paddingHorizontal: tokens.spacing.navSidePaddingHorizontal
|
|
744
|
-
}]
|
|
745
|
-
}, navRight));
|
|
746
|
-
const paneNodes = useMemo(() => panes.map(pane => {
|
|
747
|
-
const isActive = pane.name === currentName;
|
|
748
|
-
const shouldRender = !lazyRender || isActive || visitedRef.current.has(pane.name);
|
|
749
|
-
if (!shouldRender && !isSwipeable) {
|
|
750
|
-
return null;
|
|
751
708
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
709
|
+
}, navRight), hasBorder && type === 'line' && /*#__PURE__*/React.createElement(View, {
|
|
710
|
+
style: createHairlineView({
|
|
711
|
+
position: 'bottom',
|
|
712
|
+
color: tokens.colors.border,
|
|
713
|
+
left: 0,
|
|
714
|
+
right: 0
|
|
715
|
+
})
|
|
716
|
+
}));
|
|
717
|
+
const paneNodes = useMemo(() => panes.map(pane => {
|
|
718
|
+
const isActive = pane.name === curName;
|
|
719
|
+
const shouldRender = !lazyRender || isActive || visRef.current.has(pane.name);
|
|
720
|
+
if (!shouldRender && !isSwipe) return null;
|
|
721
|
+
const layoutHandler = isSwipe && swipeCfg?.autoHeight ? event => onPaneLayout(pane.name, event) : undefined;
|
|
722
|
+
const paneStyles = [S.pane, isSwipe ? S.swipePane : null, isSwipe && ctrW > 0 && {
|
|
723
|
+
width: ctrW
|
|
724
|
+
}, !isSwipe && !isActive ? S.hidPane : null];
|
|
756
725
|
const paneContent = shouldRender ? pane.children : lazyRenderPlaceholder || null;
|
|
757
726
|
return /*#__PURE__*/React.createElement(View, {
|
|
758
727
|
key: pane.key,
|
|
@@ -760,37 +729,37 @@ const TabsBaseInner = (props, ref) => {
|
|
|
760
729
|
onLayout: layoutHandler,
|
|
761
730
|
style: paneStyles
|
|
762
731
|
}, paneContent);
|
|
763
|
-
}), [
|
|
764
|
-
const baseContentStyle =
|
|
765
|
-
const
|
|
766
|
-
height:
|
|
767
|
-
}]
|
|
768
|
-
const contentNode =
|
|
769
|
-
style:
|
|
732
|
+
}), [ctrW, curName, onPaneLayout, isSwipe, lazyRender, lazyRenderPlaceholder, panes, swipeCfg?.autoHeight]);
|
|
733
|
+
const baseContentStyle = [S.content, contentStyle];
|
|
734
|
+
const swipeContentStyle = [S.content, contentStyle, swipeCfg?.autoHeight && swipeH !== undefined && {
|
|
735
|
+
height: swipeH
|
|
736
|
+
}];
|
|
737
|
+
const contentNode = isSwipe ? /*#__PURE__*/React.createElement(View, {
|
|
738
|
+
style: swipeContentStyle
|
|
770
739
|
}, /*#__PURE__*/React.createElement(Animated.ScrollView, {
|
|
771
|
-
ref:
|
|
740
|
+
ref: swipeScrRef,
|
|
772
741
|
horizontal: true,
|
|
773
742
|
pagingEnabled: true,
|
|
774
743
|
scrollEventThrottle: 16,
|
|
775
744
|
showsHorizontalScrollIndicator: false,
|
|
776
|
-
onMomentumScrollEnd:
|
|
777
|
-
onScrollEndDrag:
|
|
778
|
-
nestedScrollEnabled:
|
|
779
|
-
directionalLockEnabled:
|
|
745
|
+
onMomentumScrollEnd: onSwipeMomentumScrollEnd,
|
|
746
|
+
onScrollEndDrag: onSwipeScrollEndDrag,
|
|
747
|
+
nestedScrollEnabled: swipeCfg?.preventScroll === false,
|
|
748
|
+
directionalLockEnabled: swipeCfg?.preventScroll !== false
|
|
780
749
|
}, paneNodes)) : /*#__PURE__*/React.createElement(View, {
|
|
781
750
|
style: baseContentStyle
|
|
782
751
|
}, paneNodes);
|
|
783
752
|
return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
784
|
-
style: [
|
|
785
|
-
onLayout:
|
|
753
|
+
style: [S.ctr, style],
|
|
754
|
+
onLayout: onCtrLayout
|
|
786
755
|
}), navContent, navBottom && /*#__PURE__*/React.createElement(View, {
|
|
787
|
-
style:
|
|
756
|
+
style: {
|
|
788
757
|
marginTop: tokens.spacing.navBottomMarginTop
|
|
789
|
-
}
|
|
758
|
+
}
|
|
790
759
|
}, navBottom), contentNode);
|
|
791
760
|
};
|
|
792
|
-
const
|
|
793
|
-
|
|
761
|
+
const S = StyleSheet.create({
|
|
762
|
+
ctr: {
|
|
794
763
|
width: '100%'
|
|
795
764
|
},
|
|
796
765
|
wrap: {
|
|
@@ -803,31 +772,29 @@ const styles = StyleSheet.create({
|
|
|
803
772
|
position: 'relative',
|
|
804
773
|
alignSelf: 'stretch'
|
|
805
774
|
},
|
|
806
|
-
|
|
775
|
+
navC: {
|
|
807
776
|
flexDirection: 'row',
|
|
808
777
|
alignItems: 'center',
|
|
809
778
|
height: '100%',
|
|
810
779
|
position: 'relative'
|
|
811
780
|
},
|
|
812
|
-
|
|
781
|
+
navCSta: {
|
|
813
782
|
flex: 1
|
|
814
783
|
},
|
|
815
|
-
|
|
816
|
-
navBottom: {},
|
|
817
|
-
labelWrapper: {
|
|
784
|
+
lblW: {
|
|
818
785
|
justifyContent: 'center',
|
|
819
786
|
alignItems: 'center',
|
|
820
787
|
flexDirection: 'column'
|
|
821
788
|
},
|
|
822
|
-
|
|
789
|
+
lblWJ: {
|
|
823
790
|
alignItems: 'center'
|
|
824
791
|
},
|
|
825
|
-
|
|
792
|
+
cardLbl: {
|
|
826
793
|
flexDirection: 'row',
|
|
827
794
|
justifyContent: 'center',
|
|
828
795
|
alignItems: 'center'
|
|
829
796
|
},
|
|
830
|
-
|
|
797
|
+
tabI: {
|
|
831
798
|
flexShrink: 0,
|
|
832
799
|
height: '100%',
|
|
833
800
|
alignSelf: 'stretch',
|
|
@@ -835,23 +802,20 @@ const styles = StyleSheet.create({
|
|
|
835
802
|
justifyContent: 'center',
|
|
836
803
|
flexDirection: 'row'
|
|
837
804
|
},
|
|
838
|
-
|
|
805
|
+
flexI: {
|
|
839
806
|
flexGrow: 1
|
|
840
807
|
},
|
|
841
808
|
title: {
|
|
842
809
|
includeFontPadding: false
|
|
843
810
|
},
|
|
844
|
-
|
|
811
|
+
descTxt: {
|
|
845
812
|
includeFontPadding: false
|
|
846
813
|
},
|
|
847
|
-
descriptionView: {},
|
|
848
814
|
ellipsis: {
|
|
849
815
|
maxWidth: '100%',
|
|
850
816
|
flexShrink: 1
|
|
851
817
|
},
|
|
852
|
-
|
|
853
|
-
badgeText: {},
|
|
854
|
-
indicator: {
|
|
818
|
+
ind: {
|
|
855
819
|
position: 'absolute',
|
|
856
820
|
bottom: 0,
|
|
857
821
|
left: 0
|
|
@@ -862,16 +826,15 @@ const styles = StyleSheet.create({
|
|
|
862
826
|
pane: {
|
|
863
827
|
width: '100%'
|
|
864
828
|
},
|
|
865
|
-
|
|
829
|
+
swipePane: {
|
|
866
830
|
flexShrink: 0
|
|
867
831
|
},
|
|
868
|
-
|
|
832
|
+
hidPane: {
|
|
869
833
|
display: 'none'
|
|
870
834
|
}
|
|
871
835
|
});
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
const TabsWithPane = Object.assign(TabsBase, {
|
|
836
|
+
const TabsBaseRef = /*#__PURE__*/React.forwardRef(TabsBaseInner);
|
|
837
|
+
const TabsWithPane = Object.assign(/*#__PURE__*/React.memo(TabsBaseRef), {
|
|
875
838
|
TabPane
|
|
876
839
|
});
|
|
877
840
|
export { TabPane };
|