@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.
Files changed (276) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +36 -0
  3. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  4. package/es/index.js +2772 -2661
  5. package/jest-setup.ts +2 -0
  6. package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
  7. package/lib/index.js +2775 -2665
  8. package/package.json +23 -24
  9. package/rollup.config.js +0 -1
  10. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +564 -384
  11. package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +76 -20
  12. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +791 -605
  13. package/src/components/Accordion/index.tsx +1 -1
  14. package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +848 -567
  15. package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +172 -110
  16. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +138 -70
  17. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +745 -581
  18. package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +158 -57
  19. package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +273 -153
  20. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +391 -223
  21. package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +119 -63
  22. package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +306 -242
  23. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +317 -183
  24. package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +1042 -454
  25. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +6 -10
  26. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +400 -140
  27. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +1090 -880
  28. package/src/components/Button/StyledButton.tsx +4 -0
  29. package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +196 -106
  30. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1675 -1125
  31. package/src/components/Button/__tests__/__snapshots__/IconButton.spec.tsx.snap +71 -26
  32. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +1651 -665
  33. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +555 -330
  34. package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +265 -69
  35. package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +205 -65
  36. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +36 -8
  37. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +292 -124
  38. package/src/components/Carousel/CardCarousel.tsx +10 -7
  39. package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +486 -406
  40. package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +197 -70
  41. package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +41 -13
  42. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +1742 -1526
  43. package/src/components/Carousel/__tests__/index.spec.tsx +50 -3
  44. package/src/components/Carousel/index.tsx +16 -22
  45. package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +404 -112
  46. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +574 -334
  47. package/src/components/Chip/StyledChip.tsx +121 -0
  48. package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +1483 -0
  49. package/src/components/Chip/__tests__/index.spec.tsx +136 -0
  50. package/src/components/Chip/index.tsx +82 -0
  51. package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +73 -17
  52. package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +94 -38
  53. package/src/components/Collapse/index.tsx +1 -1
  54. package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +37 -9
  55. package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +424 -268
  56. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +586 -466
  57. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +200 -160
  58. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +192 -152
  59. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +471 -389
  60. package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +464 -128
  61. package/src/components/Drawer/DragableDrawer/__tests__/__snapshots__/index.spec.tsx.snap +97 -69
  62. package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +327 -192
  63. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +169 -113
  64. package/src/components/Error/StyledError.tsx +2 -1
  65. package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +390 -262
  66. package/src/components/Error/__tests__/index.spec.tsx +9 -6
  67. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +860 -723
  68. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +98 -42
  69. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +199 -99
  70. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +293 -185
  71. package/src/components/HeroDesignProvider/__tests__/__snapshots__/index.spec.tsx.snap +45 -17
  72. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  73. package/src/components/Icon/IconList.ts +3 -0
  74. package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +158 -46
  75. package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +164 -52
  76. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +242 -170
  77. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +760 -588
  78. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +272 -128
  79. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +477 -193
  80. package/src/components/Modal/__tests__/__snapshots__/index.spec.tsx.snap +169 -0
  81. package/src/components/Modal/__tests__/index.spec.tsx +99 -0
  82. package/src/components/Modal/index.tsx +178 -82
  83. package/src/components/PageControl/__tests__/__snapshots__/index.spec.tsx.snap +84 -41
  84. package/src/components/PageControl/index.tsx +1 -0
  85. package/src/components/PinInput/__tests__/StyledPinInput.spec.tsx +9 -4
  86. package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +293 -153
  87. package/src/components/PinInput/__tests__/__snapshots__/StyledPinInput.spec.tsx.snap +15 -48
  88. package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +809 -697
  89. package/src/components/Portal/__tests__/PortalHost.spec.tsx +12 -14
  90. package/src/components/Portal/__tests__/__snapshots__/index.spec.tsx.snap +43 -15
  91. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +743 -603
  92. package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +188 -116
  93. package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +257 -205
  94. package/src/components/Rate/__tests__/__snapshots__/index.spec.tsx.snap +864 -600
  95. package/src/components/RefreshControl/__tests__/__snapshots__/index.spec.tsx.snap +128 -44
  96. package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +5 -2
  97. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +3 -3
  98. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +413 -266
  99. package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +64 -35
  100. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +371 -297
  101. package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +158 -46
  102. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +394 -226
  103. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +93 -57
  104. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +2387 -2151
  105. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +621 -28
  106. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +7 -6
  107. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +73 -37
  108. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +2321 -2085
  109. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +473 -23
  110. package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +490 -294
  111. package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +117 -33
  112. package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +105 -77
  113. package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +1308 -636
  114. package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +121 -93
  115. package/src/components/Success/StyledSuccess.tsx +2 -1
  116. package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +388 -258
  117. package/src/components/Success/__tests__/index.spec.tsx +9 -6
  118. package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +210 -75
  119. package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +58 -30
  120. package/src/components/Swipeable/index.tsx +3 -3
  121. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +226 -114
  122. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +146 -109
  123. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +202 -62
  124. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +132 -68
  125. package/src/components/Tabs/__tests__/SceneView.spec.tsx +7 -7
  126. package/src/components/Tabs/__tests__/__snapshots__/SceneView.spec.tsx.snap +206 -94
  127. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +2217 -1962
  128. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +523 -455
  129. package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +121 -65
  130. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +1641 -1398
  131. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +554 -274
  132. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1542 -646
  133. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3177 -2701
  134. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +390 -310
  135. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +662 -540
  136. package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +871 -573
  137. package/src/components/Toast/__tests__/__snapshots__/ToastContainer.spec.tsx.snap +180 -68
  138. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +582 -426
  139. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +683 -363
  140. package/src/components/Typography/Body/__tests__/__snapshots__/StyledBody.tsx.snap +704 -256
  141. package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +855 -323
  142. package/src/components/Typography/Caption/__tests__/__snapshots__/StyledCaption.spec.tsx.snap +430 -150
  143. package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +572 -208
  144. package/src/components/Typography/Label/__tests__/__snapshots__/StyledLabel.tsx.snap +328 -104
  145. package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +462 -154
  146. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +900 -340
  147. package/src/components/Typography/Title/__tests__/__snapshots__/StyledTitle.tsx.snap +880 -320
  148. package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +1035 -391
  149. package/src/index.ts +2 -2
  150. package/src/testHelpers/renderWithTheme.tsx +2 -2
  151. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +38 -1
  152. package/src/theme/components/button.ts +0 -1
  153. package/src/theme/components/chip.ts +47 -0
  154. package/src/theme/getTheme.ts +3 -0
  155. package/testUtils/setup.tsx +0 -18
  156. package/tsconfig.json +4 -1
  157. package/types/components/Accordion/AccordionItem.d.ts +2 -1
  158. package/types/components/Accordion/index.d.ts +1 -1
  159. package/types/components/Attachment/index.d.ts +2 -1
  160. package/types/components/Avatar/Avatar.d.ts +2 -1
  161. package/types/components/Avatar/AvatarStack/index.d.ts +2 -2
  162. package/types/components/Avatar/index.d.ts +3 -2
  163. package/types/components/Badge/StyledBadge.d.ts +0 -4
  164. package/types/components/BottomSheet/Footer.d.ts +2 -1
  165. package/types/components/BottomSheet/Header.d.ts +2 -1
  166. package/types/components/BottomSheet/ScrollView.d.ts +1 -0
  167. package/types/components/BottomSheet/StyledBottomSheet.d.ts +0 -4
  168. package/types/components/Box/index.d.ts +2 -1
  169. package/types/components/Button/IconButton.d.ts +2 -1
  170. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +3 -3
  171. package/types/components/Button/LoadingIndicator/index.d.ts +2 -1
  172. package/types/components/Button/UtilityButton/index.d.ts +2 -1
  173. package/types/components/Calendar/CalendarRowItem.d.ts +2 -1
  174. package/types/components/Calendar/StyledCalendar.d.ts +1 -1
  175. package/types/components/Calendar/index.d.ts +2 -1
  176. package/types/components/Carousel/CardCarousel.d.ts +1 -1
  177. package/types/components/Carousel/CarouselItem.d.ts +2 -1
  178. package/types/components/Carousel/index.d.ts +2 -2
  179. package/types/components/Checkbox/index.d.ts +2 -1
  180. package/types/components/Chip/StyledChip.d.ts +31 -0
  181. package/types/components/Chip/index.d.ts +27 -0
  182. package/types/components/Collapse/StyledCollapse.d.ts +0 -2
  183. package/types/components/Collapse/index.d.ts +2 -1
  184. package/types/components/ContentNavigator/index.d.ts +2 -1
  185. package/types/components/DatePicker/DatePickerAndroid.d.ts +2 -1
  186. package/types/components/DatePicker/DatePickerCalendar.d.ts +2 -1
  187. package/types/components/DatePicker/DatePickerIOS.d.ts +2 -1
  188. package/types/components/DatePicker/index.d.ts +2 -1
  189. package/types/components/Divider/index.d.ts +2 -1
  190. package/types/components/Drawer/StyledDrawer.d.ts +0 -6
  191. package/types/components/Error/StyledError.d.ts +3 -9
  192. package/types/components/FAB/ActionGroup/ActionItem.d.ts +2 -1
  193. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -4
  194. package/types/components/FAB/AnimatedFABIcon.d.ts +2 -1
  195. package/types/components/HeroDesignProvider/index.d.ts +2 -1
  196. package/types/components/Icon/AnimatedIcon.d.ts +2 -1
  197. package/types/components/Icon/IconList.d.ts +1 -1
  198. package/types/components/Icon/index.d.ts +3 -2
  199. package/types/components/Icon/utils.d.ts +1 -1
  200. package/types/components/Image/index.d.ts +1 -0
  201. package/types/components/Modal/index.d.ts +12 -8
  202. package/types/components/PageControl/StyledPageControl.d.ts +0 -2
  203. package/types/components/PageControl/index.d.ts +2 -1
  204. package/types/components/PinInput/PinCell.d.ts +2 -1
  205. package/types/components/Portal/PortalHost.d.ts +1 -1
  206. package/types/components/Portal/PortalProvider.d.ts +1 -1
  207. package/types/components/Portal/index.d.ts +2 -2
  208. package/types/components/Progress/ProgressBar.d.ts +1 -0
  209. package/types/components/Progress/StyledProgressBar.d.ts +0 -2
  210. package/types/components/Progress/index.d.ts +1 -0
  211. package/types/components/Rate/StyledRate.d.ts +0 -2
  212. package/types/components/Rate/index.d.ts +2 -1
  213. package/types/components/RefreshControl/index.d.ts +2 -1
  214. package/types/components/RichTextEditor/EditorToolbar.d.ts +2 -1
  215. package/types/components/RichTextEditor/MentionList.d.ts +2 -1
  216. package/types/components/RichTextEditor/index.d.ts +2 -2
  217. package/types/components/Select/BaseOptionList.d.ts +1 -1
  218. package/types/components/Select/Footer.d.ts +2 -1
  219. package/types/components/Select/MultiSelect/Option.d.ts +2 -1
  220. package/types/components/Select/MultiSelect/OptionList.d.ts +2 -1
  221. package/types/components/Select/MultiSelect/index.d.ts +1 -1
  222. package/types/components/Select/SingleSelect/Option.d.ts +2 -1
  223. package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
  224. package/types/components/Select/SingleSelect/StyledSingleSelect.d.ts +2 -1
  225. package/types/components/Select/SingleSelect/index.d.ts +1 -1
  226. package/types/components/Select/helpers.d.ts +1 -2
  227. package/types/components/Select/index.d.ts +2 -1
  228. package/types/components/Skeleton/index.d.ts +2 -1
  229. package/types/components/Slider/index.d.ts +2 -1
  230. package/types/components/Spinner/AnimatedSpinner.d.ts +2 -1
  231. package/types/components/Success/StyledSuccess.d.ts +3 -7
  232. package/types/components/Swipeable/SwipeableAction.d.ts +2 -2
  233. package/types/components/Swipeable/index.d.ts +3 -3
  234. package/types/components/Switch/SelectorSwitch/Option.d.ts +2 -1
  235. package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +0 -6
  236. package/types/components/Switch/StyledSwitch.d.ts +0 -2
  237. package/types/components/Tabs/ActiveTabIndicator.d.ts +2 -1
  238. package/types/components/Tabs/SceneView.d.ts +1 -1
  239. package/types/components/Tabs/ScrollableTabs.d.ts +2 -1
  240. package/types/components/Tabs/ScrollableTabsHeader.d.ts +2 -1
  241. package/types/components/Tabs/StyledScrollableTabs.d.ts +0 -4
  242. package/types/components/Tabs/StyledTabs.d.ts +0 -4
  243. package/types/components/Tabs/TabWithBadge.d.ts +2 -2
  244. package/types/components/Tabs/index.d.ts +2 -1
  245. package/types/components/TextInput/StyledTextInput.d.ts +1 -1
  246. package/types/components/TextInput/index.d.ts +1 -1
  247. package/types/components/TimePicker/TimePickerAndroid.d.ts +2 -1
  248. package/types/components/TimePicker/TimePickerIOS.d.ts +2 -1
  249. package/types/components/TimePicker/index.d.ts +2 -1
  250. package/types/components/Toast/StyledToast.d.ts +0 -2
  251. package/types/components/Toast/Toast.d.ts +1 -0
  252. package/types/components/Toast/ToastProvider.d.ts +2 -1
  253. package/types/components/Toast/index.d.ts +1 -1
  254. package/types/components/Toolbar/ToolbarGroup.d.ts +2 -1
  255. package/types/components/Toolbar/ToolbarItem.d.ts +2 -1
  256. package/types/components/Toolbar/index.d.ts +3 -2
  257. package/types/components/Typography/Body/index.d.ts +2 -1
  258. package/types/components/Typography/Caption/index.d.ts +2 -1
  259. package/types/components/Typography/Label/index.d.ts +2 -1
  260. package/types/components/Typography/Text/index.d.ts +2 -1
  261. package/types/components/Typography/Title/index.d.ts +2 -1
  262. package/types/index.d.ts +2 -2
  263. package/types/testHelpers/renderWithTheme.d.ts +1 -0
  264. package/types/theme/ThemeSwitcher.d.ts +2 -2
  265. package/types/theme/components/button.d.ts +0 -1
  266. package/types/theme/components/chip.d.ts +40 -0
  267. package/types/theme/getTheme.d.ts +2 -0
  268. package/.turbo/turbo-publish:npm.log +0 -0
  269. package/src/components/Modal/ModalContentWrapper.tsx +0 -112
  270. package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +0 -135
  271. package/src/components/Modal/ModalPresenter/index.tsx +0 -9
  272. package/src/components/Modal/ModalProvider.tsx +0 -8
  273. package/types/components/Modal/ModalContentWrapper.d.ts +0 -16
  274. package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +0 -34
  275. package/types/components/Modal/ModalPresenter/index.d.ts +0 -3
  276. package/types/components/Modal/ModalProvider.d.ts +0 -5
