@hero-design/rn 8.44.0-alpha.0 → 8.45.0-test.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 +2 -2
- package/CHANGELOG.md +36 -0
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +2772 -2661
- package/jest-setup.ts +2 -0
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +2775 -2665
- package/package.json +23 -24
- package/rollup.config.js +0 -1
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +564 -384
- package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +76 -20
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +791 -605
- package/src/components/Accordion/index.tsx +1 -1
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +848 -567
- package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +172 -110
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +138 -70
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +745 -581
- package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +158 -57
- package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +273 -153
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +391 -223
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +119 -63
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +306 -242
- package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +317 -183
- package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +1042 -454
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +6 -10
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +400 -140
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +1090 -880
- package/src/components/Button/StyledButton.tsx +4 -0
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +196 -106
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1675 -1125
- package/src/components/Button/__tests__/__snapshots__/IconButton.spec.tsx.snap +71 -26
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +1651 -665
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +555 -330
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +265 -69
- package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +205 -65
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +36 -8
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +292 -124
- package/src/components/Carousel/CardCarousel.tsx +10 -7
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +486 -406
- package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +197 -70
- package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +41 -13
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +1742 -1526
- package/src/components/Carousel/__tests__/index.spec.tsx +50 -3
- package/src/components/Carousel/index.tsx +16 -22
- package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +404 -112
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +574 -334
- package/src/components/Chip/StyledChip.tsx +121 -0
- package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +1483 -0
- package/src/components/Chip/__tests__/index.spec.tsx +136 -0
- package/src/components/Chip/index.tsx +82 -0
- package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +73 -17
- package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +94 -38
- package/src/components/Collapse/index.tsx +1 -1
- package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +37 -9
- package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +424 -268
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +586 -466
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +200 -160
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +192 -152
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +471 -389
- package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +464 -128
- package/src/components/Drawer/DragableDrawer/__tests__/__snapshots__/index.spec.tsx.snap +97 -69
- package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +327 -192
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +169 -113
- package/src/components/Error/StyledError.tsx +2 -1
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +390 -262
- package/src/components/Error/__tests__/index.spec.tsx +9 -6
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +860 -723
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +98 -42
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +199 -99
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +293 -185
- package/src/components/HeroDesignProvider/__tests__/__snapshots__/index.spec.tsx.snap +45 -17
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +3 -0
- package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +158 -46
- package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +164 -52
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +242 -170
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +760 -588
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +272 -128
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +477 -193
- package/src/components/Modal/__tests__/__snapshots__/index.spec.tsx.snap +169 -0
- package/src/components/Modal/__tests__/index.spec.tsx +99 -0
- package/src/components/Modal/index.tsx +178 -82
- package/src/components/PageControl/__tests__/__snapshots__/index.spec.tsx.snap +84 -41
- package/src/components/PageControl/index.tsx +1 -0
- package/src/components/PinInput/__tests__/StyledPinInput.spec.tsx +9 -4
- package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +293 -153
- package/src/components/PinInput/__tests__/__snapshots__/StyledPinInput.spec.tsx.snap +15 -48
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +809 -697
- package/src/components/Portal/__tests__/PortalHost.spec.tsx +12 -14
- package/src/components/Portal/__tests__/__snapshots__/index.spec.tsx.snap +43 -15
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +743 -603
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +188 -116
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +257 -205
- package/src/components/Rate/__tests__/__snapshots__/index.spec.tsx.snap +864 -600
- package/src/components/RefreshControl/__tests__/__snapshots__/index.spec.tsx.snap +128 -44
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +5 -2
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +3 -3
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +413 -266
- package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +64 -35
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +371 -297
- package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +158 -46
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +394 -226
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +93 -57
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +2387 -2151
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +621 -28
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +7 -6
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +73 -37
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +2321 -2085
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +473 -23
- package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +490 -294
- package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +117 -33
- package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +105 -77
- package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +1308 -636
- package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +121 -93
- package/src/components/Success/StyledSuccess.tsx +2 -1
- package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +388 -258
- package/src/components/Success/__tests__/index.spec.tsx +9 -6
- package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +210 -75
- package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +58 -30
- package/src/components/Swipeable/index.tsx +3 -3
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +226 -114
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +146 -109
- package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +202 -62
- package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +132 -68
- package/src/components/Tabs/__tests__/SceneView.spec.tsx +7 -7
- package/src/components/Tabs/__tests__/__snapshots__/SceneView.spec.tsx.snap +206 -94
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +2217 -1962
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +523 -455
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +121 -65
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +1641 -1398
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +554 -274
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1542 -646
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3177 -2701
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +390 -310
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +662 -540
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +871 -573
- package/src/components/Toast/__tests__/__snapshots__/ToastContainer.spec.tsx.snap +180 -68
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +582 -426
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +683 -363
- package/src/components/Typography/Body/__tests__/__snapshots__/StyledBody.tsx.snap +704 -256
- package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +855 -323
- package/src/components/Typography/Caption/__tests__/__snapshots__/StyledCaption.spec.tsx.snap +430 -150
- package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +572 -208
- package/src/components/Typography/Label/__tests__/__snapshots__/StyledLabel.tsx.snap +328 -104
- package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +462 -154
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +900 -340
- package/src/components/Typography/Title/__tests__/__snapshots__/StyledTitle.tsx.snap +880 -320
- package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +1035 -391
- package/src/index.ts +2 -2
- package/src/testHelpers/renderWithTheme.tsx +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +38 -1
- package/src/theme/components/button.ts +0 -1
- package/src/theme/components/chip.ts +47 -0
- package/src/theme/getTheme.ts +3 -0
- package/testUtils/setup.tsx +0 -18
- package/tsconfig.json +4 -1
- package/types/components/Accordion/AccordionItem.d.ts +2 -1
- package/types/components/Accordion/index.d.ts +1 -1
- package/types/components/Attachment/index.d.ts +2 -1
- package/types/components/Avatar/Avatar.d.ts +2 -1
- package/types/components/Avatar/AvatarStack/index.d.ts +2 -2
- package/types/components/Avatar/index.d.ts +3 -2
- package/types/components/Badge/StyledBadge.d.ts +0 -4
- package/types/components/BottomSheet/Footer.d.ts +2 -1
- package/types/components/BottomSheet/Header.d.ts +2 -1
- package/types/components/BottomSheet/ScrollView.d.ts +1 -0
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +0 -4
- package/types/components/Box/index.d.ts +2 -1
- package/types/components/Button/IconButton.d.ts +2 -1
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +3 -3
- package/types/components/Button/LoadingIndicator/index.d.ts +2 -1
- package/types/components/Button/UtilityButton/index.d.ts +2 -1
- package/types/components/Calendar/CalendarRowItem.d.ts +2 -1
- package/types/components/Calendar/StyledCalendar.d.ts +1 -1
- package/types/components/Calendar/index.d.ts +2 -1
- package/types/components/Carousel/CardCarousel.d.ts +1 -1
- package/types/components/Carousel/CarouselItem.d.ts +2 -1
- package/types/components/Carousel/index.d.ts +2 -2
- package/types/components/Checkbox/index.d.ts +2 -1
- package/types/components/Chip/StyledChip.d.ts +31 -0
- package/types/components/Chip/index.d.ts +27 -0
- package/types/components/Collapse/StyledCollapse.d.ts +0 -2
- package/types/components/Collapse/index.d.ts +2 -1
- package/types/components/ContentNavigator/index.d.ts +2 -1
- package/types/components/DatePicker/DatePickerAndroid.d.ts +2 -1
- package/types/components/DatePicker/DatePickerCalendar.d.ts +2 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +2 -1
- package/types/components/DatePicker/index.d.ts +2 -1
- package/types/components/Divider/index.d.ts +2 -1
- package/types/components/Drawer/StyledDrawer.d.ts +0 -6
- package/types/components/Error/StyledError.d.ts +3 -9
- package/types/components/FAB/ActionGroup/ActionItem.d.ts +2 -1
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -4
- package/types/components/FAB/AnimatedFABIcon.d.ts +2 -1
- package/types/components/HeroDesignProvider/index.d.ts +2 -1
- package/types/components/Icon/AnimatedIcon.d.ts +2 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +3 -2
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Image/index.d.ts +1 -0
- package/types/components/Modal/index.d.ts +12 -8
- package/types/components/PageControl/StyledPageControl.d.ts +0 -2
- package/types/components/PageControl/index.d.ts +2 -1
- package/types/components/PinInput/PinCell.d.ts +2 -1
- package/types/components/Portal/PortalHost.d.ts +1 -1
- package/types/components/Portal/PortalProvider.d.ts +1 -1
- package/types/components/Portal/index.d.ts +2 -2
- package/types/components/Progress/ProgressBar.d.ts +1 -0
- package/types/components/Progress/StyledProgressBar.d.ts +0 -2
- package/types/components/Progress/index.d.ts +1 -0
- package/types/components/Rate/StyledRate.d.ts +0 -2
- package/types/components/Rate/index.d.ts +2 -1
- package/types/components/RefreshControl/index.d.ts +2 -1
- package/types/components/RichTextEditor/EditorToolbar.d.ts +2 -1
- package/types/components/RichTextEditor/MentionList.d.ts +2 -1
- package/types/components/RichTextEditor/index.d.ts +2 -2
- package/types/components/Select/BaseOptionList.d.ts +1 -1
- package/types/components/Select/Footer.d.ts +2 -1
- package/types/components/Select/MultiSelect/Option.d.ts +2 -1
- package/types/components/Select/MultiSelect/OptionList.d.ts +2 -1
- package/types/components/Select/MultiSelect/index.d.ts +1 -1
- package/types/components/Select/SingleSelect/Option.d.ts +2 -1
- package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
- package/types/components/Select/SingleSelect/StyledSingleSelect.d.ts +2 -1
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/helpers.d.ts +1 -2
- package/types/components/Select/index.d.ts +2 -1
- package/types/components/Skeleton/index.d.ts +2 -1
- package/types/components/Slider/index.d.ts +2 -1
- package/types/components/Spinner/AnimatedSpinner.d.ts +2 -1
- package/types/components/Success/StyledSuccess.d.ts +3 -7
- package/types/components/Swipeable/SwipeableAction.d.ts +2 -2
- package/types/components/Swipeable/index.d.ts +3 -3
- package/types/components/Switch/SelectorSwitch/Option.d.ts +2 -1
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +0 -6
- package/types/components/Switch/StyledSwitch.d.ts +0 -2
- package/types/components/Tabs/ActiveTabIndicator.d.ts +2 -1
- package/types/components/Tabs/SceneView.d.ts +1 -1
- package/types/components/Tabs/ScrollableTabs.d.ts +2 -1
- package/types/components/Tabs/ScrollableTabsHeader.d.ts +2 -1
- package/types/components/Tabs/StyledScrollableTabs.d.ts +0 -4
- package/types/components/Tabs/StyledTabs.d.ts +0 -4
- package/types/components/Tabs/TabWithBadge.d.ts +2 -2
- package/types/components/Tabs/index.d.ts +2 -1
- package/types/components/TextInput/StyledTextInput.d.ts +1 -1
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/components/TimePicker/TimePickerAndroid.d.ts +2 -1
- package/types/components/TimePicker/TimePickerIOS.d.ts +2 -1
- package/types/components/TimePicker/index.d.ts +2 -1
- package/types/components/Toast/StyledToast.d.ts +0 -2
- package/types/components/Toast/Toast.d.ts +1 -0
- package/types/components/Toast/ToastProvider.d.ts +2 -1
- package/types/components/Toast/index.d.ts +1 -1
- package/types/components/Toolbar/ToolbarGroup.d.ts +2 -1
- package/types/components/Toolbar/ToolbarItem.d.ts +2 -1
- package/types/components/Toolbar/index.d.ts +3 -2
- package/types/components/Typography/Body/index.d.ts +2 -1
- package/types/components/Typography/Caption/index.d.ts +2 -1
- package/types/components/Typography/Label/index.d.ts +2 -1
- package/types/components/Typography/Text/index.d.ts +2 -1
- package/types/components/Typography/Title/index.d.ts +2 -1
- package/types/index.d.ts +2 -2
- package/types/testHelpers/renderWithTheme.d.ts +1 -0
- package/types/theme/ThemeSwitcher.d.ts +2 -2
- package/types/theme/components/button.d.ts +0 -1
- package/types/theme/components/chip.d.ts +40 -0
- package/types/theme/getTheme.d.ts +2 -0
- package/.turbo/turbo-publish:npm.log +0 -0
- package/src/components/Modal/ModalContentWrapper.tsx +0 -112
- package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +0 -135
- package/src/components/Modal/ModalPresenter/index.tsx +0 -9
- package/src/components/Modal/ModalProvider.tsx +0 -8
- package/types/components/Modal/ModalContentWrapper.d.ts +0 -16
- package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +0 -34
- package/types/components/Modal/ModalPresenter/index.d.ts +0 -3
- package/types/components/Modal/ModalProvider.d.ts +0 -5
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Animated,
|
|
4
|
-
Dimensions,
|
|
5
|
-
Easing,
|
|
6
|
-
Platform,
|
|
7
|
-
StyleProp,
|
|
8
|
-
ViewStyle,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
|
|
11
|
-
type ModalContentWrapperProps = {
|
|
12
|
-
children: React.ReactElement;
|
|
13
|
-
visible?: boolean;
|
|
14
|
-
onShow?: () => void;
|
|
15
|
-
testID?: string;
|
|
16
|
-
animationType?: 'none' | 'slide' | 'fade';
|
|
17
|
-
style?: StyleProp<ViewStyle>;
|
|
18
|
-
animated?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ModalContentWrapperHandler = {
|
|
22
|
-
hide: (callback?: () => void) => void;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const windowHeight = Dimensions.get('window').height;
|
|
26
|
-
const defaultAnimationConfig = {
|
|
27
|
-
easing: Easing.inOut(Easing.cubic),
|
|
28
|
-
duration: 400,
|
|
29
|
-
useNativeDriver: Platform.OS !== 'web',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const ModalContentWrapper = forwardRef<
|
|
33
|
-
ModalContentWrapperHandler,
|
|
34
|
-
ModalContentWrapperProps
|
|
35
|
-
>(
|
|
36
|
-
(
|
|
37
|
-
{
|
|
38
|
-
animationType,
|
|
39
|
-
children,
|
|
40
|
-
testID,
|
|
41
|
-
onShow,
|
|
42
|
-
style,
|
|
43
|
-
visible,
|
|
44
|
-
animated = true,
|
|
45
|
-
},
|
|
46
|
-
ref
|
|
47
|
-
) => {
|
|
48
|
-
const animatedValue = React.useRef(new Animated.Value(0)).current;
|
|
49
|
-
|
|
50
|
-
const modalAnimation = animatedValue.interpolate(
|
|
51
|
-
animationType === 'fade'
|
|
52
|
-
? {
|
|
53
|
-
inputRange: [0, 1],
|
|
54
|
-
outputRange: [0, 1],
|
|
55
|
-
}
|
|
56
|
-
: {
|
|
57
|
-
inputRange: [0, 1],
|
|
58
|
-
outputRange: [windowHeight, 0],
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
React.useImperativeHandle(
|
|
63
|
-
ref,
|
|
64
|
-
() => ({
|
|
65
|
-
hide: (callback) => {
|
|
66
|
-
Animated.timing(animatedValue, {
|
|
67
|
-
toValue: 0,
|
|
68
|
-
...defaultAnimationConfig,
|
|
69
|
-
}).start(callback);
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
[animatedValue]
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
// Hiding animation will be called from the modal component
|
|
77
|
-
if (visible) {
|
|
78
|
-
Animated.timing(animatedValue, {
|
|
79
|
-
toValue: 1,
|
|
80
|
-
...defaultAnimationConfig,
|
|
81
|
-
// Prevent animation when updating the modal content
|
|
82
|
-
duration: animated ? defaultAnimationConfig.duration : 0,
|
|
83
|
-
}).start(() => {
|
|
84
|
-
onShow?.();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}, [visible, animatedValue, onShow, animated]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Animated.View
|
|
91
|
-
testID={testID}
|
|
92
|
-
style={[
|
|
93
|
-
style,
|
|
94
|
-
{
|
|
95
|
-
...(animationType === 'fade' ? { opacity: modalAnimation } : {}),
|
|
96
|
-
...(animationType === 'slide'
|
|
97
|
-
? {
|
|
98
|
-
transform: [{ translateY: modalAnimation }],
|
|
99
|
-
}
|
|
100
|
-
: {}),
|
|
101
|
-
},
|
|
102
|
-
]}
|
|
103
|
-
>
|
|
104
|
-
{children}
|
|
105
|
-
</Animated.View>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
ModalContentWrapper.displayName = 'ModalContentWrapper';
|
|
111
|
-
|
|
112
|
-
export default ModalContentWrapper;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useRef } from 'react';
|
|
2
|
-
import { Animated, StyleSheet, ViewProps } from 'react-native';
|
|
3
|
-
import RootSiblings from 'react-native-root-siblings';
|
|
4
|
-
import { useTheme } from '../../../theme';
|
|
5
|
-
import Box from '../../Box';
|
|
6
|
-
|
|
7
|
-
export type ModalPresenterHandles = {
|
|
8
|
-
animatedOut: (completion?: () => void) => void;
|
|
9
|
-
};
|
|
10
|
-
export type ModalDismissFunc = (onDismiss?: () => void) => void;
|
|
11
|
-
export type ModalUpdateFunc = (content: React.ReactNode) => void;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Modal handler is returned by `showModal` function.
|
|
15
|
-
*/
|
|
16
|
-
export type ModalHandler = {
|
|
17
|
-
/**
|
|
18
|
-
* Same `dismiss` function as in `ModalContentProps`.
|
|
19
|
-
*/
|
|
20
|
-
dismiss: ModalDismissFunc;
|
|
21
|
-
/**
|
|
22
|
-
* Same `update` function as in `ModalContentProps`.
|
|
23
|
-
*/
|
|
24
|
-
update: ModalUpdateFunc;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const ModalPresenter = forwardRef<ModalPresenterHandles, ViewProps>(
|
|
28
|
-
({ style, children, ...props }, ref) => {
|
|
29
|
-
const animatedOpacity = useRef(new Animated.Value(0));
|
|
30
|
-
const theme = useTheme();
|
|
31
|
-
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
Animated.spring(animatedOpacity.current, {
|
|
34
|
-
toValue: 1,
|
|
35
|
-
useNativeDriver: true,
|
|
36
|
-
}).start();
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
React.useImperativeHandle(ref, () => ({
|
|
40
|
-
animatedOut: (completion?: () => void) => {
|
|
41
|
-
Animated.spring(animatedOpacity.current, {
|
|
42
|
-
toValue: 0,
|
|
43
|
-
useNativeDriver: true,
|
|
44
|
-
}).start(() => {
|
|
45
|
-
completion?.();
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Box style={StyleSheet.absoluteFill}>
|
|
52
|
-
<Animated.View
|
|
53
|
-
style={[
|
|
54
|
-
{
|
|
55
|
-
width: '100%',
|
|
56
|
-
height: '100%',
|
|
57
|
-
backgroundColor: `${theme.colors.overlayGlobalSurface}66`, // 66 = 40% opacity as suggested by the mobile color guidelines
|
|
58
|
-
justifyContent: 'center',
|
|
59
|
-
alignItems: 'center',
|
|
60
|
-
opacity: animatedOpacity.current,
|
|
61
|
-
},
|
|
62
|
-
style,
|
|
63
|
-
]}
|
|
64
|
-
{...props}
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
</Animated.View>
|
|
68
|
-
</Box>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Present a modal on screen immediately.
|
|
75
|
-
*
|
|
76
|
-
* The new presented modal will be on top of existing modals if there are any.
|
|
77
|
-
*
|
|
78
|
-
* @param Content A component to be presented as a modal on screen.
|
|
79
|
-
* This component will be centered horizontally and vertically on screen with
|
|
80
|
-
* a semitransparent black overlay underneath.
|
|
81
|
-
* @param contentProps Props for this modal component.
|
|
82
|
-
* @returns A `ModalHandler` you can use to dismiss the modal.
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
export const showModal = (content: React.ReactNode): ModalHandler => {
|
|
86
|
-
let ref: ModalPresenterHandles | null = null;
|
|
87
|
-
let rootSiblings: RootSiblings | null = null;
|
|
88
|
-
|
|
89
|
-
const dismiss: ModalDismissFunc = (onDismiss) => {
|
|
90
|
-
if (rootSiblings) {
|
|
91
|
-
const cleanup = () => {
|
|
92
|
-
rootSiblings?.destroy();
|
|
93
|
-
rootSiblings = null;
|
|
94
|
-
ref = null;
|
|
95
|
-
onDismiss?.();
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
if (ref) {
|
|
99
|
-
ref.animatedOut(cleanup);
|
|
100
|
-
} else {
|
|
101
|
-
cleanup();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const update: ModalUpdateFunc = (newContent) => {
|
|
107
|
-
rootSiblings?.update(
|
|
108
|
-
<ModalPresenter
|
|
109
|
-
ref={(_ref) => {
|
|
110
|
-
ref = _ref;
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
{newContent}
|
|
114
|
-
</ModalPresenter>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
rootSiblings = new RootSiblings(
|
|
119
|
-
(
|
|
120
|
-
<ModalPresenter
|
|
121
|
-
ref={(_ref) => {
|
|
122
|
-
ref = _ref;
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{content}
|
|
126
|
-
</ModalPresenter>
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
return { dismiss, update };
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
ModalPresenter.displayName = 'ModalPresenter';
|
|
134
|
-
|
|
135
|
-
export default ModalPresenter;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { RootSiblingParent } from 'react-native-root-siblings';
|
|
3
|
-
|
|
4
|
-
const ModalProvider = ({ children }: { children: ReactNode }) => {
|
|
5
|
-
return <RootSiblingParent>{children}</RootSiblingParent>;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default ModalProvider;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
type ModalContentWrapperProps = {
|
|
4
|
-
children: React.ReactElement;
|
|
5
|
-
visible?: boolean;
|
|
6
|
-
onShow?: () => void;
|
|
7
|
-
testID?: string;
|
|
8
|
-
animationType?: 'none' | 'slide' | 'fade';
|
|
9
|
-
style?: StyleProp<ViewStyle>;
|
|
10
|
-
animated?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type ModalContentWrapperHandler = {
|
|
13
|
-
hide: (callback?: () => void) => void;
|
|
14
|
-
};
|
|
15
|
-
declare const ModalContentWrapper: React.ForwardRefExoticComponent<ModalContentWrapperProps & React.RefAttributes<ModalContentWrapperHandler>>;
|
|
16
|
-
export default ModalContentWrapper;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ViewProps } from 'react-native';
|
|
3
|
-
export type ModalPresenterHandles = {
|
|
4
|
-
animatedOut: (completion?: () => void) => void;
|
|
5
|
-
};
|
|
6
|
-
export type ModalDismissFunc = (onDismiss?: () => void) => void;
|
|
7
|
-
export type ModalUpdateFunc = (content: React.ReactNode) => void;
|
|
8
|
-
/**
|
|
9
|
-
* Modal handler is returned by `showModal` function.
|
|
10
|
-
*/
|
|
11
|
-
export type ModalHandler = {
|
|
12
|
-
/**
|
|
13
|
-
* Same `dismiss` function as in `ModalContentProps`.
|
|
14
|
-
*/
|
|
15
|
-
dismiss: ModalDismissFunc;
|
|
16
|
-
/**
|
|
17
|
-
* Same `update` function as in `ModalContentProps`.
|
|
18
|
-
*/
|
|
19
|
-
update: ModalUpdateFunc;
|
|
20
|
-
};
|
|
21
|
-
declare const ModalPresenter: React.ForwardRefExoticComponent<ViewProps & React.RefAttributes<ModalPresenterHandles>>;
|
|
22
|
-
/**
|
|
23
|
-
* Present a modal on screen immediately.
|
|
24
|
-
*
|
|
25
|
-
* The new presented modal will be on top of existing modals if there are any.
|
|
26
|
-
*
|
|
27
|
-
* @param Content A component to be presented as a modal on screen.
|
|
28
|
-
* This component will be centered horizontally and vertically on screen with
|
|
29
|
-
* a semitransparent black overlay underneath.
|
|
30
|
-
* @param contentProps Props for this modal component.
|
|
31
|
-
* @returns A `ModalHandler` you can use to dismiss the modal.
|
|
32
|
-
*/
|
|
33
|
-
export declare const showModal: (content: React.ReactNode) => ModalHandler;
|
|
34
|
-
export default ModalPresenter;
|