@hero-design/rn 8.34.2 → 8.35.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tool-versions +1 -0
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-build:types.log +9 -0
- package/.turbo/turbo-lint.log +163 -0
- package/.turbo/turbo-publish:npm.log +9 -0
- package/.turbo/turbo-test.log +725 -0
- package/.turbo/turbo-type-check.log +1 -0
- package/es/index.js +235 -93
- package/lib/index.js +235 -92
- package/package.json +9 -8
- package/src/components/FAB/ActionGroup/FABModal.tsx +63 -0
- package/src/components/FAB/ActionGroup/FABModalContentWrapper.tsx +31 -0
- package/src/components/FAB/ActionGroup/ModalPresenter/ModalPresenter.tsx +133 -0
- package/src/components/FAB/ActionGroup/ModalPresenter/index.tsx +13 -0
- package/src/components/FAB/ActionGroup/index.tsx +55 -35
- package/src/components/FAB/FAB.tsx +10 -1
- package/src/components/Progress/StyledProgressBar.tsx +0 -1
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +44 -46
- package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +7 -4
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
- package/src/components/Switch/SelectorSwitch/index.tsx +15 -7
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +12 -12
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +4 -4
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +7 -7
- package/src/theme/components/progress.ts +2 -2
- package/src/theme/components/switch.ts +4 -4
- package/src/theme/components/tabs.ts +1 -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/FABModal.d.ts +21 -0
- package/types/components/FAB/ActionGroup/FABModalContentWrapper.d.ts +18 -0
- package/types/components/FAB/ActionGroup/FABProvider.d.ts +5 -0
- package/types/components/FAB/ActionGroup/ModalPresenter/ModalPresenter.d.ts +34 -0
- package/types/components/FAB/ActionGroup/ModalPresenter/index.d.ts +3 -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 +0 -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 +0 -0
- package/types/components/Tabs/ScrollableTabs.d.ts +0 -0
- package/types/components/Tabs/ScrollableTabsHeader.d.ts +0 -0
- package/types/components/Tabs/ScrollableTabsV2/SceneView.d.ts +10 -0
- package/types/components/Tabs/ScrollableTabsV2/ScrollableTabsV2.d.ts +9 -0
- package/types/components/Tabs/ScrollableTabsV2/index.d.ts +4 -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 +0 -0
- package/types/components/Tabs/useIsFocused.d.ts +0 -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 +2 -1
- 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 +1 -1
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.35.0-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.34.
|
|
24
|
+
"@hero-design/colors": "8.34.1",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@hero-design/react-native-month-year-picker": "^8.34.
|
|
30
|
+
"@hero-design/react-native-month-year-picker": "^8.34.1",
|
|
31
31
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
32
32
|
"@react-native-community/slider": "4.1.12",
|
|
33
33
|
"react": "18.0.0",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@babel/preset-typescript": "^7.17.12",
|
|
48
48
|
"@babel/runtime": "^7.18.9",
|
|
49
49
|
"@emotion/jest": "^11.9.3",
|
|
50
|
-
"@hero-design/eslint-plugin": "8.34.
|
|
51
|
-
"@hero-design/react-native-month-year-picker": "^8.34.
|
|
50
|
+
"@hero-design/eslint-plugin": "8.34.1",
|
|
51
|
+
"@hero-design/react-native-month-year-picker": "^8.34.1",
|
|
52
52
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
53
53
|
"@react-native-community/slider": "4.1.12",
|
|
54
54
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"@types/react-native": "^0.67.7",
|
|
65
65
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
66
66
|
"babel-plugin-inline-import": "^3.0.0",
|
|
67
|
-
"eslint-config-hd": "8.34.
|
|
67
|
+
"eslint-config-hd": "8.34.1",
|
|
68
68
|
"eslint-plugin-import": "^2.27.5",
|
|
69
69
|
"jest": "^27.3.1",
|
|
70
|
-
"prettier-config-hd": "8.34.
|
|
70
|
+
"prettier-config-hd": "8.34.1",
|
|
71
71
|
"react": "18.0.0",
|
|
72
72
|
"react-native": "0.69.7",
|
|
73
73
|
"react-native-gesture-handler": "~2.5.0",
|
|
@@ -82,5 +82,6 @@
|
|
|
82
82
|
"rollup-plugin-flow": "^1.1.1",
|
|
83
83
|
"ts-jest": "^27.0.7"
|
|
84
84
|
},
|
|
85
|
-
"prettier": "prettier-config-hd"
|
|
85
|
+
"prettier": "prettier-config-hd",
|
|
86
|
+
"react-native": "src/index.ts"
|
|
86
87
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dimensions, View, ViewStyle } from 'react-native';
|
|
3
|
+
import { ModalHandler, showFABModal } from './ModalPresenter';
|
|
4
|
+
|
|
5
|
+
const wrapperStyle: ViewStyle = {
|
|
6
|
+
width: Dimensions.get('window').width,
|
|
7
|
+
height: Dimensions.get('window').height,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface ModalProps {
|
|
11
|
+
/**
|
|
12
|
+
* Content of the modal.
|
|
13
|
+
*/
|
|
14
|
+
children: React.ReactElement;
|
|
15
|
+
/**
|
|
16
|
+
* Visibility of the modal
|
|
17
|
+
*/
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Callback when the modal is shown.
|
|
21
|
+
*/
|
|
22
|
+
onShow?: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* TestID of the modal.
|
|
25
|
+
*/
|
|
26
|
+
testID?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const fABModal = ({ children, onShow, testID, visible = true }: ModalProps) => {
|
|
30
|
+
const [modalHandler, setModalHandler] = React.useState<ModalHandler>();
|
|
31
|
+
|
|
32
|
+
const getModalContent = React.useCallback(
|
|
33
|
+
() => (
|
|
34
|
+
<View pointerEvents="box-none" style={wrapperStyle} testID={testID}>
|
|
35
|
+
{children}
|
|
36
|
+
</View>
|
|
37
|
+
),
|
|
38
|
+
[visible, children, onShow, testID]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (visible) {
|
|
43
|
+
// Modal does not exist, create a new one
|
|
44
|
+
if (!modalHandler) {
|
|
45
|
+
const newModalHandler = showFABModal(getModalContent());
|
|
46
|
+
setModalHandler(newModalHandler);
|
|
47
|
+
|
|
48
|
+
onShow?.();
|
|
49
|
+
}
|
|
50
|
+
// Modal already exists, update it
|
|
51
|
+
else {
|
|
52
|
+
modalHandler.update(getModalContent());
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
modalHandler?.dismiss();
|
|
56
|
+
setModalHandler(undefined);
|
|
57
|
+
}
|
|
58
|
+
}, [getModalContent]);
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default fABModal;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, View, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type ModalContentWrapperProps = {
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
visible?: boolean;
|
|
7
|
+
testID?: string;
|
|
8
|
+
style?: StyleProp<ViewStyle>;
|
|
9
|
+
animated?: boolean;
|
|
10
|
+
pointerEvents: 'box-none' | 'none' | 'box-only' | 'auto';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ModalContentWrapperHandler = {
|
|
14
|
+
hide: (callback?: () => void) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const FABModalContentWrapper = ({
|
|
18
|
+
children,
|
|
19
|
+
testID,
|
|
20
|
+
pointerEvents,
|
|
21
|
+
}: ModalContentWrapperProps) => {
|
|
22
|
+
return (
|
|
23
|
+
<View testID={testID} pointerEvents={pointerEvents}>
|
|
24
|
+
{children}
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
FABModalContentWrapper.displayName = 'FABModalContentWrapper';
|
|
30
|
+
|
|
31
|
+
export default FABModalContentWrapper;
|
|
@@ -0,0 +1,133 @@
|
|
|
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 Box from '../../../Box';
|
|
5
|
+
|
|
6
|
+
export type ModalPresenterHandles = {
|
|
7
|
+
animatedOut: (completion?: () => void) => void;
|
|
8
|
+
};
|
|
9
|
+
export type FABModalDismissFunc = (onDismiss?: () => void) => void;
|
|
10
|
+
export type FABModalUpdateFunc = (content: React.ReactNode) => void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Modal handler is returned by `showModal` function.
|
|
14
|
+
*/
|
|
15
|
+
export type FABModalHandler = {
|
|
16
|
+
/**
|
|
17
|
+
* Same `dismiss` function as in `ModalContentProps`.
|
|
18
|
+
*/
|
|
19
|
+
dismiss: FABModalDismissFunc;
|
|
20
|
+
/**
|
|
21
|
+
* Same `update` function as in `ModalContentProps`.
|
|
22
|
+
*/
|
|
23
|
+
update: FABModalUpdateFunc;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const FABModalPresenter = forwardRef<ModalPresenterHandles, ViewProps>(
|
|
27
|
+
({ style, children, ...props }, ref) => {
|
|
28
|
+
const animatedOpacity = useRef(new Animated.Value(0));
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
Animated.spring(animatedOpacity.current, {
|
|
32
|
+
toValue: 1,
|
|
33
|
+
useNativeDriver: true,
|
|
34
|
+
}).start();
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
React.useImperativeHandle(ref, () => ({
|
|
38
|
+
animatedOut: (completion?: () => void) => {
|
|
39
|
+
Animated.spring(animatedOpacity.current, {
|
|
40
|
+
toValue: 0,
|
|
41
|
+
useNativeDriver: true,
|
|
42
|
+
}).start(() => {
|
|
43
|
+
completion?.();
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Box style={StyleSheet.absoluteFill} pointerEvents="box-none">
|
|
50
|
+
<Animated.View
|
|
51
|
+
style={[
|
|
52
|
+
{
|
|
53
|
+
width: '100%',
|
|
54
|
+
height: '100%',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
opacity: animatedOpacity.current,
|
|
58
|
+
},
|
|
59
|
+
style,
|
|
60
|
+
]}
|
|
61
|
+
{...props}
|
|
62
|
+
pointerEvents="box-none"
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</Animated.View>
|
|
66
|
+
</Box>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Present a modal on screen immediately.
|
|
73
|
+
*
|
|
74
|
+
* The new presented modal will be on top of existing modals if there are any.
|
|
75
|
+
*
|
|
76
|
+
* @param Content A component to be presented as a modal on screen.
|
|
77
|
+
* This component will be centered horizontally and vertically on screen with
|
|
78
|
+
* a semitransparent black overlay underneath.
|
|
79
|
+
* @param contentProps Props for this modal component.
|
|
80
|
+
* @returns A `ModalHandler` you can use to dismiss the modal.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
export const showFABModal = (content: React.ReactNode): FABModalHandler => {
|
|
84
|
+
let ref: ModalPresenterHandles | null = null;
|
|
85
|
+
let rootSiblings: RootSiblings | null = null;
|
|
86
|
+
|
|
87
|
+
const dismiss: FABModalDismissFunc = (onDismiss) => {
|
|
88
|
+
if (rootSiblings) {
|
|
89
|
+
const cleanup = () => {
|
|
90
|
+
rootSiblings?.destroy();
|
|
91
|
+
rootSiblings = null;
|
|
92
|
+
ref = null;
|
|
93
|
+
onDismiss?.();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
if (ref) {
|
|
97
|
+
ref.animatedOut(cleanup);
|
|
98
|
+
} else {
|
|
99
|
+
cleanup();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const update: FABModalUpdateFunc = (newContent) => {
|
|
105
|
+
rootSiblings?.update(
|
|
106
|
+
<FABModalPresenter
|
|
107
|
+
ref={(_ref) => {
|
|
108
|
+
ref = _ref;
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{newContent}
|
|
112
|
+
</FABModalPresenter>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
rootSiblings = new RootSiblings(
|
|
117
|
+
(
|
|
118
|
+
<FABModalPresenter
|
|
119
|
+
ref={(_ref) => {
|
|
120
|
+
ref = _ref;
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{content}
|
|
124
|
+
</FABModalPresenter>
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return { dismiss, update };
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
FABModalPresenter.displayName = 'FABModalPresenter';
|
|
132
|
+
|
|
133
|
+
export default FABModalPresenter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FABModalDismissFunc,
|
|
3
|
+
FABModalHandler,
|
|
4
|
+
showFABModal,
|
|
5
|
+
ModalPresenterHandles,
|
|
6
|
+
} from './ModalPresenter';
|
|
7
|
+
|
|
8
|
+
export type {
|
|
9
|
+
FABModalDismissFunc as ModalDismissFunc,
|
|
10
|
+
FABModalHandler as ModalHandler,
|
|
11
|
+
ModalPresenterHandles,
|
|
12
|
+
};
|
|
13
|
+
export { showFABModal };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef, useRef } from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
import { Animated, Platform } from 'react-native';
|
|
3
|
+
import { Animated, Modal, Platform } from 'react-native';
|
|
4
4
|
import type { IconName } from '../../Icon';
|
|
5
5
|
import type { ActionItemProps } from './ActionItem';
|
|
6
6
|
import ActionItem from './ActionItem';
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
import Box from '../../Box';
|
|
16
16
|
import { FABHandles } from '../FAB';
|
|
17
|
+
import { FABModal } from '../../..';
|
|
17
18
|
|
|
18
19
|
export type ActionGroupHandles = {
|
|
19
20
|
showFAB: () => void;
|
|
@@ -31,7 +32,6 @@ export interface ActionGroupProps {
|
|
|
31
32
|
* This function is called on pressing the FAB button.
|
|
32
33
|
* */
|
|
33
34
|
onPress?: () => void;
|
|
34
|
-
|
|
35
35
|
/**
|
|
36
36
|
* Specify if the FAB button is in active state and the action group is shown.
|
|
37
37
|
* */
|
|
@@ -125,40 +125,60 @@ const ActionGroup = forwardRef<ActionGroupHandles, ActionGroupProps>(
|
|
|
125
125
|
|
|
126
126
|
return (
|
|
127
127
|
<StyledContainer testID={testID} pointerEvents="box-none" style={style}>
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
<FABModal visible={active}>
|
|
129
|
+
<StyledContainer
|
|
130
|
+
testID={testID}
|
|
131
|
+
pointerEvents="box-none"
|
|
132
|
+
style={style}
|
|
133
|
+
>
|
|
134
|
+
<StyledBackdrop
|
|
135
|
+
pointerEvents={active ? 'auto' : 'box-none'}
|
|
136
|
+
testID="back-drop"
|
|
137
|
+
style={{
|
|
138
|
+
opacity: interpolatedBackdropOpacityAnimation,
|
|
139
|
+
backgroundColor: 'yellow',
|
|
140
|
+
}}
|
|
141
|
+
/>
|
|
142
|
+
<StyledActionGroupContainer
|
|
143
|
+
pointerEvents={active ? 'auto' : 'none'}
|
|
144
|
+
testID="action-group"
|
|
145
|
+
style={{
|
|
146
|
+
opacity: interpolatedActionGroupOpacityAnimation,
|
|
147
|
+
flex: 1,
|
|
148
|
+
}}
|
|
143
149
|
>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
{!!headerTitle && (
|
|
151
|
+
<Animated.View
|
|
152
|
+
style={{ transform: [{ translateY: titleTranslateY }] }}
|
|
153
|
+
>
|
|
154
|
+
<StyledHeaderText testID="header-text" level="h4">
|
|
155
|
+
{headerTitle}
|
|
156
|
+
</StyledHeaderText>
|
|
157
|
+
</Animated.View>
|
|
158
|
+
)}
|
|
159
|
+
|
|
160
|
+
<Box style={[style, { paddingBottom: 0 }]}>
|
|
161
|
+
{items?.map((itemProp, index) => (
|
|
162
|
+
<ActionItem
|
|
163
|
+
key={itemProp.key || `${itemProp.icon}_${itemProp.title}`}
|
|
164
|
+
{...itemProp}
|
|
165
|
+
index={active ? index : items.length - index}
|
|
166
|
+
active={active}
|
|
167
|
+
/>
|
|
168
|
+
))}
|
|
169
|
+
</Box>
|
|
170
|
+
</StyledActionGroupContainer>
|
|
171
|
+
<StyledFAB
|
|
172
|
+
testID="fab"
|
|
173
|
+
icon={fabIcon}
|
|
174
|
+
onPress={onPress}
|
|
175
|
+
animated
|
|
176
|
+
active={active}
|
|
177
|
+
title={fabTitle}
|
|
178
|
+
ref={fabRef}
|
|
179
|
+
/>
|
|
180
|
+
</StyledContainer>
|
|
181
|
+
</FABModal>
|
|
162
182
|
<StyledFAB
|
|
163
183
|
testID="fab"
|
|
164
184
|
icon={fabIcon}
|
|
@@ -163,7 +163,16 @@ const FAB = forwardRef<FABHandles, FABProps>(
|
|
|
163
163
|
return (
|
|
164
164
|
<StyledFAB
|
|
165
165
|
/** Add a small timeout before executing animation to prevent flakiness */
|
|
166
|
-
onLayout={() =>
|
|
166
|
+
onLayout={() => {
|
|
167
|
+
setTimeout(() => setCanAnimate(true), 500);
|
|
168
|
+
}}
|
|
169
|
+
ref={(ref) => {
|
|
170
|
+
if (ref) {
|
|
171
|
+
ref.measureInWindow((x, y, width, height) => {
|
|
172
|
+
console.log('measureInWindow', x, y, width, height);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}}
|
|
167
176
|
underlayColor={theme.__hd__.fab.colors.buttonPressedBackground}
|
|
168
177
|
onPress={onPress}
|
|
169
178
|
style={[
|