@@ -0,0 +1,169 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Modal renders correctly 1`] = `
4
+ <View
5
+ style={
6
+ {
7
+ "flex": 1,
8
+ }
9
+ }
10
+ >
11
+ <View
12
+ collapsable={false}
13
+ style={
14
+ {
15
+ "backgroundColor": "#000000",
16
+ "bottom": 0,
17
+ "left": 0,
18
+ "opacity": 0.4,
19
+ "position": "absolute",
20
+ "right": 0,
21
+ "top": 0,
22
+ }
23
+ }
24
+ />
25
+ <View
26
+ collapsable={false}
27
+ style={
28
+ {
29
+ "bottom": 0,
30
+ "left": 0,
31
+ "opacity": 1,
32
+ "position": "absolute",
33
+ "right": 0,
34
+ "top": 0,
35
+ "transform": [
36
+ {
37
+ "translateY": 0,
38
+ },
39
+ ],
40
+ }
41
+ }
42
+ >
43
+ <Text
44
+ allowFontScaling={false}
45
+ style={
46
+ [
47
+ {
48
+ "color": "#001f23",
49
+ "fontFamily": "BeVietnamPro-Regular",
50
+ "fontSize": 16,
51
+ "letterSpacing": 0.48,
52
+ "lineHeight": 24,
53
+ },
54
+ undefined,
55
+ ]
56
+ }
57
+ themeIntent="body"
58
+ themeTypeface="neutral"
59
+ themeVariant="regular"
60
+ >
61
+ Modal content
62
+ </Text>
63
+ </View>
64
+ <View
65
+ pointerEvents="box-none"
66
+ position="bottom"
67
+ style={
68
+ [
69
+ {
70
+ "bottom": 0,
71
+ "elevation": 9999,
72
+ "flexDirection": "column-reverse",
73
+ "left": 0,
74
+ "paddingHorizontal": 24,
75
+ "paddingVertical": 16,
76
+ "position": "absolute",
77
+ "right": 0,
78
+ "top": 0,
79
+ },
80
+ undefined,
81
+ ]
82
+ }
83
+ />
84
+ </View>
85
+ `;
86
+
87
+ exports[`Modal renders correctly with transparent 1`] = `
88
+ <View
89
+ style={
90
+ {
91
+ "flex": 1,
92
+ }
93
+ }
94
+ >
95
+ <View
96
+ collapsable={false}
97
+ style={
98
+ {
99
+ "backgroundColor": "transparent",
100
+ "bottom": 0,
101
+ "left": 0,
102
+ "opacity": 0.4,
103
+ "position": "absolute",
104
+ "right": 0,
105
+ "top": 0,
106
+ }
107
+ }
108
+ />
109
+ <View
110
+ collapsable={false}
111
+ style={
112
+ {
113
+ "bottom": 0,
114
+ "left": 0,
115
+ "opacity": 1,
116
+ "position": "absolute",
117
+ "right": 0,
118
+ "top": 0,
119
+ "transform": [
120
+ {
121
+ "translateY": 0,
122
+ },
123
+ ],
124
+ }
125
+ }
126
+ >
127
+ <Text
128
+ allowFontScaling={false}
129
+ style={
130
+ [
131
+ {
132
+ "color": "#001f23",
133
+ "fontFamily": "BeVietnamPro-Regular",
134
+ "fontSize": 16,
135
+ "letterSpacing": 0.48,
136
+ "lineHeight": 24,
137
+ },
138
+ undefined,
139
+ ]
140
+ }
141
+ themeIntent="body"
142
+ themeTypeface="neutral"
143
+ themeVariant="regular"
144
+ >
145
+ Modal content
146
+ </Text>
147
+ </View>
148
+ <View
149
+ pointerEvents="box-none"
150
+ position="bottom"
151
+ style={
152
+ [
153
+ {
154
+ "bottom": 0,
155
+ "elevation": 9999,
156
+ "flexDirection": "column-reverse",
157
+ "left": 0,
158
+ "paddingHorizontal": 24,
159
+ "paddingVertical": 16,
160
+ "position": "absolute",
161
+ "right": 0,
162
+ "top": 0,
163
+ },
164
+ undefined,
165
+ ]
166
+ }
167
+ />
168
+ </View>
169
+ `;
@@ -0,0 +1,99 @@
1
+ import { fireEvent } from '@testing-library/react-native';
2
+ import React from 'react';
3
+ import { BackHandler } from 'react-native';
4
+ import Modal from '..';
5
+ import { Button } from '../../..';
6
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
7
+ import Portal from '../../Portal';
8
+ import Typography from '../../Typography';
9
+
10
+ describe('Modal', () => {
11
+ it('renders correctly', () => {
12
+ const wrapper = renderWithTheme(
13
+ <Portal.Provider>
14
+ <Modal visible>
15
+ <Typography.Body>Modal content</Typography.Body>
16
+ </Modal>
17
+ </Portal.Provider>
18
+ );
19
+
20
+ expect(wrapper.toJSON()).toMatchSnapshot();
21
+ });
22
+
23
+ it('renders correctly with transparent', () => {
24
+ const wrapper = renderWithTheme(
25
+ <Portal.Provider>
26
+ <Modal visible transparent>
27
+ <Typography.Body>Modal content</Typography.Body>
28
+ </Modal>
29
+ </Portal.Provider>
30
+ );
31
+
32
+ expect(wrapper.toJSON()).toMatchSnapshot();
33
+ });
34
+
35
+ it('trigger onShow callback correctly', () => {
36
+ const onShow = jest.fn();
37
+ renderWithTheme(
38
+ <Portal.Provider>
39
+ <Modal visible onShow={onShow}>
40
+ <Typography.Body>Modal content</Typography.Body>
41
+ </Modal>
42
+ </Portal.Provider>
43
+ );
44
+
45
+ expect(onShow).toBeCalledTimes(1);
46
+ });
47
+
48
+ it('trigger onRequestClose callback correctly', () => {
49
+ jest.mock('react-native/Libraries/Utilities/Platform', () => ({
50
+ OS: 'android',
51
+ select: () => null,
52
+ }));
53
+
54
+ const onRequestClose = jest.fn();
55
+ renderWithTheme(
56
+ <Portal.Provider>
57
+ <Modal visible onRequestClose={onRequestClose}>
58
+ <Typography.Body>Modal content</Typography.Body>
59
+ </Modal>
60
+ </Portal.Provider>
61
+ );
62
+
63
+ // @ts-expect-error: BackHandler mock
64
+ BackHandler.mockPressBack();
65
+ expect(onRequestClose).toBeCalled();
66
+ });
67
+
68
+ it('trigger onDismiss callback correctly', async () => {
69
+ jest.mock('react-native/Libraries/Utilities/Platform', () => ({
70
+ OS: 'ios',
71
+ select: () => null,
72
+ }));
73
+
74
+ const onDismiss = jest.fn();
75
+
76
+ const ModalExample = () => {
77
+ const [modalVisible, setModalVisible] = React.useState(true);
78
+
79
+ return (
80
+ <Portal.Provider>
81
+ <Modal
82
+ animationType="none"
83
+ visible={modalVisible}
84
+ onDismiss={onDismiss}
85
+ transparent
86
+ >
87
+ <Typography.Body>Modal content</Typography.Body>
88
+ <Button text="Close modal" onPress={() => setModalVisible(false)} />
89
+ </Modal>
90
+ </Portal.Provider>
91
+ );
92
+ };
93
+
94
+ const { getByText } = renderWithTheme(<ModalExample />);
95
+
96
+ fireEvent.press(getByText('Close modal'));
97
+ expect(onDismiss).toBeCalled();
98
+ });
99
+ });
@@ -1,21 +1,41 @@
1
- import React from 'react';
2
- import { BackHandler, Dimensions, View, ViewStyle } from 'react-native';
3
- import ModalContentWrapper, {
4
- ModalContentWrapperHandler,
5
- } from './ModalContentWrapper';
6
- import ModalProvider from './ModalProvider';
7
- import { ModalHandler, showModal } from './ModalPresenter';
8
-
9
- const wrapperStyle: ViewStyle = {
10
- width: Dimensions.get('window').width,
11
- height: Dimensions.get('window').height,
1
+ import React, {
2
+ ReactNode,
3
+ forwardRef,
4
+ useEffect,
5
+ useImperativeHandle,
6
+ useRef,
7
+ useState,
8
+ useCallback,
9
+ } from 'react';
10
+ import {
11
+ Animated,
12
+ BackHandler,
13
+ Dimensions,
14
+ Easing,
15
+ Platform,
16
+ StyleSheet,
17
+ } from 'react-native';
18
+ import { useTheme } from '../../theme';
19
+ import Portal from '../Portal';
20
+
21
+ type ModalHandles = {
22
+ show: () => void;
23
+ hide: (callback: () => void) => void;
24
+ };
25
+
26
+ const DEFAULT_BACKDROP_OPACITY = 0.4;
27
+
28
+ const DEFAULT_ANIMATION_CONFIG = {
29
+ easing: Easing.inOut(Easing.cubic),
30
+ useNativeDriver: Platform.OS !== 'web',
31
+ duration: 400,
12
32
  };
13
33
 
14
34
  export interface ModalProps {
15
35
  /**
16
36
  * Content of the modal.
17
37
  */
18
- children: React.ReactElement;
38
+ children: ReactNode;
19
39
  /**
20
40
  * Visibility of the modal
21
41
  */
@@ -36,86 +56,162 @@ export interface ModalProps {
36
56
  * Animation type of the modal content.
37
57
  */
38
58
  animationType?: 'none' | 'slide' | 'fade';
59
+ /**
60
+ * Whether to show the modal backdrop
61
+ */
62
+ transparent?: boolean;
63
+ /**
64
+ * Callback when the modal is dismissed. iOS only.
65
+ */
66
+ onDismiss?: () => void;
39
67
  }
40
68
 
41
- const Modal = ({
42
- children,
43
- onShow,
44
- onRequestClose,
45
- testID,
46
- visible = true,
47
- animationType = 'none',
48
- }: ModalProps) => {
49
- const [modalHandler, setModalHandler] = React.useState<ModalHandler>();
50
- const modalContentWrapperRef = React.useRef<ModalContentWrapperHandler>(null);
51
-
52
- const getModalContent = React.useCallback(
53
- (isUpdate = false) => {
54
- return animationType === 'none' ? (
55
- <View style={wrapperStyle} testID={testID}>
56
- {children}
57
- </View>
58
- ) : (
59
- <ModalContentWrapper
60
- visible={visible}
61
- style={wrapperStyle}
62
- animationType={animationType}
69
+ const Modal = forwardRef<ModalHandles, Omit<ModalProps, 'visible'>>(
70
+ (
71
+ {
72
+ children,
73
+ onShow,
74
+ onRequestClose,
75
+ testID,
76
+ animationType = 'none',
77
+ transparent = false,
78
+ onDismiss,
79
+ },
80
+ ref
81
+ ) => {
82
+ const theme = useTheme();
83
+ const animatedBackdropValue = useRef(new Animated.Value(0)).current;
84
+ const animatedModalValue = useRef(new Animated.Value(0)).current;
85
+
86
+ // Show or hide the backdrop and modal content
87
+ const animateBackdropAndContent = useCallback(
88
+ ({ toValue, callback }: { toValue: number; callback?: () => void }) => {
89
+ if (animationType !== 'none') {
90
+ // Backdrop animation
91
+ if (!transparent) {
92
+ Animated.timing(animatedBackdropValue, {
93
+ toValue,
94
+ ...DEFAULT_ANIMATION_CONFIG,
95
+ }).start();
96
+ }
97
+
98
+ // Modal content animation
99
+ Animated.timing(animatedModalValue, {
100
+ toValue,
101
+ ...DEFAULT_ANIMATION_CONFIG,
102
+ }).start(callback);
103
+ } else {
104
+ callback?.();
105
+ }
106
+ },
107
+ [animationType, onShow, transparent]
108
+ );
109
+
110
+ const backdropOpacityAnimation = animatedBackdropValue.interpolate({
111
+ inputRange: [0, 1],
112
+ outputRange: [0, DEFAULT_BACKDROP_OPACITY],
113
+ });
114
+
115
+ const modalAnimation = animatedModalValue.interpolate({
116
+ inputRange: [0, 1],
117
+ outputRange:
118
+ animationType === 'slide'
119
+ ? [Dimensions.get('window').height, 0]
120
+ : [0, 1],
121
+ });
122
+
123
+ useImperativeHandle(
124
+ ref,
125
+ () => {
126
+ return {
127
+ show: () => {
128
+ animateBackdropAndContent({ toValue: 1, callback: onShow });
129
+ },
130
+
131
+ hide: (wrapperCallback) => {
132
+ animateBackdropAndContent({
133
+ toValue: 0,
134
+ callback: () => {
135
+ if (Platform.OS === 'ios') {
136
+ onDismiss?.();
137
+ }
138
+
139
+ wrapperCallback();
140
+ },
141
+ });
142
+ },
143
+ };
144
+ },
145
+ [onDismiss, onShow, animateBackdropAndContent]
146
+ );
147
+
148
+ // Back button handler
149
+ useEffect(() => {
150
+ const backHandler = BackHandler.addEventListener(
151
+ 'hardwareBackPress',
152
+ () => {
153
+ onRequestClose?.();
154
+ return true;
155
+ }
156
+ );
157
+
158
+ return () => backHandler.remove();
159
+ }, [onRequestClose]);
160
+
161
+ return (
162
+ <Portal>
163
+ <Animated.View
164
+ style={{
165
+ ...StyleSheet.absoluteFillObject,
166
+ backgroundColor: transparent
167
+ ? 'transparent'
168
+ : theme.colors.overlayGlobalSurface,
169
+ opacity:
170
+ animationType !== 'none'
171
+ ? backdropOpacityAnimation
172
+ : DEFAULT_BACKDROP_OPACITY,
173
+ }}
174
+ />
175
+
176
+ <Animated.View
63
177
  testID={testID}
64
- onShow={onShow}
65
- ref={modalContentWrapperRef}
66
- animated={!isUpdate}
178
+ style={{
179
+ ...StyleSheet.absoluteFillObject,
180
+ opacity: animationType === 'fade' ? modalAnimation : 1,
181
+ transform: [
182
+ {
183
+ translateY: animationType === 'slide' ? modalAnimation : 0,
184
+ },
185
+ ],
186
+ }}
67
187
  >
68
188
  {children}
69
- </ModalContentWrapper>
70
- );
71
- },
72
- [visible, children, onShow, testID, animationType]
73
- );
189
+ </Animated.View>
190
+ </Portal>
191
+ );
192
+ }
193
+ );
74
194
 
75
- React.useEffect(() => {
195
+ const ModalWrapper = ({ visible = true, ...props }: ModalProps) => {
196
+ const modalRef = useRef<ModalHandles>(null);
197
+ const [internalVisible, setInternalVisible] = useState(visible);
198
+
199
+ useEffect(() => {
76
200
  if (visible) {
77
- // Modal does not exist, create a new one
78
- if (!modalHandler) {
79
- const newModalHandler = showModal(getModalContent(false));
80
- setModalHandler(newModalHandler);
81
-
82
- // If animationType is slide for fade, onShow would be run after animation on ModalContentWrapper,
83
- // else run on this component.
84
- if (animationType === 'none') {
85
- onShow?.();
86
- }
87
- }
88
- // Modal already exists, update it
89
- else {
90
- modalHandler.update(getModalContent(true));
91
- }
92
- } else if (animationType === 'none') {
93
- modalHandler?.dismiss();
94
- setModalHandler(undefined);
201
+ setInternalVisible(true);
95
202
  } else {
96
- // Wait to finish animation before dismissing
97
- modalContentWrapperRef.current?.hide(() => {
98
- modalHandler?.dismiss();
99
- setModalHandler(undefined);
100
- });
203
+ // Wait for animation to finish before hiding the modal
204
+ modalRef.current?.hide(() => setInternalVisible(false));
101
205
  }
102
- }, [getModalContent]);
206
+ }, [visible]);
103
207
 
104
- React.useEffect(() => {
105
- const backHandler = BackHandler.addEventListener(
106
- 'hardwareBackPress',
107
- () => {
108
- onRequestClose?.();
109
- return true;
110
- }
111
- );
112
-
113
- return () => backHandler.remove();
114
- }, [onRequestClose]);
208
+ useEffect(() => {
209
+ if (internalVisible) {
210
+ modalRef.current?.show();
211
+ }
212
+ }, [internalVisible]);
115
213
 
116
- return null;
214
+ return internalVisible ? <Modal ref={modalRef} {...props} /> : null;
117
215
  };
118
216
 
119
- export default Object.assign(Modal, {
120
- Provider: ModalProvider,
121
- });
217
+ export default ModalWrapper;
@@ -3,56 +3,99 @@
3
3
  exports[`RefreshControl renders correctly 1`] = `
