@hero-design/rn 8.24.0-alpha.1 → 8.25.0
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/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-publish:npm.log +0 -9
- package/es/index.js +144 -166
- package/lib/index.js +144 -166
- package/package.json +5 -5
- package/src/components/Carousel/CardCarousel.tsx +23 -7
- package/src/components/Carousel/__tests__/CardCarousel.spec.tsx +177 -70
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +294 -1
- package/src/components/Error/StyledError.tsx +2 -0
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +8 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +3 -4
- package/src/components/Spinner/AnimatedSpinner.tsx +2 -2
- package/src/components/Success/__tests__/index.spec.tsx +6 -0
- package/src/components/Success/index.tsx +19 -0
- package/src/components/Tabs/{ScrollableTabsV2/SceneView.tsx → SceneView.tsx} +2 -2
- package/src/components/Tabs/ScrollableTabs.tsx +54 -48
- package/src/components/Tabs/{ScrollableTabsV2/__tests__ → __tests__}/SceneView.spec.tsx +3 -3
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +86 -28
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +1687 -49
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +1213 -29
- package/src/components/Tabs/__tests__/index.spec.tsx +58 -14
- package/src/components/Tabs/index.tsx +108 -102
- package/src/components/Tabs/useIsFocused.tsx +19 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +4 -0
- package/src/theme/components/error.ts +6 -1
- package/types/components/Accordion/AccordionItem.d.ts +0 -0
- package/types/components/Accordion/StyledAccordion.d.ts +0 -0
- package/types/components/Accordion/index.d.ts +0 -0
- package/types/components/Alert/StyledAlert.d.ts +0 -0
- package/types/components/Alert/index.d.ts +0 -0
- package/types/components/Attachment/StyledAttachment.d.ts +0 -0
- package/types/components/Attachment/index.d.ts +0 -0
- package/types/components/Avatar/Avatar.d.ts +0 -0
- package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +0 -0
- package/types/components/Avatar/AvatarStack/index.d.ts +0 -0
- package/types/components/Avatar/AvatarStack/utils.d.ts +0 -0
- package/types/components/Avatar/StyledAvatar.d.ts +0 -0
- package/types/components/Avatar/index.d.ts +0 -0
- package/types/components/Badge/Status.d.ts +0 -0
- package/types/components/Badge/StyledBadge.d.ts +0 -0
- package/types/components/Badge/index.d.ts +0 -0
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -0
- package/types/components/BottomNavigation/index.d.ts +0 -0
- package/types/components/BottomSheet/BottomSheetContext.d.ts +0 -0
- package/types/components/BottomSheet/Footer.d.ts +0 -0
- package/types/components/BottomSheet/Header.d.ts +0 -0
- package/types/components/BottomSheet/ScrollView.d.ts +0 -0
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +0 -0
- package/types/components/BottomSheet/index.d.ts +0 -0
- package/types/components/Box/StyledBox.d.ts +0 -0
- package/types/components/Box/config.d.ts +0 -0
- package/types/components/Box/index.d.ts +0 -0
- package/types/components/Box/types.d.ts +0 -0
- package/types/components/Button/Button.d.ts +0 -0
- package/types/components/Button/IconButton.d.ts +0 -0
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +0 -0
- package/types/components/Button/LoadingIndicator/index.d.ts +0 -0
- package/types/components/Button/StyledButton.d.ts +0 -0
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +0 -0
- package/types/components/Button/UtilityButton/index.d.ts +0 -0
- package/types/components/Button/index.d.ts +0 -0
- package/types/components/Calendar/CalendarRowItem.d.ts +0 -0
- package/types/components/Calendar/StyledCalendar.d.ts +0 -0
- package/types/components/Calendar/helpers.d.ts +0 -0
- package/types/components/Calendar/index.d.ts +0 -0
- package/types/components/Card/DataCard/StyledDataCard.d.ts +0 -0
- package/types/components/Card/DataCard/index.d.ts +0 -0
- package/types/components/Card/StyledCard.d.ts +0 -0
- package/types/components/Card/index.d.ts +0 -0
- package/types/components/Carousel/CardCarousel.d.ts +0 -0
- package/types/components/Carousel/CarouselItem.d.ts +0 -0
- package/types/components/Carousel/StyledCardCarousel.d.ts +0 -0
- package/types/components/Carousel/StyledCarousel.d.ts +0 -0
- package/types/components/Carousel/contants.d.ts +0 -0
- package/types/components/Carousel/index.d.ts +0 -0
- package/types/components/Carousel/types.d.ts +0 -0
- package/types/components/Checkbox/StyledCheckbox.d.ts +0 -0
- package/types/components/Checkbox/index.d.ts +0 -0
- package/types/components/Collapse/StyledCollapse.d.ts +0 -0
- package/types/components/Collapse/index.d.ts +0 -0
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +0 -0
- package/types/components/ContentNavigator/index.d.ts +0 -0
- package/types/components/DatePicker/DatePickerAndroid.d.ts +0 -0
- package/types/components/DatePicker/DatePickerCalendar.d.ts +0 -0
- package/types/components/DatePicker/DatePickerIOS.d.ts +0 -0
- package/types/components/DatePicker/StyledDatePicker.d.ts +0 -0
- package/types/components/DatePicker/index.d.ts +0 -0
- package/types/components/DatePicker/types.d.ts +0 -0
- package/types/components/Divider/StyledDivider.d.ts +0 -0
- package/types/components/Divider/index.d.ts +0 -0
- package/types/components/Drawer/DragableDrawer/helpers.d.ts +0 -0
- package/types/components/Drawer/DragableDrawer/index.d.ts +0 -0
- package/types/components/Drawer/StyledDrawer.d.ts +0 -0
- package/types/components/Drawer/index.d.ts +0 -0
- package/types/components/Empty/StyledEmpty.d.ts +0 -0
- package/types/components/Empty/index.d.ts +0 -0
- package/types/components/Error/StyledError.d.ts +0 -0
- package/types/components/Error/index.d.ts +0 -0
- package/types/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -0
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -0
- package/types/components/FAB/ActionGroup/index.d.ts +0 -0
- package/types/components/FAB/AnimatedFABIcon.d.ts +0 -0
- package/types/components/FAB/FAB.d.ts +0 -0
- package/types/components/FAB/StyledFAB.d.ts +0 -0
- package/types/components/FAB/index.d.ts +0 -0
- package/types/components/Icon/AnimatedIcon.d.ts +0 -0
- package/types/components/Icon/HeroIcon/index.d.ts +0 -0
- package/types/components/Icon/IconList.d.ts +0 -0
- package/types/components/Icon/index.d.ts +0 -0
- package/types/components/Icon/utils.d.ts +0 -0
- package/types/components/Image/index.d.ts +0 -0
- package/types/components/List/BasicListItem.d.ts +0 -0
- package/types/components/List/ListItem.d.ts +0 -0
- package/types/components/List/StyledBasicListItem.d.ts +0 -0
- package/types/components/List/StyledListItem.d.ts +0 -0
- package/types/components/List/index.d.ts +0 -0
- package/types/components/PageControl/StyledPageControl.d.ts +0 -0
- package/types/components/PageControl/index.d.ts +0 -0
- package/types/components/PinInput/PinCell.d.ts +0 -0
- package/types/components/PinInput/StyledPinInput.d.ts +0 -0
- package/types/components/PinInput/index.d.ts +0 -0
- package/types/components/Progress/ProgressBar.d.ts +0 -0
- package/types/components/Progress/ProgressCircle.d.ts +0 -0
- package/types/components/Progress/StyledProgressBar.d.ts +0 -0
- package/types/components/Progress/StyledProgressCircle.d.ts +0 -0
- package/types/components/Progress/__tests__/index.spec.d.ts +0 -0
- package/types/components/Progress/constants.d.ts +0 -0
- package/types/components/Progress/index.d.ts +0 -0
- package/types/components/Progress/types.d.ts +0 -0
- package/types/components/Radio/Radio.d.ts +0 -0
- package/types/components/Radio/RadioGroup.d.ts +0 -0
- package/types/components/Radio/StyledRadio.d.ts +0 -0
- package/types/components/Radio/index.d.ts +0 -0
- package/types/components/Radio/types.d.ts +0 -0
- package/types/components/RefreshControl/index.d.ts +0 -0
- package/types/components/RichTextEditor/EditorEvent.d.ts +0 -0
- package/types/components/RichTextEditor/EditorToolbar.d.ts +0 -0
- package/types/components/RichTextEditor/MentionList.d.ts +0 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +0 -0
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +0 -0
- package/types/components/RichTextEditor/StyledToolbar.d.ts +0 -0
- package/types/components/RichTextEditor/__mocks__/heroEditorApp.d.ts +0 -0
- package/types/components/RichTextEditor/constants.d.ts +0 -0
- package/types/components/RichTextEditor/heroEditorApp.d.ts +0 -0
- package/types/components/RichTextEditor/index.d.ts +0 -0
- package/types/components/RichTextEditor/types.d.ts +0 -0
- package/types/components/RichTextEditor/utils/events.d.ts +0 -0
- package/types/components/RichTextEditor/utils/rnWebView.d.ts +0 -0
- package/types/components/SectionHeading/StyledHeading.d.ts +0 -0
- package/types/components/SectionHeading/index.d.ts +0 -0
- package/types/components/Select/BaseOptionList.d.ts +0 -0
- package/types/components/Select/Footer.d.ts +0 -0
- package/types/components/Select/MultiSelect/Option.d.ts +0 -0
- package/types/components/Select/MultiSelect/OptionList.d.ts +0 -0
- package/types/components/Select/MultiSelect/index.d.ts +0 -0
- package/types/components/Select/SingleSelect/Option.d.ts +0 -0
- package/types/components/Select/SingleSelect/OptionList.d.ts +0 -0
- package/types/components/Select/SingleSelect/StyledSingleSelect.d.ts +0 -0
- package/types/components/Select/SingleSelect/index.d.ts +0 -0
- package/types/components/Select/StyledSelect.d.ts +0 -0
- package/types/components/Select/helpers.d.ts +0 -0
- package/types/components/Select/index.d.ts +0 -0
- package/types/components/Select/types.d.ts +0 -0
- package/types/components/Skeleton/StyledSkeleton.d.ts +0 -0
- package/types/components/Skeleton/index.d.ts +0 -0
- package/types/components/Slider/index.d.ts +0 -0
- package/types/components/Spinner/AnimatedSpinner.d.ts +0 -0
- package/types/components/Spinner/StyledSpinner.d.ts +0 -0
- package/types/components/Spinner/index.d.ts +0 -0
- package/types/components/Success/StyledSuccess.d.ts +0 -0
- package/types/components/Success/index.d.ts +8 -0
- package/types/components/Swipeable/StyledSwipeable.d.ts +0 -0
- package/types/components/Swipeable/SwipeableAction.d.ts +0 -0
- package/types/components/Swipeable/index.d.ts +0 -0
- package/types/components/Switch/SelectorSwitch/Option.d.ts +0 -0
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +0 -0
- package/types/components/Switch/SelectorSwitch/index.d.ts +0 -0
- package/types/components/Switch/StyledSwitch.d.ts +0 -0
- package/types/components/Switch/index.d.ts +0 -0
- package/types/components/Tabs/ActiveTabIndicator.d.ts +0 -0
- package/types/components/Tabs/SceneView.d.ts +4 -3
- package/types/components/Tabs/ScrollableTabs.d.ts +0 -0
- package/types/components/Tabs/ScrollableTabsHeader.d.ts +0 -0
- package/types/components/Tabs/StyledScrollableTabs.d.ts +0 -0
- package/types/components/Tabs/StyledTabs.d.ts +0 -0
- package/types/components/Tabs/TabWithBadge.d.ts +0 -0
- package/types/components/Tabs/index.d.ts +1 -3
- package/types/components/Tabs/useIsFocused.d.ts +6 -0
- package/types/components/Tabs/utils.d.ts +0 -0
- package/types/components/Tag/StyledTag.d.ts +0 -0
- package/types/components/Tag/index.d.ts +0 -0
- package/types/components/TextInput/StyledTextInput.d.ts +0 -0
- package/types/components/TextInput/index.d.ts +0 -0
- package/types/components/TimePicker/StyledTimePicker.d.ts +0 -0
- package/types/components/TimePicker/TimePickerAndroid.d.ts +0 -0
- package/types/components/TimePicker/TimePickerIOS.d.ts +0 -0
- package/types/components/TimePicker/index.d.ts +0 -0
- package/types/components/TimePicker/types.d.ts +0 -0
- package/types/components/Toast/StyledToast.d.ts +0 -0
- package/types/components/Toast/Toast.d.ts +0 -0
- package/types/components/Toast/ToastContainer.d.ts +0 -0
- package/types/components/Toast/ToastContext.d.ts +0 -0
- package/types/components/Toast/ToastProvider.d.ts +0 -0
- package/types/components/Toast/index.d.ts +0 -0
- package/types/components/Toast/types.d.ts +0 -0
- package/types/components/Toolbar/StyledToolbar.d.ts +0 -0
- package/types/components/Toolbar/ToolbarGroup.d.ts +0 -0
- package/types/components/Toolbar/ToolbarItem.d.ts +0 -0
- package/types/components/Toolbar/index.d.ts +0 -0
- package/types/components/Typography/Text/StyledText.d.ts +0 -0
- package/types/components/Typography/Text/index.d.ts +0 -0
- package/types/components/Typography/index.d.ts +0 -0
- package/types/index.d.ts +0 -0
- package/types/testHelpers/renderWithTheme.d.ts +0 -0
- package/types/theme/ThemeProvider.d.ts +0 -0
- package/types/theme/ThemeSwitcher.d.ts +0 -0
- package/types/theme/components/accordion.d.ts +0 -0
- package/types/theme/components/alert.d.ts +0 -0
- package/types/theme/components/attachment.d.ts +0 -0
- package/types/theme/components/avatar.d.ts +0 -0
- package/types/theme/components/badge.d.ts +0 -0
- package/types/theme/components/bottomNavigation.d.ts +0 -0
- package/types/theme/components/bottomSheet.d.ts +0 -0
- package/types/theme/components/button.d.ts +0 -0
- package/types/theme/components/calendar.d.ts +0 -0
- package/types/theme/components/card.d.ts +0 -0
- package/types/theme/components/cardCarousel.d.ts +0 -0
- package/types/theme/components/carousel.d.ts +0 -0
- package/types/theme/components/checkbox.d.ts +0 -0
- package/types/theme/components/contentNavigator.d.ts +0 -0
- package/types/theme/components/datePicker.d.ts +0 -0
- package/types/theme/components/divider.d.ts +0 -0
- package/types/theme/components/drawer.d.ts +0 -0
- package/types/theme/components/empty.d.ts +0 -0
- package/types/theme/components/error.d.ts +4 -0
- package/types/theme/components/fab.d.ts +0 -0
- package/types/theme/components/icon.d.ts +0 -0
- package/types/theme/components/image.d.ts +0 -0
- package/types/theme/components/list.d.ts +0 -0
- package/types/theme/components/pageControl.d.ts +0 -0
- package/types/theme/components/pinInput.d.ts +0 -0
- package/types/theme/components/progress.d.ts +0 -0
- package/types/theme/components/radio.d.ts +0 -0
- package/types/theme/components/refreshControl.d.ts +0 -0
- package/types/theme/components/richTextEditor.d.ts +0 -0
- package/types/theme/components/sectionHeading.d.ts +0 -0
- package/types/theme/components/select.d.ts +0 -0
- package/types/theme/components/skeleton.d.ts +0 -0
- package/types/theme/components/slider.d.ts +0 -0
- package/types/theme/components/spinner.d.ts +0 -0
- package/types/theme/components/success.d.ts +0 -0
- package/types/theme/components/swipeable.d.ts +0 -0
- package/types/theme/components/switch.d.ts +0 -0
- package/types/theme/components/tabs.d.ts +0 -0
- package/types/theme/components/tag.d.ts +0 -0
- package/types/theme/components/textInput.d.ts +0 -0
- package/types/theme/components/timePicker.d.ts +0 -0
- package/types/theme/components/toast.d.ts +0 -0
- package/types/theme/components/toolbar.d.ts +0 -0
- package/types/theme/components/typography.d.ts +0 -0
- package/types/theme/getTheme.d.ts +0 -0
- package/types/theme/global/borders.d.ts +0 -0
- package/types/theme/global/colors/eBens.d.ts +0 -0
- package/types/theme/global/colors/global.d.ts +0 -0
- package/types/theme/global/colors/globalDark.d.ts +0 -0
- package/types/theme/global/colors/jobs.d.ts +0 -0
- package/types/theme/global/colors/swag.d.ts +0 -0
- package/types/theme/global/colors/swagDark.d.ts +0 -0
- package/types/theme/global/colors/types.d.ts +0 -0
- package/types/theme/global/colors/wallet.d.ts +0 -0
- package/types/theme/global/colors/work.d.ts +0 -0
- package/types/theme/global/index.d.ts +0 -0
- package/types/theme/global/scale.d.ts +0 -0
- package/types/theme/global/sizes.d.ts +0 -0
- package/types/theme/global/space.d.ts +0 -0
- package/types/theme/global/typography.d.ts +0 -0
- package/types/theme/index.d.ts +0 -0
- package/types/types.d.ts +0 -0
- package/types/utils/functions.d.ts +0 -0
- package/types/utils/helpers.d.ts +0 -0
- package/types/utils/hooks.d.ts +0 -0
- package/types/utils/scale.d.ts +0 -0
- package/.turbo/turbo-build:types.log +0 -2
- package/.turbo/turbo-lint.log +0 -146
- package/.turbo/turbo-test.log +0 -451
- package/.turbo/turbo-type-check.log +0 -1
- package/src/components/Tabs/ScrollableTabsV2/ScrollableTabsV2.tsx +0 -120
- package/src/components/Tabs/ScrollableTabsV2/__tests__/ScrollableTabsV2.spec.tsx +0 -166
- package/src/components/Tabs/ScrollableTabsV2/__tests__/__snapshots__/ScrollableTabsV2.spec.tsx.snap +0 -2497
- package/src/components/Tabs/ScrollableTabsV2/index.tsx +0 -5
- package/types/components/Tabs/ScrollableTabsV2/SceneView.d.ts +0 -10
- package/types/components/Tabs/ScrollableTabsV2/ScrollableTabsV2.d.ts +0 -9
- package/types/components/Tabs/ScrollableTabsV2/index.d.ts +0 -4
- /package/src/components/Tabs/{ScrollableTabsV2/__tests__ → __tests__}/__snapshots__/SceneView.spec.tsx.snap +0 -0
|
@@ -61,6 +61,7 @@ describe('Success', () => {
|
|
|
61
61
|
});
|
|
62
62
|
it('handles CTA press correctly', () => {
|
|
63
63
|
const onCtaPress = jest.fn();
|
|
64
|
+
const onSecondCtaPress = jest.fn();
|
|
64
65
|
const { getByText } = renderWithTheme(
|
|
65
66
|
<Success
|
|
66
67
|
title={title}
|
|
@@ -68,11 +69,16 @@ describe('Success', () => {
|
|
|
68
69
|
image="path_to_image"
|
|
69
70
|
ctaText="CTA Text"
|
|
70
71
|
onCtaPress={onCtaPress}
|
|
72
|
+
secondaryCtaText="Second CTA Text"
|
|
73
|
+
onSecondaryCtaPress={onSecondCtaPress}
|
|
71
74
|
/>
|
|
72
75
|
);
|
|
73
76
|
|
|
74
77
|
const CTA = getByText('CTA Text');
|
|
75
78
|
fireEvent.press(CTA);
|
|
79
|
+
const secondCTA = getByText('Second CTA Text');
|
|
80
|
+
fireEvent.press(secondCTA);
|
|
76
81
|
expect(onCtaPress).toBeCalledTimes(1);
|
|
82
|
+
expect(onSecondCtaPress).toBeCalledTimes(1);
|
|
77
83
|
});
|
|
78
84
|
});
|
|
@@ -47,6 +47,14 @@ export interface SuccessProps extends ViewProps {
|
|
|
47
47
|
* Callback when the action button is pressed.
|
|
48
48
|
*/
|
|
49
49
|
onCtaPress?: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Secondary button text.
|
|
52
|
+
*/
|
|
53
|
+
secondaryCtaText?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Callback when the secondary button is pressed.
|
|
56
|
+
*/
|
|
57
|
+
onSecondaryCtaPress?: () => void;
|
|
50
58
|
/**
|
|
51
59
|
* Testing id of the component.
|
|
52
60
|
*/
|
|
@@ -78,8 +86,12 @@ const SuccessPage = ({
|
|
|
78
86
|
testID,
|
|
79
87
|
ctaText,
|
|
80
88
|
onCtaPress = noop,
|
|
89
|
+
secondaryCtaText,
|
|
90
|
+
onSecondaryCtaPress,
|
|
81
91
|
...nativeProps
|
|
82
92
|
}: SuccessProps): ReactElement => {
|
|
93
|
+
const showSecondaryButton = secondaryCtaText && onSecondaryCtaPress;
|
|
94
|
+
|
|
83
95
|
return (
|
|
84
96
|
<StyledSuccessContainer
|
|
85
97
|
testID={testID}
|
|
@@ -102,6 +114,13 @@ const SuccessPage = ({
|
|
|
102
114
|
{!!ctaText && (
|
|
103
115
|
<StyledSuccessButtonContainer>
|
|
104
116
|
<StyledSuccessButtonPrimary text={ctaText} onPress={onCtaPress} />
|
|
117
|
+
{!!showSecondaryButton && (
|
|
118
|
+
<StyledSuccessButtonPrimary
|
|
119
|
+
variant="text"
|
|
120
|
+
text={secondaryCtaText}
|
|
121
|
+
onPress={onSecondaryCtaPress}
|
|
122
|
+
/>
|
|
123
|
+
)}
|
|
105
124
|
</StyledSuccessButtonContainer>
|
|
106
125
|
)}
|
|
107
126
|
</StyledSuccessContainer>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleSheet } from 'react-native';
|
|
3
|
-
import { TabScreen } from '
|
|
3
|
+
import { TabScreen } from './StyledScrollableTabs';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const SceneView = ({
|
|
6
6
|
lazy = false,
|
|
7
7
|
lazyPreloadDistance = 1,
|
|
8
8
|
children,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
3
|
import PagerView from 'react-native-pager-view';
|
|
4
|
-
import {
|
|
5
|
-
TabContainer,
|
|
6
|
-
TabScreen,
|
|
7
|
-
ContentWrapper,
|
|
8
|
-
} from './StyledScrollableTabs';
|
|
4
|
+
import { TabContainer, ContentWrapper } from './StyledScrollableTabs';
|
|
9
5
|
import type { TabsProps } from '.';
|
|
6
|
+
import SceneView from './SceneView';
|
|
10
7
|
import ScrollableTabHeader from './ScrollableTabsHeader';
|
|
8
|
+
import { ScreenContext, TabContext } from './useIsFocused';
|
|
11
9
|
|
|
12
10
|
const ScrollableTab = ({
|
|
13
11
|
onTabPress,
|
|
@@ -25,6 +23,7 @@ const ScrollableTab = ({
|
|
|
25
23
|
const selectedTabIndex = tabs.findIndex(
|
|
26
24
|
(item) => item.key === selectedTabKey
|
|
27
25
|
);
|
|
26
|
+
|
|
28
27
|
React.useEffect(() => {
|
|
29
28
|
let timeoutHandle: number | null = null;
|
|
30
29
|
if (selectedTabIndex !== -1) {
|
|
@@ -43,51 +42,58 @@ const ScrollableTab = ({
|
|
|
43
42
|
};
|
|
44
43
|
}, [selectedTabIndex, pagerViewRef]);
|
|
45
44
|
|
|
45
|
+
const tabContextProviderValue = React.useMemo(
|
|
46
|
+
() => ({
|
|
47
|
+
selectedTabKey,
|
|
48
|
+
}),
|
|
49
|
+
[selectedTabKey]
|
|
50
|
+
);
|
|
51
|
+
|
|
46
52
|
return (
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
<TabContext.Provider value={tabContextProviderValue}>
|
|
54
|
+
<TabContainer style={containerStyle} testID={componentTestID}>
|
|
55
|
+
<ScrollableTabHeader
|
|
56
|
+
tabs={tabs}
|
|
57
|
+
selectedIndex={selectedTabIndex}
|
|
58
|
+
onTabPress={onTabPress}
|
|
59
|
+
barStyle={barStyle}
|
|
60
|
+
insets={insets}
|
|
61
|
+
testID={componentTestID ? `${componentTestID}-tab-bar` : undefined}
|
|
62
|
+
/>
|
|
63
|
+
<ContentWrapper
|
|
64
|
+
initialPage={selectedTabIndex}
|
|
65
|
+
ref={pagerViewRef}
|
|
66
|
+
onPageSelected={(e) => {
|
|
67
|
+
const index = e.nativeEvent.position;
|
|
68
|
+
const selectedItem = tabs[index];
|
|
69
|
+
if (selectedItem) {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
onTabPress(selectedItem.key);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}}
|
|
75
|
+
scrollEnabled={swipeEnabled}
|
|
76
|
+
>
|
|
77
|
+
{tabs.map((tab, index) => {
|
|
78
|
+
const { key, component, testID } = tab;
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
</
|
|
90
|
-
</
|
|
80
|
+
return (
|
|
81
|
+
<ScreenContext.Provider value={key} key={key}>
|
|
82
|
+
<SceneView
|
|
83
|
+
testID={testID}
|
|
84
|
+
index={index}
|
|
85
|
+
selectedIndex={selectedTabIndex}
|
|
86
|
+
lazy={lazy}
|
|
87
|
+
lazyPreloadDistance={lazyPreloadDistance}
|
|
88
|
+
>
|
|
89
|
+
{component}
|
|
90
|
+
</SceneView>
|
|
91
|
+
</ScreenContext.Provider>
|
|
92
|
+
);
|
|
93
|
+
})}
|
|
94
|
+
</ContentWrapper>
|
|
95
|
+
</TabContainer>
|
|
96
|
+
</TabContext.Provider>
|
|
91
97
|
);
|
|
92
98
|
};
|
|
93
99
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ThemeProvider } from '@emotion/react';
|
|
3
|
-
import renderWithTheme from '
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
4
|
import ScenceView from '../SceneView';
|
|
5
|
-
import Typography from '
|
|
6
|
-
import { theme } from '
|
|
5
|
+
import Typography from '../../Typography';
|
|
6
|
+
import { theme } from '../../../index';
|
|
7
7
|
|
|
8
8
|
describe('ScenceView', () => {
|
|
9
9
|
describe('lazy', () => {
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
|
-
import { fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import { fireEvent, waitFor } from '@testing-library/react-native';
|
|
4
4
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
5
5
|
import type { ComponentProps } from 'react';
|
|
6
6
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
7
|
-
import
|
|
7
|
+
import ScrollableTabs from '../ScrollableTabs';
|
|
8
8
|
import Button from '../../Button';
|
|
9
9
|
import type { TabType } from '..';
|
|
10
|
+
import { useIsFocused } from '../useIsFocused';
|
|
10
11
|
|
|
12
|
+
const CustomScreen = ({ title }: { title: string }) => {
|
|
13
|
+
const isFocused = useIsFocused();
|
|
14
|
+
return (
|
|
15
|
+
<Text>
|
|
16
|
+
{title} {isFocused ? 'focused' : 'unfocused'}
|
|
17
|
+
</Text>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
11
20
|
const TestTabsComponent = (
|
|
12
21
|
props: Omit<
|
|
13
|
-
ComponentProps<typeof
|
|
22
|
+
ComponentProps<typeof ScrollableTabs>,
|
|
14
23
|
'selectedTabKey' | 'onTabPress' | 'tabs'
|
|
15
24
|
>
|
|
16
25
|
) => {
|
|
@@ -19,19 +28,19 @@ const TestTabsComponent = (
|
|
|
19
28
|
{
|
|
20
29
|
key: 'work',
|
|
21
30
|
activeItem: 'Work',
|
|
22
|
-
component: <
|
|
31
|
+
component: <CustomScreen title="Work Screen" />,
|
|
23
32
|
},
|
|
24
33
|
{
|
|
25
34
|
key: 'personal',
|
|
26
35
|
activeItem: 'speaker',
|
|
27
36
|
inactiveItem: 'speaker-outlined',
|
|
28
|
-
component: <
|
|
37
|
+
component: <CustomScreen title="Personal Screen" />,
|
|
29
38
|
},
|
|
30
39
|
{
|
|
31
40
|
key: 'home',
|
|
32
41
|
activeItem: 'home',
|
|
33
42
|
inactiveItem: 'home-outlined',
|
|
34
|
-
component: <
|
|
43
|
+
component: <CustomScreen title="Home Screen" />,
|
|
35
44
|
badge: {
|
|
36
45
|
type: 'status',
|
|
37
46
|
},
|
|
@@ -40,7 +49,7 @@ const TestTabsComponent = (
|
|
|
40
49
|
key: 'calendar',
|
|
41
50
|
activeItem: 'calendar',
|
|
42
51
|
inactiveItem: 'calendar-dates-outlined',
|
|
43
|
-
component: <
|
|
52
|
+
component: <CustomScreen title="Calendar Screen" />,
|
|
44
53
|
badge: {
|
|
45
54
|
type: 'counter',
|
|
46
55
|
value: 50,
|
|
@@ -60,7 +69,7 @@ const TestTabsComponent = (
|
|
|
60
69
|
onPress={() => setSelectedTabKey('work')}
|
|
61
70
|
icon="sync"
|
|
62
71
|
/>
|
|
63
|
-
<
|
|
72
|
+
<ScrollableTabs
|
|
64
73
|
{...props}
|
|
65
74
|
tabs={tabs}
|
|
66
75
|
selectedTabKey={selectedTabKey}
|
|
@@ -71,7 +80,7 @@ const TestTabsComponent = (
|
|
|
71
80
|
};
|
|
72
81
|
|
|
73
82
|
describe('Tabs.Scroll', () => {
|
|
74
|
-
it('renders correctly', () => {
|
|
83
|
+
it('renders correctly', async () => {
|
|
75
84
|
const { getByTestId, getByText, toJSON } = renderWithTheme(
|
|
76
85
|
<TestTabsComponent />
|
|
77
86
|
);
|
|
@@ -80,30 +89,79 @@ describe('Tabs.Scroll', () => {
|
|
|
80
89
|
expect(getByText('Work')).toBeDefined();
|
|
81
90
|
expect(getByTestId('hero-icon-speaker-outlined')).toBeDefined();
|
|
82
91
|
expect(getByTestId('hero-icon-home-outlined')).toBeDefined();
|
|
83
|
-
expect(getByText('Work Screen')).toBeDefined();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
expect(getByText('
|
|
90
|
-
expect(getByText('
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
expect(getByText('Work Screen focused')).toBeDefined();
|
|
93
|
+
expect(getByText('Personal Screen unfocused')).toBeDefined();
|
|
94
|
+
await waitFor(() =>
|
|
95
|
+
expect(getByText('Home Screen unfocused')).toBeDefined()
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(getByText('Home Screen unfocused')).toBeDefined();
|
|
99
|
+
expect(getByText('Calendar Screen unfocused')).toBeDefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('lazy', () => {
|
|
103
|
+
it('render all screens when lazy = false', async () => {
|
|
104
|
+
const { queryByText } = renderWithTheme(
|
|
105
|
+
<TestTabsComponent lazy={false} />
|
|
106
|
+
);
|
|
107
|
+
expect(queryByText('Work Screen focused')).toBeDefined();
|
|
108
|
+
expect(queryByText('Personal Screen unfocused')).toBeDefined();
|
|
109
|
+
await waitFor(() =>
|
|
110
|
+
expect(queryByText('Home Screen unfocused')).toBeDefined()
|
|
111
|
+
);
|
|
112
|
+
expect(queryByText('Home Screen unfocused')).toBeDefined();
|
|
113
|
+
expect(queryByText('Calendar Screen unfocused')).toBeDefined();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('not render lazy screen', async () => {
|
|
117
|
+
const { toJSON, queryByText } = renderWithTheme(
|
|
118
|
+
<TestTabsComponent lazyPreloadDistance={1} lazy />
|
|
119
|
+
);
|
|
120
|
+
expect(queryByText('Work Screen focused')).toBeDefined();
|
|
121
|
+
expect(queryByText('Personal Screen unfocused')).toBeDefined();
|
|
122
|
+
await waitFor(() =>
|
|
123
|
+
expect(queryByText('Home Screen unfocused')).toBeDefined()
|
|
124
|
+
);
|
|
125
|
+
expect(toJSON()).toMatchSnapshot('xxx');
|
|
126
|
+
expect(queryByText('Home Screen unfocused')).toBeDefined();
|
|
127
|
+
expect(queryByText('Calendar Screen unfocused')).toBeNull();
|
|
128
|
+
});
|
|
93
129
|
});
|
|
130
|
+
});
|
|
94
131
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
132
|
+
describe('useIsFocused', () => {
|
|
133
|
+
it('renders correctly', async () => {
|
|
134
|
+
const { getByTestId, getByText, toJSON } = renderWithTheme(
|
|
135
|
+
<TestTabsComponent />
|
|
98
136
|
);
|
|
99
137
|
|
|
100
|
-
expect(
|
|
101
|
-
expect(getByText('
|
|
102
|
-
|
|
103
|
-
expect(
|
|
138
|
+
expect(toJSON()).toMatchSnapshot();
|
|
139
|
+
expect(getByText('Work')).toBeDefined();
|
|
140
|
+
expect(getByTestId('hero-icon-speaker-outlined')).toBeDefined();
|
|
141
|
+
expect(getByTestId('hero-icon-home-outlined')).toBeDefined();
|
|
142
|
+
await waitFor(() => expect(getByText('Work Screen focused')).toBeDefined());
|
|
143
|
+
expect(getByText('Work Screen focused')).toBeDefined();
|
|
144
|
+
expect(getByText('Personal Screen unfocused')).toBeDefined();
|
|
145
|
+
expect(getByText('Home Screen unfocused')).toBeDefined();
|
|
146
|
+
expect(getByText('Calendar Screen unfocused')).toBeDefined();
|
|
147
|
+
|
|
148
|
+
fireEvent.press(getByTestId('hero-icon-speaker-outlined'));
|
|
149
|
+
expect(getByText('Personal Screen focused')).toBeDefined();
|
|
150
|
+
expect(getByText('Work Screen unfocused')).toBeDefined();
|
|
151
|
+
expect(getByText('Home Screen unfocused')).toBeDefined();
|
|
152
|
+
expect(getByText('Calendar Screen unfocused')).toBeDefined();
|
|
104
153
|
|
|
105
154
|
fireEvent.press(getByTestId('hero-icon-home-outlined'));
|
|
106
|
-
expect(getByText('
|
|
107
|
-
expect(
|
|
155
|
+
expect(getByText('Personal Screen unfocused')).toBeDefined();
|
|
156
|
+
expect(getByText('Work Screen unfocused')).toBeDefined();
|
|
157
|
+
expect(getByText('Home Screen focused')).toBeDefined();
|
|
158
|
+
expect(getByText('Calendar Screen unfocused')).toBeDefined();
|
|
159
|
+
|
|
160
|
+
fireEvent.press(getByTestId('hero-icon-calendar-dates-outlined'));
|
|
161
|
+
expect(getByText('Personal Screen unfocused')).toBeDefined();
|
|
162
|
+
expect(getByText('Work Screen unfocused')).toBeDefined();
|
|
163
|
+
expect(getByText('Home Screen unfocused')).toBeDefined();
|
|
164
|
+
expect(getByText('Calendar Screen focused')).toBeDefined();
|
|
165
|
+
expect(getByText('50')).toBeDefined();
|
|
108
166
|
});
|
|
109
167
|
});
|