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