4
4
  <View
5
5
  style={
6
- [
7
- {
8
- "alignItems": "center",
9
- "flexDirection": "row",
10
- },
11
- undefined,
12
- ]
6
+ {
7
+ "flex": 1,
8
+ }
13
9
  }
14
10
  >
15
11
  <View
16
- collapsable={false}
17
12
  style={
18
- {
19
- "backgroundColor": "#401960",
20
- "borderRadius": 999,
21
- "height": 8,
22
- "marginHorizontal": 8,
23
- "opacity": 0.5,
24
- "width": 8,
25
- }
13
+ [
14
+ {
15
+ "alignItems": "center",
16
+ "flexDirection": "row",
17
+ },
18
+ undefined,
19
+ ]
26
20
  }
27
- testID="page-control-indicator0"
28
- />
29
- <View
30
- collapsable={false}
31
- style={
32
- {
33
- "backgroundColor": "#401960",
34
- "borderRadius": 999,
35
- "height": 8,
36
- "marginHorizontal": 8,
37
- "opacity": 1,
38
- "width": 24,
21
+ >
22
+ <View
23
+ accessibilityState={
24
+ {
25
+ "selected": false,
26
+ }
39
27
  }
40
- }
41
- testID="page-control-indicator1"
42
- />
28
+ collapsable={false}
29
+ style={
30
+ {
31
+ "backgroundColor": "#401960",
32
+ "borderRadius": 999,
33
+ "height": 8,
34
+ "marginHorizontal": 8,
35
+ "opacity": 0.5,
36
+ "width": 8,
37
+ }
38
+ }
39
+ testID="page-control-indicator0"
40
+ />
41
+ <View
42
+ accessibilityState={
43
+ {
44
+ "selected": true,
45
+ }
46
+ }
47
+ collapsable={false}
48
+ style={
49
+ {
50
+ "backgroundColor": "#401960",
51
+ "borderRadius": 999,
52
+ "height": 8,
53
+ "marginHorizontal": 8,
54
+ "opacity": 1,
55
+ "width": 24,
56
+ }
57
+ }
58
+ testID="page-control-indicator1"
59
+ />
60
+ <View
61
+ accessibilityState={
62
+ {
63
+ "selected": false,
64
+ }
65
+ }
66
+ collapsable={false}
67
+ style={
68
+ {
69
+ "backgroundColor": "#401960",
70
+ "borderRadius": 999,
71
+ "height": 8,
72
+ "marginHorizontal": 8,
73
+ "opacity": 0.5,
74
+ "width": 8,
75
+ }
76
+ }
77
+ testID="page-control-indicator2"
78
+ />
79
+ </View>
43
80
  <View
44
- collapsable={false}
81
+ pointerEvents="box-none"
82
+ position="bottom"
45
83
  style={
46
- {
47
- "backgroundColor": "#401960",
48
- "borderRadius": 999,
49
- "height": 8,
50
- "marginHorizontal": 8,
51
- "opacity": 0.5,
52
- "width": 8,
53
- }
84
+ [
85
+ {
86
+ "bottom": 0,
87
+ "elevation": 9999,
88
+ "flexDirection": "column-reverse",
89
+ "left": 0,
90
+ "paddingHorizontal": 24,
91
+ "paddingVertical": 16,
92
+ "position": "absolute",
93
+ "right": 0,
94
+ "top": 0,
95
+ },
96
+ undefined,
97
+ ]
54
98
  }
55
- testID="page-control-indicator2"
56
99
  />
57
100
  </View>
58
101
  `;
@@ -61,6 +61,7 @@ const PageControl = ({
61
61
 
62
62
  return (
63
63
  <StyledPageControlAnimatedView
64
+ accessibilityState={{ selected: index === currentPage }}
64
65
  style={[{ width: indicatorWidth, opacity }]}
65
66
  key={index.toString()}
66
67
  testID={`page-control-indicator${index}`}