@hero-design/rn 8.24.0-alpha.0 → 8.24.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 +3 -3
- package/.turbo/turbo-publish:npm.log +0 -9
- package/es/index.js +79 -147
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +79 -147
- package/package.json +5 -5
- package/src/components/RichTextEditor/RichTextEditor.tsx +3 -4
- 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/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 +0 -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
package/lib/index.js
CHANGED
|
@@ -14968,7 +14968,7 @@ var StyledSuccessModal = index$a(reactNative.Modal)({
|
|
|
14968
14968
|
width: '100%'
|
|
14969
14969
|
});
|
|
14970
14970
|
|
|
14971
|
-
var _excluded$2 = ["variant", "title", "description", "image", "testID", "ctaText", "onCtaPress"];
|
|
14971
|
+
var _excluded$2 = ["variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"];
|
|
14972
14972
|
var renderImage = function renderImage(image) {
|
|
14973
14973
|
if ( /*#__PURE__*/React.isValidElement(image)) {
|
|
14974
14974
|
return /*#__PURE__*/React__default["default"].cloneElement(image, {
|
|
@@ -14992,13 +14992,20 @@ var SuccessPage = function SuccessPage(_ref) {
|
|
|
14992
14992
|
ctaText = _ref.ctaText,
|
|
14993
14993
|
_ref$onCtaPress = _ref.onCtaPress,
|
|
14994
14994
|
onCtaPress = _ref$onCtaPress === void 0 ? noop$1 : _ref$onCtaPress,
|
|
14995
|
+
secondaryCtaText = _ref.secondaryCtaText,
|
|
14996
|
+
onSecondaryCtaPress = _ref.onSecondaryCtaPress,
|
|
14995
14997
|
nativeProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
14998
|
+
var showSecondaryButton = secondaryCtaText && onSecondaryCtaPress;
|
|
14996
14999
|
return /*#__PURE__*/React__default["default"].createElement(StyledSuccessContainer, _extends$1({
|
|
14997
15000
|
testID: testID,
|
|
14998
15001
|
themeVariant: variant
|
|
14999
15002
|
}, nativeProps), /*#__PURE__*/React__default["default"].createElement(StyledSuccessContent, null, !!image && /*#__PURE__*/React__default["default"].createElement(StyledSuccessImageContainer, null, renderImage(image)), /*#__PURE__*/React__default["default"].createElement(StyledSuccessTitle, null, title), !!description && /*#__PURE__*/React__default["default"].createElement(StyledSuccessDescription, null, description)), !!ctaText && /*#__PURE__*/React__default["default"].createElement(StyledSuccessButtonContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledSuccessButtonPrimary, {
|
|
15000
15003
|
text: ctaText,
|
|
15001
15004
|
onPress: onCtaPress
|
|
15005
|
+
}), !!showSecondaryButton && /*#__PURE__*/React__default["default"].createElement(StyledSuccessButtonPrimary, {
|
|
15006
|
+
variant: "text",
|
|
15007
|
+
text: secondaryCtaText,
|
|
15008
|
+
onPress: onSecondaryCtaPress
|
|
15002
15009
|
})));
|
|
15003
15010
|
};
|
|
15004
15011
|
/**
|
|
@@ -15213,7 +15220,7 @@ var HeaderTabItem$1 = index$a(reactNative.View)(function (_ref2) {
|
|
|
15213
15220
|
var ContentWrapper$1 = index$a(AnimatedPagerView)({
|
|
15214
15221
|
flex: 1
|
|
15215
15222
|
});
|
|
15216
|
-
|
|
15223
|
+
index$a(reactNative.View)({
|
|
15217
15224
|
flex: 1
|
|
15218
15225
|
});
|
|
15219
15226
|
var StyledIndicator = index$a(reactNative.Animated.View)(function (_ref3) {
|
|
@@ -15302,6 +15309,48 @@ var HeaderTabItemWrapper = index$a(reactNative.View)(function (_ref5) {
|
|
|
15302
15309
|
};
|
|
15303
15310
|
});
|
|
15304
15311
|
|
|
15312
|
+
var SceneView = function SceneView(_ref) {
|
|
15313
|
+
var _ref$lazy = _ref.lazy,
|
|
15314
|
+
lazy = _ref$lazy === void 0 ? false : _ref$lazy,
|
|
15315
|
+
_ref$lazyPreloadDista = _ref.lazyPreloadDistance,
|
|
15316
|
+
lazyPreloadDistance = _ref$lazyPreloadDista === void 0 ? 1 : _ref$lazyPreloadDista,
|
|
15317
|
+
children = _ref.children,
|
|
15318
|
+
index = _ref.index,
|
|
15319
|
+
selectedIndex = _ref.selectedIndex,
|
|
15320
|
+
testID = _ref.testID;
|
|
15321
|
+
var _React$useState = React__default["default"].useState(Math.abs(selectedIndex - index) > lazyPreloadDistance),
|
|
15322
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
15323
|
+
isLoading = _React$useState2[0],
|
|
15324
|
+
setIsLoading = _React$useState2[1];
|
|
15325
|
+
var focused = index === selectedIndex;
|
|
15326
|
+
if (isLoading && Math.abs(selectedIndex - index) <= lazyPreloadDistance) {
|
|
15327
|
+
// Always render the route when it becomes focused
|
|
15328
|
+
setIsLoading(false);
|
|
15329
|
+
}
|
|
15330
|
+
React__default["default"].useEffect(function () {
|
|
15331
|
+
var timer;
|
|
15332
|
+
if (!lazy && isLoading) {
|
|
15333
|
+
// If lazy mode is not enabled, render the scene with a delay if not loaded already
|
|
15334
|
+
// This improves the initial startup time as the scene is no longer blocking
|
|
15335
|
+
timer = setTimeout(function () {
|
|
15336
|
+
return setIsLoading(false);
|
|
15337
|
+
}, 0);
|
|
15338
|
+
}
|
|
15339
|
+
return function () {
|
|
15340
|
+
clearTimeout(timer);
|
|
15341
|
+
};
|
|
15342
|
+
}, [index, isLoading, lazy, focused]);
|
|
15343
|
+
return /*#__PURE__*/React__default["default"].createElement(TabScreen, {
|
|
15344
|
+
accessibilityElementsHidden: !focused,
|
|
15345
|
+
importantForAccessibility: focused ? 'auto' : 'no-hide-descendants',
|
|
15346
|
+
style: [{
|
|
15347
|
+
flex: 1,
|
|
15348
|
+
overflow: 'hidden'
|
|
15349
|
+
}, focused ? reactNative.StyleSheet.absoluteFill : null],
|
|
15350
|
+
testID: testID
|
|
15351
|
+
}, focused || !isLoading ? children : null);
|
|
15352
|
+
};
|
|
15353
|
+
|
|
15305
15354
|
var useAnimatedValueArray = function useAnimatedValueArray(initialValues) {
|
|
15306
15355
|
var refs = React__default["default"].useRef([]);
|
|
15307
15356
|
refs.current.length = initialValues.length;
|
|
@@ -15472,124 +15521,6 @@ var ScrollableTabHeader = function ScrollableTabHeader(_ref2) {
|
|
|
15472
15521
|
}));
|
|
15473
15522
|
};
|
|
15474
15523
|
|
|
15475
|
-
var ScrollableTab$1 = function ScrollableTab(_ref) {
|
|
15476
|
-
var onTabPress = _ref.onTabPress,
|
|
15477
|
-
selectedTabKey = _ref.selectedTabKey,
|
|
15478
|
-
tabs = _ref.tabs,
|
|
15479
|
-
containerStyle = _ref.containerStyle,
|
|
15480
|
-
barStyle = _ref.barStyle,
|
|
15481
|
-
_ref$lazy = _ref.lazy,
|
|
15482
|
-
lazy = _ref$lazy === void 0 ? false : _ref$lazy,
|
|
15483
|
-
_ref$lazyPreloadDista = _ref.lazyPreloadDistance,
|
|
15484
|
-
lazyPreloadDistance = _ref$lazyPreloadDista === void 0 ? 1 : _ref$lazyPreloadDista,
|
|
15485
|
-
_ref$swipeEnabled = _ref.swipeEnabled,
|
|
15486
|
-
swipeEnabled = _ref$swipeEnabled === void 0 ? true : _ref$swipeEnabled,
|
|
15487
|
-
componentTestID = _ref.testID;
|
|
15488
|
-
var pagerViewRef = React__default["default"].useRef(null);
|
|
15489
|
-
var insets = reactNativeSafeAreaContext.useSafeAreaInsets();
|
|
15490
|
-
var selectedTabIndex = tabs.findIndex(function (item) {
|
|
15491
|
-
return item.key === selectedTabKey;
|
|
15492
|
-
});
|
|
15493
|
-
React__default["default"].useEffect(function () {
|
|
15494
|
-
var timeoutHandle = null;
|
|
15495
|
-
if (selectedTabIndex !== -1) {
|
|
15496
|
-
// If the selected tab is changed too quickly, the setPage is crashed and not work anymore
|
|
15497
|
-
// We apply throttle to prevent this issue https://github.com/Thinkei/hero-design/issues/1715
|
|
15498
|
-
timeoutHandle = setTimeout(function () {
|
|
15499
|
-
var _pagerViewRef$current;
|
|
15500
|
-
// use no animation to prevent unexpected behavior if users select tab too quickly
|
|
15501
|
-
(_pagerViewRef$current = pagerViewRef.current) === null || _pagerViewRef$current === void 0 ? void 0 : _pagerViewRef$current.setPageWithoutAnimation(selectedTabIndex);
|
|
15502
|
-
}, 200);
|
|
15503
|
-
}
|
|
15504
|
-
return function () {
|
|
15505
|
-
if (timeoutHandle) {
|
|
15506
|
-
clearTimeout(timeoutHandle);
|
|
15507
|
-
}
|
|
15508
|
-
};
|
|
15509
|
-
}, [selectedTabIndex, pagerViewRef]);
|
|
15510
|
-
return /*#__PURE__*/React__default["default"].createElement(TabContainer, {
|
|
15511
|
-
style: containerStyle,
|
|
15512
|
-
testID: componentTestID
|
|
15513
|
-
}, /*#__PURE__*/React__default["default"].createElement(ScrollableTabHeader, {
|
|
15514
|
-
tabs: tabs,
|
|
15515
|
-
selectedIndex: selectedTabIndex,
|
|
15516
|
-
onTabPress: onTabPress,
|
|
15517
|
-
barStyle: barStyle,
|
|
15518
|
-
insets: insets,
|
|
15519
|
-
testID: componentTestID ? "".concat(componentTestID, "-tab-bar") : undefined
|
|
15520
|
-
}), /*#__PURE__*/React__default["default"].createElement(ContentWrapper, {
|
|
15521
|
-
initialPage: selectedTabIndex,
|
|
15522
|
-
ref: pagerViewRef,
|
|
15523
|
-
onPageSelected: function onPageSelected(e) {
|
|
15524
|
-
var index = e.nativeEvent.position;
|
|
15525
|
-
var selectedItem = tabs[index];
|
|
15526
|
-
if (selectedItem) {
|
|
15527
|
-
onTabPress(selectedItem.key);
|
|
15528
|
-
}
|
|
15529
|
-
},
|
|
15530
|
-
scrollEnabled: swipeEnabled
|
|
15531
|
-
}, tabs.map(function (tab, index) {
|
|
15532
|
-
var key = tab.key,
|
|
15533
|
-
component = tab.component,
|
|
15534
|
-
testID = tab.testID;
|
|
15535
|
-
var active = selectedTabKey === key;
|
|
15536
|
-
var isLazyScreen = lazy && Math.abs(selectedTabIndex - index) > lazyPreloadDistance;
|
|
15537
|
-
return /*#__PURE__*/React__default["default"].createElement(TabScreen, {
|
|
15538
|
-
key: key,
|
|
15539
|
-
testID: testID ? "tab-screen-".concat(testID) : undefined,
|
|
15540
|
-
pointerEvents: active ? 'auto' : 'none',
|
|
15541
|
-
accessibilityElementsHidden: !active,
|
|
15542
|
-
importantForAccessibility: active ? 'auto' : 'no-hide-descendants',
|
|
15543
|
-
collapsable: false
|
|
15544
|
-
}, isLazyScreen ? null : component);
|
|
15545
|
-
})));
|
|
15546
|
-
};
|
|
15547
|
-
|
|
15548
|
-
var SceneView = function SceneView(_ref) {
|
|
15549
|
-
var _ref$lazy = _ref.lazy,
|
|
15550
|
-
lazy = _ref$lazy === void 0 ? false : _ref$lazy,
|
|
15551
|
-
_ref$lazyPreloadDista = _ref.lazyPreloadDistance,
|
|
15552
|
-
lazyPreloadDistance = _ref$lazyPreloadDista === void 0 ? 1 : _ref$lazyPreloadDista,
|
|
15553
|
-
children = _ref.children,
|
|
15554
|
-
index = _ref.index,
|
|
15555
|
-
selectedIndex = _ref.selectedIndex,
|
|
15556
|
-
focused = _ref.focused,
|
|
15557
|
-
testID = _ref.testID;
|
|
15558
|
-
var _React$useState = React__default["default"].useState(Math.abs(selectedIndex - index) > lazyPreloadDistance),
|
|
15559
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
15560
|
-
isLoading = _React$useState2[0],
|
|
15561
|
-
setIsLoading = _React$useState2[1];
|
|
15562
|
-
if (isLoading && Math.abs(selectedIndex - index) <= lazyPreloadDistance) {
|
|
15563
|
-
// Always render the route when it becomes focused
|
|
15564
|
-
setIsLoading(false);
|
|
15565
|
-
}
|
|
15566
|
-
if (lazy && isLoading) {
|
|
15567
|
-
console.error('Lazy loading is not supported in this version of Tabs');
|
|
15568
|
-
}
|
|
15569
|
-
React__default["default"].useEffect(function () {
|
|
15570
|
-
var timer;
|
|
15571
|
-
if (!lazy && isLoading) {
|
|
15572
|
-
// If lazy mode is not enabled, render the scene with a delay if not loaded already
|
|
15573
|
-
// This improves the initial startup time as the scene is no longer blocking
|
|
15574
|
-
timer = setTimeout(function () {
|
|
15575
|
-
return setIsLoading(false);
|
|
15576
|
-
}, 0);
|
|
15577
|
-
}
|
|
15578
|
-
return function () {
|
|
15579
|
-
clearTimeout(timer);
|
|
15580
|
-
};
|
|
15581
|
-
}, [index, isLoading, lazy, focused]);
|
|
15582
|
-
return /*#__PURE__*/React__default["default"].createElement(TabScreen, {
|
|
15583
|
-
accessibilityElementsHidden: !focused,
|
|
15584
|
-
importantForAccessibility: focused ? 'auto' : 'no-hide-descendants',
|
|
15585
|
-
style: [{
|
|
15586
|
-
flex: 1,
|
|
15587
|
-
overflow: 'hidden'
|
|
15588
|
-
}, focused ? reactNative.StyleSheet.absoluteFill : null],
|
|
15589
|
-
testID: testID
|
|
15590
|
-
}, focused || !isLoading ? children : null);
|
|
15591
|
-
};
|
|
15592
|
-
|
|
15593
15524
|
var TabContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
15594
15525
|
var ScreenContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
15595
15526
|
var useIsFocused = function useIsFocused() {
|
|
@@ -15601,6 +15532,7 @@ var useIsFocused = function useIsFocused() {
|
|
|
15601
15532
|
var isFocused = context.selectedTabKey === key;
|
|
15602
15533
|
return isFocused;
|
|
15603
15534
|
};
|
|
15535
|
+
|
|
15604
15536
|
var ScrollableTab = function ScrollableTab(_ref) {
|
|
15605
15537
|
var onTabPress = _ref.onTabPress,
|
|
15606
15538
|
selectedTabKey = _ref.selectedTabKey,
|
|
@@ -15636,7 +15568,6 @@ var ScrollableTab = function ScrollableTab(_ref) {
|
|
|
15636
15568
|
}
|
|
15637
15569
|
};
|
|
15638
15570
|
}, [selectedTabIndex, pagerViewRef]);
|
|
15639
|
-
var indexRef = React__default["default"].useRef(selectedTabIndex);
|
|
15640
15571
|
var tabContextProviderValue = React__default["default"].useMemo(function () {
|
|
15641
15572
|
return {
|
|
15642
15573
|
selectedTabKey: selectedTabKey
|
|
@@ -15665,7 +15596,6 @@ var ScrollableTab = function ScrollableTab(_ref) {
|
|
|
15665
15596
|
onTabPress(selectedItem.key);
|
|
15666
15597
|
});
|
|
15667
15598
|
}
|
|
15668
|
-
indexRef.current = index;
|
|
15669
15599
|
},
|
|
15670
15600
|
scrollEnabled: swipeEnabled
|
|
15671
15601
|
}, tabs.map(function (tab, index) {
|
|
@@ -15673,23 +15603,18 @@ var ScrollableTab = function ScrollableTab(_ref) {
|
|
|
15673
15603
|
component = tab.component,
|
|
15674
15604
|
testID = tab.testID;
|
|
15675
15605
|
return /*#__PURE__*/React__default["default"].createElement(ScreenContext.Provider, {
|
|
15676
|
-
value: key
|
|
15606
|
+
value: key,
|
|
15607
|
+
key: key
|
|
15677
15608
|
}, /*#__PURE__*/React__default["default"].createElement(SceneView, {
|
|
15678
15609
|
testID: testID,
|
|
15679
|
-
key: key,
|
|
15680
15610
|
index: index,
|
|
15681
|
-
selectedIndex:
|
|
15611
|
+
selectedIndex: selectedTabIndex,
|
|
15682
15612
|
lazy: lazy,
|
|
15683
|
-
lazyPreloadDistance: lazyPreloadDistance
|
|
15684
|
-
focused: selectedTabKey === key
|
|
15613
|
+
lazyPreloadDistance: lazyPreloadDistance
|
|
15685
15614
|
}, component));
|
|
15686
15615
|
}))));
|
|
15687
15616
|
};
|
|
15688
15617
|
|
|
15689
|
-
var ScrollableTabsV2 = Object.assign(ScrollableTab, {
|
|
15690
|
-
useIsFocused: useIsFocused
|
|
15691
|
-
});
|
|
15692
|
-
|
|
15693
15618
|
var getTabItem = function getTabItem(_ref) {
|
|
15694
15619
|
var item = _ref.item,
|
|
15695
15620
|
color = _ref.color,
|
|
@@ -15738,7 +15663,14 @@ var Tabs = function Tabs(_ref2) {
|
|
|
15738
15663
|
(_pagerViewRef$current = pagerViewRef.current) === null || _pagerViewRef$current === void 0 ? void 0 : _pagerViewRef$current.setPage(selectedTabIndex);
|
|
15739
15664
|
}
|
|
15740
15665
|
}, [selectedTabIndex]);
|
|
15741
|
-
|
|
15666
|
+
var tabContextProviderValue = React__default["default"].useMemo(function () {
|
|
15667
|
+
return {
|
|
15668
|
+
selectedTabKey: selectedTabKey
|
|
15669
|
+
};
|
|
15670
|
+
}, [selectedTabKey]);
|
|
15671
|
+
return /*#__PURE__*/React__default["default"].createElement(TabContext.Provider, {
|
|
15672
|
+
value: tabContextProviderValue
|
|
15673
|
+
}, /*#__PURE__*/React__default["default"].createElement(TabContainer$1, {
|
|
15742
15674
|
style: containerStyle,
|
|
15743
15675
|
testID: componentTestID
|
|
15744
15676
|
}, /*#__PURE__*/React__default["default"].createElement(HeaderTabWrapper$1, {
|
|
@@ -15803,21 +15735,22 @@ var Tabs = function Tabs(_ref2) {
|
|
|
15803
15735
|
var key = tab.key,
|
|
15804
15736
|
component = tab.component,
|
|
15805
15737
|
testID = tab.testID;
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15738
|
+
return /*#__PURE__*/React__default["default"].createElement(ScreenContext.Provider, {
|
|
15739
|
+
value: key,
|
|
15740
|
+
key: key
|
|
15741
|
+
}, /*#__PURE__*/React__default["default"].createElement(SceneView, {
|
|
15742
|
+
testID: testID,
|
|
15809
15743
|
key: key,
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
})));
|
|
15744
|
+
index: index,
|
|
15745
|
+
selectedIndex: selectedTabIndex,
|
|
15746
|
+
lazy: lazy,
|
|
15747
|
+
lazyPreloadDistance: lazyPreloadDistance
|
|
15748
|
+
}, component));
|
|
15749
|
+
}))));
|
|
15817
15750
|
};
|
|
15818
15751
|
var index$2 = Object.assign(Tabs, {
|
|
15819
|
-
Scroll: ScrollableTab
|
|
15820
|
-
|
|
15752
|
+
Scroll: ScrollableTab,
|
|
15753
|
+
useIsFocused: useIsFocused
|
|
15821
15754
|
});
|
|
15822
15755
|
|
|
15823
15756
|
var getFilledStyles = function getFilledStyles(themeIntent, theme) {
|
|
@@ -32706,11 +32639,10 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
32706
32639
|
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n <style>\n body {\n margin: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n <script>\n window.__editorConfigs = {\n placeholder: \"".concat(placeholder, "\",\n initialValue: ").concat(initialValueString, ",\n isAndroid: ").concat(isAndroid ? 'true' : 'false', ",\n autoFocus: ").concat(autoFocus, ",\n style: {\n padding: '0 !important',\n fontSize: ").concat(theme.__hd__.richTextEditor.fontSizes.editor, ",\n color: '").concat(theme.__hd__.richTextEditor.colors.text, "'\n }\n };\n ").concat(heroEditorApp, "\n </script>\n </body>\n </html>\n ");
|
|
32707
32640
|
}, []);
|
|
32708
32641
|
var requestBlur = React.useCallback(function () {
|
|
32709
|
-
if (webview.current) {
|
|
32642
|
+
if (webview.current && isFocused) {
|
|
32710
32643
|
requestBlurEditor(webview.current);
|
|
32711
|
-
reactNative.Keyboard.dismiss();
|
|
32712
32644
|
}
|
|
32713
|
-
}, []);
|
|
32645
|
+
}, [isFocused]);
|
|
32714
32646
|
React.useImperativeHandle(forwardedRef, function () {
|
|
32715
32647
|
return {
|
|
32716
32648
|
requestBlur: requestBlur
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.24.0
|
|
3
|
+
"version": "8.24.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.
|
|
24
|
+
"@hero-design/colors": "8.24.0",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/preset-typescript": "^7.17.12",
|
|
46
46
|
"@babel/runtime": "^7.18.9",
|
|
47
47
|
"@emotion/jest": "^11.9.3",
|
|
48
|
-
"@hero-design/eslint-plugin": "8.
|
|
48
|
+
"@hero-design/eslint-plugin": "8.24.0",
|
|
49
49
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
50
50
|
"@react-native-community/slider": "4.1.12",
|
|
51
51
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"@types/react-native": "^0.67.7",
|
|
62
62
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
63
63
|
"babel-plugin-inline-import": "^3.0.0",
|
|
64
|
-
"eslint-config-hd": "8.
|
|
64
|
+
"eslint-config-hd": "8.24.0",
|
|
65
65
|
"jest": "^27.3.1",
|
|
66
|
-
"prettier-config-hd": "8.
|
|
66
|
+
"prettier-config-hd": "8.24.0",
|
|
67
67
|
"react": "18.0.0",
|
|
68
68
|
"react-native": "0.69.7",
|
|
69
69
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -10,7 +10,7 @@ import React, {
|
|
|
10
10
|
useState,
|
|
11
11
|
} from 'react';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { TouchableWithoutFeedback } from 'react-native';
|
|
14
14
|
import { WebView } from 'react-native-webview';
|
|
15
15
|
import type { ComponentType, ReactElement, Ref } from 'react';
|
|
16
16
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
@@ -207,11 +207,10 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
207
207
|
}, []);
|
|
208
208
|
|
|
209
209
|
const requestBlur = useCallback(() => {
|
|
210
|
-
if (webview.current) {
|
|
210
|
+
if (webview.current && isFocused) {
|
|
211
211
|
requestBlurEditor(webview.current);
|
|
212
|
-
Keyboard.dismiss();
|
|
213
212
|
}
|
|
214
|
-
}, []);
|
|
213
|
+
}, [isFocused]);
|
|
215
214
|
|
|
216
215
|
useImperativeHandle(forwardedRef, () => ({ requestBlur }), [requestBlur]);
|
|
217
216
|
|
|
@@ -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', () => {
|