@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.
Files changed (294) hide show
  1. package/.tool-versions +1 -0
  2. package/.turbo/turbo-build.log +2 -2
  3. package/.turbo/turbo-build:types.log +9 -0
  4. package/.turbo/turbo-lint.log +163 -0
  5. package/.turbo/turbo-publish:npm.log +9 -0
  6. package/.turbo/turbo-test.log +725 -0
  7. package/.turbo/turbo-type-check.log +1 -0
  8. package/es/index.js +235 -93
  9. package/lib/index.js +235 -92
  10. package/package.json +9 -8
  11. package/src/components/FAB/ActionGroup/FABModal.tsx +63 -0
  12. package/src/components/FAB/ActionGroup/FABModalContentWrapper.tsx +31 -0
  13. package/src/components/FAB/ActionGroup/ModalPresenter/ModalPresenter.tsx +133 -0
  14. package/src/components/FAB/ActionGroup/ModalPresenter/index.tsx +13 -0
  15. package/src/components/FAB/ActionGroup/index.tsx +55 -35
  16. package/src/components/FAB/FAB.tsx +10 -1
  17. package/src/components/Progress/StyledProgressBar.tsx +0 -1
  18. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +44 -46
  19. package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +7 -4
  20. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
  21. package/src/components/Switch/SelectorSwitch/index.tsx +15 -7
  22. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +12 -12
  23. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +4 -4
  24. package/src/index.ts +2 -0
  25. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +7 -7
  26. package/src/theme/components/progress.ts +2 -2
  27. package/src/theme/components/switch.ts +4 -4
  28. package/src/theme/components/tabs.ts +1 -1
  29. package/types/components/Accordion/AccordionItem.d.ts +0 -0
  30. package/types/components/Accordion/StyledAccordion.d.ts +0 -0
  31. package/types/components/Accordion/index.d.ts +0 -0
  32. package/types/components/Alert/StyledAlert.d.ts +0 -0
  33. package/types/components/Alert/index.d.ts +0 -0
  34. package/types/components/Attachment/StyledAttachment.d.ts +0 -0
  35. package/types/components/Attachment/index.d.ts +0 -0
  36. package/types/components/Avatar/Avatar.d.ts +0 -0
  37. package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +0 -0
  38. package/types/components/Avatar/AvatarStack/index.d.ts +0 -0
  39. package/types/components/Avatar/AvatarStack/utils.d.ts +0 -0
  40. package/types/components/Avatar/StyledAvatar.d.ts +0 -0
  41. package/types/components/Avatar/index.d.ts +0 -0
  42. package/types/components/Badge/Status.d.ts +0 -0
  43. package/types/components/Badge/StyledBadge.d.ts +0 -0
  44. package/types/components/Badge/index.d.ts +0 -0
  45. package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -0
  46. package/types/components/BottomNavigation/index.d.ts +0 -0
  47. package/types/components/BottomSheet/BottomSheetContext.d.ts +0 -0
  48. package/types/components/BottomSheet/Footer.d.ts +0 -0
  49. package/types/components/BottomSheet/Header.d.ts +0 -0
  50. package/types/components/BottomSheet/ScrollView.d.ts +0 -0
  51. package/types/components/BottomSheet/StyledBottomSheet.d.ts +0 -0
  52. package/types/components/BottomSheet/index.d.ts +0 -0
  53. package/types/components/Box/StyledBox.d.ts +0 -0
  54. package/types/components/Box/config.d.ts +0 -0
  55. package/types/components/Box/index.d.ts +0 -0
  56. package/types/components/Box/types.d.ts +0 -0
  57. package/types/components/Button/Button.d.ts +0 -0
  58. package/types/components/Button/IconButton.d.ts +0 -0
  59. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +0 -0
  60. package/types/components/Button/LoadingIndicator/index.d.ts +0 -0
  61. package/types/components/Button/StyledButton.d.ts +0 -0
  62. package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +0 -0
  63. package/types/components/Button/UtilityButton/index.d.ts +0 -0
  64. package/types/components/Button/index.d.ts +0 -0
  65. package/types/components/Calendar/CalendarRowItem.d.ts +0 -0
  66. package/types/components/Calendar/StyledCalendar.d.ts +0 -0
  67. package/types/components/Calendar/helpers.d.ts +0 -0
  68. package/types/components/Calendar/index.d.ts +0 -0
  69. package/types/components/Card/DataCard/StyledDataCard.d.ts +0 -0
  70. package/types/components/Card/DataCard/index.d.ts +0 -0
  71. package/types/components/Card/StyledCard.d.ts +0 -0
  72. package/types/components/Card/index.d.ts +0 -0
  73. package/types/components/Carousel/CardCarousel.d.ts +0 -0
  74. package/types/components/Carousel/CarouselItem.d.ts +0 -0
  75. package/types/components/Carousel/StyledCardCarousel.d.ts +0 -0
  76. package/types/components/Carousel/StyledCarousel.d.ts +0 -0
  77. package/types/components/Carousel/contants.d.ts +0 -0
  78. package/types/components/Carousel/index.d.ts +0 -0
  79. package/types/components/Carousel/types.d.ts +0 -0
  80. package/types/components/Checkbox/StyledCheckbox.d.ts +0 -0
  81. package/types/components/Checkbox/index.d.ts +0 -0
  82. package/types/components/Collapse/StyledCollapse.d.ts +0 -0
  83. package/types/components/Collapse/index.d.ts +0 -0
  84. package/types/components/ContentNavigator/StyledContentNavigator.d.ts +0 -0
  85. package/types/components/ContentNavigator/index.d.ts +0 -0
  86. package/types/components/DatePicker/DatePickerAndroid.d.ts +0 -0
  87. package/types/components/DatePicker/DatePickerCalendar.d.ts +0 -0
  88. package/types/components/DatePicker/DatePickerIOS.d.ts +0 -0
  89. package/types/components/DatePicker/StyledDatePicker.d.ts +0 -0
  90. package/types/components/DatePicker/index.d.ts +0 -0
  91. package/types/components/DatePicker/types.d.ts +0 -0
  92. package/types/components/Divider/StyledDivider.d.ts +0 -0
  93. package/types/components/Divider/index.d.ts +0 -0
  94. package/types/components/Drawer/DragableDrawer/helpers.d.ts +0 -0
  95. package/types/components/Drawer/DragableDrawer/index.d.ts +0 -0
  96. package/types/components/Drawer/StyledDrawer.d.ts +0 -0
  97. package/types/components/Drawer/index.d.ts +0 -0
  98. package/types/components/Empty/StyledEmpty.d.ts +0 -0
  99. package/types/components/Empty/index.d.ts +0 -0
  100. package/types/components/Error/StyledError.d.ts +0 -0
  101. package/types/components/Error/index.d.ts +0 -0
  102. package/types/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
  103. package/types/components/FAB/ActionGroup/FABModal.d.ts +21 -0
  104. package/types/components/FAB/ActionGroup/FABModalContentWrapper.d.ts +18 -0
  105. package/types/components/FAB/ActionGroup/FABProvider.d.ts +5 -0
  106. package/types/components/FAB/ActionGroup/ModalPresenter/ModalPresenter.d.ts +34 -0
  107. package/types/components/FAB/ActionGroup/ModalPresenter/index.d.ts +3 -0
  108. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -0
  109. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -0
  110. package/types/components/FAB/ActionGroup/index.d.ts +0 -0
  111. package/types/components/FAB/AnimatedFABIcon.d.ts +0 -0
  112. package/types/components/FAB/FAB.d.ts +0 -0
  113. package/types/components/FAB/StyledFAB.d.ts +0 -0
  114. package/types/components/FAB/index.d.ts +0 -0
  115. package/types/components/Icon/AnimatedIcon.d.ts +0 -0
  116. package/types/components/Icon/HeroIcon/index.d.ts +0 -0
  117. package/types/components/Icon/IconList.d.ts +0 -0
  118. package/types/components/Icon/index.d.ts +0 -0
  119. package/types/components/Icon/utils.d.ts +0 -0
  120. package/types/components/Image/index.d.ts +0 -0
  121. package/types/components/List/BasicListItem.d.ts +0 -0
  122. package/types/components/List/ListItem.d.ts +0 -0
  123. package/types/components/List/StyledBasicListItem.d.ts +0 -0
  124. package/types/components/List/StyledListItem.d.ts +0 -0
  125. package/types/components/List/index.d.ts +0 -0
  126. package/types/components/PageControl/StyledPageControl.d.ts +0 -0
  127. package/types/components/PageControl/index.d.ts +0 -0
  128. package/types/components/PinInput/PinCell.d.ts +0 -0
  129. package/types/components/PinInput/StyledPinInput.d.ts +0 -0
  130. package/types/components/PinInput/index.d.ts +0 -0
  131. package/types/components/Progress/ProgressBar.d.ts +0 -0
  132. package/types/components/Progress/ProgressCircle.d.ts +0 -0
  133. package/types/components/Progress/StyledProgressBar.d.ts +0 -0
  134. package/types/components/Progress/StyledProgressCircle.d.ts +0 -0
  135. package/types/components/Progress/__tests__/index.spec.d.ts +0 -0
  136. package/types/components/Progress/constants.d.ts +0 -0
  137. package/types/components/Progress/index.d.ts +0 -0
  138. package/types/components/Progress/types.d.ts +0 -0
  139. package/types/components/Radio/Radio.d.ts +0 -0
  140. package/types/components/Radio/RadioGroup.d.ts +0 -0
  141. package/types/components/Radio/StyledRadio.d.ts +0 -0
  142. package/types/components/Radio/index.d.ts +0 -0
  143. package/types/components/Radio/types.d.ts +0 -0
  144. package/types/components/RefreshControl/index.d.ts +0 -0
  145. package/types/components/RichTextEditor/EditorEvent.d.ts +0 -0
  146. package/types/components/RichTextEditor/EditorToolbar.d.ts +0 -0
  147. package/types/components/RichTextEditor/MentionList.d.ts +0 -0
  148. package/types/components/RichTextEditor/RichTextEditor.d.ts +0 -0
  149. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +0 -0
  150. package/types/components/RichTextEditor/StyledToolbar.d.ts +0 -0
  151. package/types/components/RichTextEditor/__mocks__/heroEditorApp.d.ts +0 -0
  152. package/types/components/RichTextEditor/constants.d.ts +0 -0
  153. package/types/components/RichTextEditor/heroEditorApp.d.ts +0 -0
  154. package/types/components/RichTextEditor/index.d.ts +0 -0
  155. package/types/components/RichTextEditor/types.d.ts +0 -0
  156. package/types/components/RichTextEditor/utils/events.d.ts +0 -0
  157. package/types/components/RichTextEditor/utils/rnWebView.d.ts +0 -0
  158. package/types/components/SectionHeading/StyledHeading.d.ts +0 -0
  159. package/types/components/SectionHeading/index.d.ts +0 -0
  160. package/types/components/Select/BaseOptionList.d.ts +0 -0
  161. package/types/components/Select/Footer.d.ts +0 -0
  162. package/types/components/Select/MultiSelect/Option.d.ts +0 -0
  163. package/types/components/Select/MultiSelect/OptionList.d.ts +0 -0
  164. package/types/components/Select/MultiSelect/index.d.ts +0 -0
  165. package/types/components/Select/SingleSelect/Option.d.ts +0 -0
  166. package/types/components/Select/SingleSelect/OptionList.d.ts +0 -0
  167. package/types/components/Select/SingleSelect/StyledSingleSelect.d.ts +0 -0
  168. package/types/components/Select/SingleSelect/index.d.ts +0 -0
  169. package/types/components/Select/StyledSelect.d.ts +0 -0
  170. package/types/components/Select/helpers.d.ts +0 -0
  171. package/types/components/Select/index.d.ts +0 -0
  172. package/types/components/Select/types.d.ts +0 -0
  173. package/types/components/Skeleton/StyledSkeleton.d.ts +0 -0
  174. package/types/components/Skeleton/index.d.ts +0 -0
  175. package/types/components/Slider/index.d.ts +0 -0
  176. package/types/components/Spinner/AnimatedSpinner.d.ts +0 -0
  177. package/types/components/Spinner/StyledSpinner.d.ts +0 -0
  178. package/types/components/Spinner/index.d.ts +0 -0
  179. package/types/components/Success/StyledSuccess.d.ts +0 -0
  180. package/types/components/Success/index.d.ts +0 -0
  181. package/types/components/Swipeable/StyledSwipeable.d.ts +0 -0
  182. package/types/components/Swipeable/SwipeableAction.d.ts +0 -0
  183. package/types/components/Swipeable/index.d.ts +0 -0
  184. package/types/components/Switch/SelectorSwitch/Option.d.ts +0 -0
  185. package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +0 -0
  186. package/types/components/Switch/SelectorSwitch/index.d.ts +0 -0
  187. package/types/components/Switch/StyledSwitch.d.ts +0 -0
  188. package/types/components/Switch/index.d.ts +0 -0
  189. package/types/components/Tabs/ActiveTabIndicator.d.ts +0 -0
  190. package/types/components/Tabs/SceneView.d.ts +0 -0
  191. package/types/components/Tabs/ScrollableTabs.d.ts +0 -0
  192. package/types/components/Tabs/ScrollableTabsHeader.d.ts +0 -0
  193. package/types/components/Tabs/ScrollableTabsV2/SceneView.d.ts +10 -0
  194. package/types/components/Tabs/ScrollableTabsV2/ScrollableTabsV2.d.ts +9 -0
  195. package/types/components/Tabs/ScrollableTabsV2/index.d.ts +4 -0
  196. package/types/components/Tabs/StyledScrollableTabs.d.ts +0 -0
  197. package/types/components/Tabs/StyledTabs.d.ts +0 -0
  198. package/types/components/Tabs/TabWithBadge.d.ts +0 -0
  199. package/types/components/Tabs/index.d.ts +0 -0
  200. package/types/components/Tabs/useIsFocused.d.ts +0 -0
  201. package/types/components/Tabs/utils.d.ts +0 -0
  202. package/types/components/Tag/StyledTag.d.ts +0 -0
  203. package/types/components/Tag/index.d.ts +0 -0
  204. package/types/components/TextInput/StyledTextInput.d.ts +0 -0
  205. package/types/components/TextInput/index.d.ts +0 -0
  206. package/types/components/TimePicker/StyledTimePicker.d.ts +0 -0
  207. package/types/components/TimePicker/TimePickerAndroid.d.ts +0 -0
  208. package/types/components/TimePicker/TimePickerIOS.d.ts +0 -0
  209. package/types/components/TimePicker/index.d.ts +0 -0
  210. package/types/components/TimePicker/types.d.ts +0 -0
  211. package/types/components/Toast/StyledToast.d.ts +0 -0
  212. package/types/components/Toast/Toast.d.ts +0 -0
  213. package/types/components/Toast/ToastContainer.d.ts +0 -0
  214. package/types/components/Toast/ToastContext.d.ts +0 -0
  215. package/types/components/Toast/ToastProvider.d.ts +0 -0
  216. package/types/components/Toast/index.d.ts +0 -0
  217. package/types/components/Toast/types.d.ts +0 -0
  218. package/types/components/Toolbar/StyledToolbar.d.ts +0 -0
  219. package/types/components/Toolbar/ToolbarGroup.d.ts +0 -0
  220. package/types/components/Toolbar/ToolbarItem.d.ts +0 -0
  221. package/types/components/Toolbar/index.d.ts +0 -0
  222. package/types/components/Typography/Text/StyledText.d.ts +0 -0
  223. package/types/components/Typography/Text/index.d.ts +0 -0
  224. package/types/components/Typography/index.d.ts +0 -0
  225. package/types/index.d.ts +2 -1
  226. package/types/testHelpers/renderWithTheme.d.ts +0 -0
  227. package/types/theme/ThemeProvider.d.ts +0 -0
  228. package/types/theme/ThemeSwitcher.d.ts +0 -0
  229. package/types/theme/components/accordion.d.ts +0 -0
  230. package/types/theme/components/alert.d.ts +0 -0
  231. package/types/theme/components/attachment.d.ts +0 -0
  232. package/types/theme/components/avatar.d.ts +0 -0
  233. package/types/theme/components/badge.d.ts +0 -0
  234. package/types/theme/components/bottomNavigation.d.ts +0 -0
  235. package/types/theme/components/bottomSheet.d.ts +0 -0
  236. package/types/theme/components/button.d.ts +0 -0
  237. package/types/theme/components/calendar.d.ts +0 -0
  238. package/types/theme/components/card.d.ts +0 -0
  239. package/types/theme/components/cardCarousel.d.ts +0 -0
  240. package/types/theme/components/carousel.d.ts +0 -0
  241. package/types/theme/components/checkbox.d.ts +0 -0
  242. package/types/theme/components/contentNavigator.d.ts +0 -0
  243. package/types/theme/components/datePicker.d.ts +0 -0
  244. package/types/theme/components/divider.d.ts +0 -0
  245. package/types/theme/components/drawer.d.ts +0 -0
  246. package/types/theme/components/empty.d.ts +0 -0
  247. package/types/theme/components/error.d.ts +0 -0
  248. package/types/theme/components/fab.d.ts +0 -0
  249. package/types/theme/components/icon.d.ts +0 -0
  250. package/types/theme/components/image.d.ts +0 -0
  251. package/types/theme/components/list.d.ts +0 -0
  252. package/types/theme/components/pageControl.d.ts +0 -0
  253. package/types/theme/components/pinInput.d.ts +0 -0
  254. package/types/theme/components/progress.d.ts +0 -0
  255. package/types/theme/components/radio.d.ts +0 -0
  256. package/types/theme/components/refreshControl.d.ts +0 -0
  257. package/types/theme/components/richTextEditor.d.ts +0 -0
  258. package/types/theme/components/sectionHeading.d.ts +0 -0
  259. package/types/theme/components/select.d.ts +0 -0
  260. package/types/theme/components/skeleton.d.ts +0 -0
  261. package/types/theme/components/slider.d.ts +0 -0
  262. package/types/theme/components/spinner.d.ts +0 -0
  263. package/types/theme/components/success.d.ts +0 -0
  264. package/types/theme/components/swipeable.d.ts +0 -0
  265. package/types/theme/components/switch.d.ts +1 -1
  266. package/types/theme/components/tabs.d.ts +0 -0
  267. package/types/theme/components/tag.d.ts +0 -0
  268. package/types/theme/components/textInput.d.ts +0 -0
  269. package/types/theme/components/timePicker.d.ts +0 -0
  270. package/types/theme/components/toast.d.ts +0 -0
  271. package/types/theme/components/toolbar.d.ts +0 -0
  272. package/types/theme/components/typography.d.ts +0 -0
  273. package/types/theme/getTheme.d.ts +0 -0
  274. package/types/theme/global/borders.d.ts +0 -0
  275. package/types/theme/global/colors/eBens.d.ts +0 -0
  276. package/types/theme/global/colors/global.d.ts +0 -0
  277. package/types/theme/global/colors/globalDark.d.ts +0 -0
  278. package/types/theme/global/colors/jobs.d.ts +0 -0
  279. package/types/theme/global/colors/swag.d.ts +0 -0
  280. package/types/theme/global/colors/swagDark.d.ts +0 -0
  281. package/types/theme/global/colors/types.d.ts +0 -0
  282. package/types/theme/global/colors/wallet.d.ts +0 -0
  283. package/types/theme/global/colors/work.d.ts +0 -0
  284. package/types/theme/global/index.d.ts +0 -0
  285. package/types/theme/global/scale.d.ts +0 -0
  286. package/types/theme/global/sizes.d.ts +0 -0
  287. package/types/theme/global/space.d.ts +0 -0
  288. package/types/theme/global/typography.d.ts +0 -0
  289. package/types/theme/index.d.ts +0 -0
  290. package/types/types.d.ts +0 -0
  291. package/types/utils/functions.d.ts +0 -0
  292. package/types/utils/helpers.d.ts +0 -0
  293. package/types/utils/hooks.d.ts +0 -0
  294. 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.34.2",
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.2",
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.2",
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.2",
51
- "@hero-design/react-native-month-year-picker": "^8.34.2",
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.2",
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.2",
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
- <StyledBackdrop
129
- pointerEvents={active ? 'auto' : 'box-none'}
130
- testID="back-drop"
131
- style={{ opacity: interpolatedBackdropOpacityAnimation }}
132
- />
133
- <StyledActionGroupContainer
134
- pointerEvents={active ? 'auto' : 'none'}
135
- testID="action-group"
136
- style={{
137
- opacity: interpolatedActionGroupOpacityAnimation,
138
- }}
139
- >
140
- {!!headerTitle && (
141
- <Animated.View
142
- style={{ transform: [{ translateY: titleTranslateY }] }}
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
- <StyledHeaderText testID="header-text" level="h4">
145
- {headerTitle}
146
- </StyledHeaderText>
147
- </Animated.View>
148
- )}
149
-
150
- <Box style={[style, { paddingBottom: 0 }]}>
151
- {items?.map((itemProp, index) => (
152
- <ActionItem
153
- key={itemProp.key || `${itemProp.icon}_${itemProp.title}`}
154
- {...itemProp}
155
- index={active ? index : items.length - index}
156
- active={active}
157
- />
158
- ))}
159
- </Box>
160
- </StyledActionGroupContainer>
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={() => setTimeout(() => setCanAnimate(true), 500)}
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={[
@@ -13,7 +13,6 @@ const StyledWrapper = styled(View)<ViewProps & { themeIntent: ThemeIntent }>(
13
13
  THEME_INTENT_MAP[themeIntent]
14
14
  ],
15
15
  overflow: 'hidden',
16
- borderRadius: theme.__hd__.progress.radii.default,
17
16
  })
18
17
  );
19
18