@hero-design/rn 8.52.2-rc2.0 → 8.53.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 (184) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +4 -16
  3. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  4. package/es/index.js +997 -700
  5. package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
  6. package/lib/index.js +996 -698
  7. package/package.json +7 -7
  8. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +4 -0
  9. package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +2 -0
  10. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  11. package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +7 -0
  12. package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  13. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +2 -0
  14. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  15. package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +3 -0
  16. package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  17. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +6 -0
  18. package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +2 -0
  19. package/src/components/BottomNavigation/StyledBottomNavigation.tsx +60 -0
  20. package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +413 -0
  21. package/src/components/BottomNavigation/__tests__/index.spec.tsx +97 -0
  22. package/src/components/BottomNavigation/index.tsx +166 -0
  23. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +21 -32
  24. package/src/components/BottomSheet/index.tsx +1 -1
  25. package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +21 -0
  26. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +10 -0
  27. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +10 -0
  28. package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  29. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +16 -0
  30. package/src/components/Button/__tests__/__snapshots__/IconButton.spec.tsx.snap +1 -0
  31. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +32 -0
  32. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +5 -0
  33. package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +7 -0
  34. package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
  35. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +1 -0
  36. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +6 -0
  37. package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +2 -0
  38. package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +4 -0
  39. package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +1 -0
  40. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +803 -1
  41. package/src/components/Carousel/__tests__/index.spec.tsx +47 -37
  42. package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +8 -0
  43. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +6 -0
  44. package/src/components/Checkbox/index.tsx +13 -1
  45. package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +12 -0
  46. package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +2 -0
  47. package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  48. package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +1 -0
  49. package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  50. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +15 -0
  51. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
  52. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +1 -0
  53. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +329 -309
  54. package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +12 -0
  55. package/src/components/Drawer/DragableDrawer/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  56. package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  57. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  58. package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  59. package/src/components/Error/index.tsx +20 -3
  60. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  61. package/src/components/FAB/ActionGroup/index.tsx +14 -1
  62. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +2 -0
  63. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +3 -0
  64. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  65. package/src/components/HeroDesignProvider/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  66. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  67. package/src/components/Icon/IconList.ts +7 -0
  68. package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  69. package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  70. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +2 -0
  71. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +4 -0
  72. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +4 -0
  73. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +9 -0
  74. package/src/components/Modal/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  75. package/src/components/PageControl/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  76. package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +5 -0
  77. package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  78. package/src/components/Portal/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  79. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +5 -0
  80. package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +2 -0
  81. package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +1 -0
  82. package/src/components/Rate/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  83. package/src/components/RefreshControl/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  84. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +1 -0
  85. package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +1 -0
  86. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -0
  87. package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +4 -0
  88. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +6 -0
  89. package/src/components/SectionHeading/__tests__/index.spec.tsx +1 -0
  90. package/src/components/SectionHeading/index.tsx +57 -32
  91. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
  92. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +4 -0
  93. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +42 -128
  94. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
  95. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +4 -0
  96. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +35 -96
  97. package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +7 -0
  98. package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  99. package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +1 -0
  100. package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +24 -0
  101. package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  102. package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  103. package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +3 -0
  104. package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  105. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +4 -0
  106. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  107. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +5 -0
  108. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  109. package/src/components/Tabs/__tests__/SceneView.spec.tsx +1 -1
  110. package/src/components/Tabs/__tests__/__snapshots__/SceneView.spec.tsx.snap +4 -0
  111. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +3 -0
  112. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +1 -0
  113. package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +2 -0
  114. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +3 -0
  115. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +10 -0
  116. package/src/components/Tag/index.tsx +12 -0
  117. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +21 -0
  118. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +17 -0
  119. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +2 -0
  120. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +330 -309
  121. package/src/components/Toast/StyledToast.tsx +9 -7
  122. package/src/components/Toast/Toast.tsx +4 -1
  123. package/src/components/Toast/ToastContainer.tsx +6 -2
  124. package/src/components/Toast/ToastContext.ts +5 -2
  125. package/src/components/Toast/ToastProvider.tsx +19 -2
  126. package/src/components/Toast/__tests__/ToastContainer.spec.tsx +15 -12
  127. package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +7 -0
  128. package/src/components/Toast/__tests__/__snapshots__/ToastContainer.spec.tsx.snap +14 -6
  129. package/src/components/Toast/types.ts +5 -1
  130. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +3 -0
  131. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +8 -0
  132. package/src/components/Typography/Body/__tests__/__snapshots__/StyledBody.tsx.snap +16 -0
  133. package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +19 -0
  134. package/src/components/Typography/Caption/__tests__/__snapshots__/StyledCaption.spec.tsx.snap +10 -0
  135. package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +13 -0
  136. package/src/components/Typography/Label/__tests__/__snapshots__/StyledLabel.tsx.snap +8 -0
  137. package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +11 -0
  138. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +20 -0
  139. package/src/components/Typography/Title/__tests__/__snapshots__/StyledTitle.tsx.snap +20 -0
  140. package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +23 -0
  141. package/src/index.ts +2 -0
  142. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +102 -0
  143. package/src/theme/components/badge.ts +28 -1
  144. package/src/theme/components/bottomNavigation.ts +27 -0
  145. package/src/theme/components/button.ts +24 -0
  146. package/src/theme/components/carousel.ts +28 -1
  147. package/src/theme/components/empty.ts +23 -1
  148. package/src/theme/components/error.ts +32 -1
  149. package/src/theme/components/fab.ts +13 -2
  150. package/src/theme/components/pinInput.ts +32 -0
  151. package/src/theme/components/success.ts +23 -1
  152. package/src/theme/components/tag.ts +28 -1
  153. package/src/theme/components/textInput.ts +5 -0
  154. package/src/theme/getTheme.ts +21 -18
  155. package/src/types.ts +2 -0
  156. package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +52 -0
  157. package/types/components/BottomNavigation/index.d.ts +45 -0
  158. package/types/components/Checkbox/index.d.ts +6 -1
  159. package/types/components/Error/index.d.ts +9 -3
  160. package/types/components/FAB/ActionGroup/index.d.ts +5 -0
  161. package/types/components/Icon/IconList.d.ts +1 -1
  162. package/types/components/Icon/index.d.ts +1 -1
  163. package/types/components/Icon/utils.d.ts +1 -1
  164. package/types/components/SectionHeading/index.d.ts +11 -1
  165. package/types/components/Tag/index.d.ts +6 -1
  166. package/types/components/Toast/StyledToast.d.ts +2 -0
  167. package/types/components/Toast/ToastContext.d.ts +2 -2
  168. package/types/components/Toast/ToastProvider.d.ts +1 -1
  169. package/types/components/Toast/index.d.ts +1 -1
  170. package/types/components/Toast/types.d.ts +5 -1
  171. package/types/index.d.ts +2 -1
  172. package/types/theme/components/badge.d.ts +24 -0
  173. package/types/theme/components/bottomNavigation.d.ts +23 -0
  174. package/types/theme/components/button.d.ts +20 -0
  175. package/types/theme/components/carousel.d.ts +24 -0
  176. package/types/theme/components/empty.d.ts +19 -0
  177. package/types/theme/components/error.d.ts +27 -0
  178. package/types/theme/components/fab.d.ts +19 -8
  179. package/types/theme/components/pinInput.d.ts +27 -0
  180. package/types/theme/components/success.d.ts +19 -0
  181. package/types/theme/components/tag.d.ts +24 -0
  182. package/types/theme/components/textInput.d.ts +5 -0
  183. package/types/theme/getTheme.d.ts +20 -18
  184. package/types/types.d.ts +2 -1
@@ -0,0 +1,413 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`BottomNavigation renders correctly 1`] = `
4
+ <View
5
+ style={
6
+ {
7
+ "flex": 1,
8
+ }
9
+ }
10
+ >
11
+ <RNCSafeAreaProvider
12
+ onInsetsChange={[Function]}
13
+ style={
14
+ [
15
+ {
16
+ "flex": 1,
17
+ },
18
+ undefined,
19
+ ]
20
+ }
21
+ >
22
+ <View
23
+ style={
24
+ [
25
+ {
26
+ "flex": 1,
27
+ "overflow": "hidden",
28
+ },
29
+ undefined,
30
+ ]
31
+ }
32
+ >
33
+ <View
34
+ style={
35
+ [
36
+ {
37
+ "flex": 1,
38
+ },
39
+ undefined,
40
+ ]
41
+ }
42
+ >
43
+ <View
44
+ accessibilityElementsHidden={false}
45
+ collapsable={false}
46
+ importantForAccessibility="auto"
47
+ pointerEvents="auto"
48
+ removeClippedSubviews={false}
49
+ style={
50
+ [
51
+ {
52
+ "display": "flex",
53
+ "flex": 1,
54
+ },
55
+ undefined,
56
+ ]
57
+ }
58
+ themeVisibility={true}
59
+ >
60
+ <Text>
61
+ Home Screen
62
+ </Text>
63
+ </View>
64
+ </View>
65
+ <View
66
+ style={
67
+ [
68
+ {
69
+ "backgroundColor": "#ffffff",
70
+ "elevation": 10,
71
+ "height": 72,
72
+ "paddingBottom": 0,
73
+ "paddingLeft": 0,
74
+ "paddingRight": 0,
75
+ "shadowColor": "#401960",
76
+ "shadowOffset": {
77
+ "height": 3,
78
+ "width": 0,
79
+ },
80
+ "shadowOpacity": 0.27,
81
+ "shadowRadius": 4.65,
82
+ },
83
+ undefined,
84
+ ]
85
+ }
86
+ themeInsets={
87
+ {
88
+ "bottom": 0,
89
+ "left": 0,
90
+ "right": 0,
91
+ "top": 0,
92
+ }
93
+ }
94
+ >
95
+ <View
96
+ style={
97
+ [
98
+ {
99
+ "alignItems": "center",
100
+ "flex": 1,
101
+ "flexDirection": "row",
102
+ "overflow": "hidden",
103
+ },
104
+ undefined,
105
+ ]
106
+ }
107
+ >
108
+ <View
109
+ accessibilityState={
110
+ {
111
+ "busy": undefined,
112
+ "checked": undefined,
113
+ "disabled": undefined,
114
+ "expanded": undefined,
115
+ "selected": undefined,
116
+ }
117
+ }
118
+ accessible={true}
119
+ focusable={true}
120
+ onClick={[Function]}
121
+ onResponderGrant={[Function]}
122
+ onResponderMove={[Function]}
123
+ onResponderRelease={[Function]}
124
+ onResponderTerminate={[Function]}
125
+ onResponderTerminationRequest={[Function]}
126
+ onStartShouldSetResponder={[Function]}
127
+ style={
128
+ [
129
+ {
130
+ "alignItems": "center",
131
+ "flex": 1,
132
+ },
133
+ undefined,
134
+ ]
135
+ }
136
+ >
137
+ <HeroIcon
138
+ name="home"
139
+ style={
140
+ [
141
+ {
142
+ "color": "#401960",
143
+ "fontSize": 24,
144
+ },
145
+ undefined,
146
+ ]
147
+ }
148
+ testID="hero-icon-home"
149
+ themeIntent="primary"
150
+ themeSize="medium"
151
+ />
152
+ <Text
153
+ allowFontScaling={false}
154
+ numberOfLines={1}
155
+ style={
156
+ [
157
+ {
158
+ "color": "#401960",
159
+ "fontFamily": "BeVietnamPro-SemiBold",
160
+ "fontSize": 12,
161
+ "letterSpacing": 0.24,
162
+ "lineHeight": 16,
163
+ },
164
+ [
165
+ {
166
+ "marginTop": 4,
167
+ },
168
+ undefined,
169
+ ],
170
+ ]
171
+ }
172
+ themeFontWeight="semi-bold"
173
+ themeIntent="primary"
174
+ >
175
+ Home
176
+ </Text>
177
+ </View>
178
+ <View
179
+ accessibilityState={
180
+ {
181
+ "busy": undefined,
182
+ "checked": undefined,
183
+ "disabled": undefined,
184
+ "expanded": undefined,
185
+ "selected": undefined,
186
+ }
187
+ }
188
+ accessible={true}
189
+ focusable={true}
190
+ onClick={[Function]}
191
+ onResponderGrant={[Function]}
192
+ onResponderMove={[Function]}
193
+ onResponderRelease={[Function]}
194
+ onResponderTerminate={[Function]}
195
+ onResponderTerminationRequest={[Function]}
196
+ onStartShouldSetResponder={[Function]}
197
+ style={
198
+ [
199
+ {
200
+ "alignItems": "center",
201
+ "flex": 1,
202
+ },
203
+ undefined,
204
+ ]
205
+ }
206
+ >
207
+ <HeroIcon
208
+ name="speaker-outlined"
209
+ style={
210
+ [
211
+ {
212
+ "color": "#001f23",
213
+ "fontSize": 24,
214
+ },
215
+ undefined,
216
+ ]
217
+ }
218
+ testID="hero-icon-speaker-outlined"
219
+ themeIntent="text"
220
+ themeSize="medium"
221
+ />
222
+ <Text
223
+ allowFontScaling={false}
224
+ numberOfLines={1}
225
+ style={
226
+ [
227
+ {
228
+ "color": "#001f23",
229
+ "fontFamily": "BeVietnamPro-SemiBold",
230
+ "fontSize": 12,
231
+ "letterSpacing": 0.24,
232
+ "lineHeight": 16,
233
+ },
234
+ [
235
+ {
236
+ "marginTop": 4,
237
+ },
238
+ undefined,
239
+ ],
240
+ ]
241
+ }
242
+ themeFontWeight="semi-bold"
243
+ themeIntent="body"
244
+ >
245
+ Feed
246
+ </Text>
247
+ </View>
248
+ <View
249
+ accessibilityState={
250
+ {
251
+ "busy": undefined,
252
+ "checked": undefined,
253
+ "disabled": undefined,
254
+ "expanded": undefined,
255
+ "selected": undefined,
256
+ }
257
+ }
258
+ accessible={true}
259
+ focusable={true}
260
+ onClick={[Function]}
261
+ onResponderGrant={[Function]}
262
+ onResponderMove={[Function]}
263
+ onResponderRelease={[Function]}
264
+ onResponderTerminate={[Function]}
265
+ onResponderTerminationRequest={[Function]}
266
+ onStartShouldSetResponder={[Function]}
267
+ style={
268
+ [
269
+ {
270
+ "alignItems": "center",
271
+ "flex": 1,
272
+ },
273
+ undefined,
274
+ ]
275
+ }
276
+ >
277
+ <HeroIcon
278
+ name="bell-outlined"
279
+ style={
280
+ [
281
+ {
282
+ "color": "#001f23",
283
+ "fontSize": 24,
284
+ },
285
+ undefined,
286
+ ]
287
+ }
288
+ testID="hero-icon-bell-outlined"
289
+ themeIntent="text"
290
+ themeSize="medium"
291
+ />
292
+ <Text
293
+ allowFontScaling={false}
294
+ numberOfLines={1}
295
+ style={
296
+ [
297
+ {
298
+ "color": "#001f23",
299
+ "fontFamily": "BeVietnamPro-SemiBold",
300
+ "fontSize": 12,
301
+ "letterSpacing": 0.24,
302
+ "lineHeight": 16,
303
+ },
304
+ [
305
+ {
306
+ "marginTop": 4,
307
+ },
308
+ undefined,
309
+ ],
310
+ ]
311
+ }
312
+ themeFontWeight="semi-bold"
313
+ themeIntent="body"
314
+ >
315
+ Alerts
316
+ </Text>
317
+ </View>
318
+ <View
319
+ accessibilityState={
320
+ {
321
+ "busy": undefined,
322
+ "checked": undefined,
323
+ "disabled": undefined,
324
+ "expanded": undefined,
325
+ "selected": undefined,
326
+ }
327
+ }
328
+ accessible={true}
329
+ focusable={true}
330
+ onClick={[Function]}
331
+ onResponderGrant={[Function]}
332
+ onResponderMove={[Function]}
333
+ onResponderRelease={[Function]}
334
+ onResponderTerminate={[Function]}
335
+ onResponderTerminationRequest={[Function]}
336
+ onStartShouldSetResponder={[Function]}
337
+ style={
338
+ [
339
+ {
340
+ "alignItems": "center",
341
+ "flex": 1,
342
+ },
343
+ undefined,
344
+ ]
345
+ }
346
+ >
347
+ <HeroIcon
348
+ name="user-outlined"
349
+ style={
350
+ [
351
+ {
352
+ "color": "#001f23",
353
+ "fontSize": 24,
354
+ },
355
+ undefined,
356
+ ]
357
+ }
358
+ testID="hero-icon-user-outlined"
359
+ themeIntent="text"
360
+ themeSize="medium"
361
+ />
362
+ <Text
363
+ allowFontScaling={false}
364
+ numberOfLines={1}
365
+ style={
366
+ [
367
+ {
368
+ "color": "#001f23",
369
+ "fontFamily": "BeVietnamPro-SemiBold",
370
+ "fontSize": 12,
371
+ "letterSpacing": 0.24,
372
+ "lineHeight": 16,
373
+ },
374
+ [
375
+ {
376
+ "marginTop": 4,
377
+ },
378
+ undefined,
379
+ ],
380
+ ]
381
+ }
382
+ themeFontWeight="semi-bold"
383
+ themeIntent="body"
384
+ >
385
+ Profile
386
+ </Text>
387
+ </View>
388
+ </View>
389
+ </View>
390
+ </View>
391
+ </RNCSafeAreaProvider>
392
+ <View
393
+ pointerEvents="box-none"
394
+ position="bottom"
395
+ style={
396
+ [
397
+ {
398
+ "bottom": 0,
399
+ "elevation": 9999,
400
+ "flexDirection": "column-reverse",
401
+ "left": 0,
402
+ "paddingHorizontal": 24,
403
+ "paddingVertical": 16,
404
+ "position": "absolute",
405
+ "right": 0,
406
+ "top": 0,
407
+ },
408
+ undefined,
409
+ ]
410
+ }
411
+ />
412
+ </View>
413
+ `;
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import { Text } from 'react-native';
3
+ import { fireEvent } from '@testing-library/react-native';
4
+ import { SafeAreaProvider } from 'react-native-safe-area-context';
5
+ import type { ComponentProps } from 'react';
6
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
7
+ import BottomNavigation from '..';
8
+ import type { BottomNavigationTabType } from '..';
9
+
10
+ const TestComponent = (
11
+ props: Omit<
12
+ ComponentProps<typeof BottomNavigation>,
13
+ 'selectedTabKey' | 'onTabPress' | 'tabs'
14
+ >
15
+ ) => {
16
+ const [selectedTabKey, setSelectedTabKey] = React.useState('home');
17
+ const tabs: BottomNavigationTabType[] = [
18
+ {
19
+ key: 'home',
20
+ title: 'Home',
21
+ icon: 'home',
22
+ component: <Text>Home Screen</Text>,
23
+ },
24
+ {
25
+ key: 'feed',
26
+ title: 'Feed',
27
+ icon: 'speaker-outlined',
28
+ component: <Text>Feed Screen</Text>,
29
+ },
30
+ {
31
+ key: 'alerts',
32
+ title: 'Alerts',
33
+ icon: 'bell-outlined',
34
+ component: <Text>Alerts Screen</Text>,
35
+ },
36
+ {
37
+ key: 'profile',
38
+ title: 'Profile',
39
+ icon: 'user-outlined',
40
+ component: <Text>Profile Screen</Text>,
41
+ },
42
+ ];
43
+
44
+ return (
45
+ <SafeAreaProvider
46
+ initialMetrics={{
47
+ frame: { x: 0, y: 0, width: 0, height: 0 },
48
+ insets: { top: 0, left: 0, right: 0, bottom: 0 },
49
+ }}
50
+ >
51
+ <BottomNavigation
52
+ {...props}
53
+ tabs={tabs}
54
+ selectedTabKey={selectedTabKey}
55
+ onTabPress={(newTabKey) => setSelectedTabKey(newTabKey)}
56
+ />
57
+ </SafeAreaProvider>
58
+ );
59
+ };
60
+
61
+ describe('BottomNavigation', () => {
62
+ it('renders correctly', () => {
63
+ const { getByText, toJSON } = renderWithTheme(<TestComponent />);
64
+
65
+ expect(toJSON()).toMatchSnapshot();
66
+ expect(getByText('Home')).toBeDefined();
67
+ fireEvent.press(getByText('Feed'));
68
+ fireEvent.press(getByText('Alerts'));
69
+ fireEvent.press(getByText('Profile'));
70
+
71
+ // All screens are rendered and component is not unmounted when switching screen.
72
+ expect(getByText('Home Screen')).toBeDefined();
73
+ expect(getByText('Feed Screen')).toBeDefined();
74
+ expect(getByText('Alerts Screen')).toBeDefined();
75
+ expect(getByText('Profile Screen')).toBeDefined();
76
+ });
77
+
78
+ it('renders correctly with renderActiveTabOnly is true', () => {
79
+ const { getByText, queryByText, getByTestId } = renderWithTheme(
80
+ <TestComponent renderActiveTabOnly />
81
+ );
82
+
83
+ // Can switch tab by clicking icon.
84
+ expect(getByText('Home Screen')).toBeDefined();
85
+ fireEvent.press(getByTestId('hero-icon-speaker-outlined'));
86
+ expect(getByText('Feed Screen')).toBeDefined();
87
+ fireEvent.press(getByTestId('hero-icon-bell-outlined'));
88
+ expect(getByText('Alerts Screen')).toBeDefined();
89
+ fireEvent.press(getByTestId('hero-icon-user-outlined'));
90
+ expect(getByText('Profile Screen')).toBeDefined();
91
+
92
+ // Only render selected screen, others are unmounted.
93
+ expect(queryByText('Home Screen')).toBeNull();
94
+ expect(queryByText('Feed Screen')).toBeNull();
95
+ expect(queryByText('Alerts Screen')).toBeNull();
96
+ });
97
+ });
@@ -0,0 +1,166 @@
1
+ import React from 'react';
2
+ import { TouchableWithoutFeedback } from 'react-native';
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
+ import type { ReactNode } from 'react';
5
+ import type { StyleProp, ViewStyle, ViewProps } from 'react-native';
6
+ import Icon from '../Icon';
7
+ import { isHeroIcon } from '../Icon/utils';
8
+ import {
9
+ BottomBar,
10
+ BottomBarItem,
11
+ BottomBarWrapper,
12
+ BottomNavigationContainer,
13
+ BottomNavigationTab,
14
+ ContentWrapper,
15
+ StyledBottomBarText,
16
+ } from './StyledBottomNavigation';
17
+ import { isIOS } from '../../utils/helpers';
18
+ import type { IconName } from '../Icon';
19
+ import { useDeprecation } from '../../utils/hooks';
20
+
21
+ export type BottomNavigationTabType = {
22
+ key: string;
23
+ title?: string;
24
+ icon: IconName;
25
+ component: ReactNode;
26
+ testID?: string;
27
+ };
28
+
29
+ interface BottomNavigationProps extends ViewProps {
30
+ /**
31
+ * Callback which is called on tab press, receiving key of upcoming active Tab.
32
+ */
33
+ onTabPress: (key: string) => void;
34
+ /**
35
+ * Whether inactive tabs should be removed and unmounted in React.
36
+ * Defaults to `false`.
37
+ */
38
+ renderActiveTabOnly?: boolean;
39
+ /**
40
+ * Current selected tab key.
41
+ */
42
+ selectedTabKey: string;
43
+ /**
44
+ * List of Tabs to be rendered. Each Tab must have an unique key.
45
+ */
46
+ tabs: {
47
+ key: string;
48
+ title?: string;
49
+ icon: IconName;
50
+ component: ReactNode;
51
+ testID?: string;
52
+ }[];
53
+ /**
54
+ * Additional style.
55
+ */
56
+ style?: StyleProp<ViewStyle>;
57
+ /**
58
+ * Testing id of the component.
59
+ */
60
+ testID?: string;
61
+ }
62
+
63
+ const getInactiveIcon = (icon: IconName): IconName => {
64
+ const inactiveIcon = `${icon}-outlined`;
65
+ return isHeroIcon(inactiveIcon) ? inactiveIcon : icon;
66
+ };
67
+
68
+ const BottomNavigation = ({
69
+ onTabPress,
70
+ renderActiveTabOnly = false,
71
+ selectedTabKey,
72
+ tabs,
73
+ ...nativeProps
74
+ }: BottomNavigationProps): JSX.Element => {
75
+ useDeprecation(
76
+ 'BottomNavigation is deprecated and will be removed in the next major release. Please remove it.'
77
+ );
78
+ const insets = useSafeAreaInsets();
79
+
80
+ /**
81
+ * List of loaded tabs, tabs will be loaded when navigated to.
82
+ */
83
+ const [loaded, setLoaded] = React.useState([selectedTabKey]);
84
+
85
+ if (!loaded.includes(selectedTabKey)) {
86
+ // Set the current tab to be loaded if it was not loaded before
87
+ setLoaded((loadedState) => [...loadedState, selectedTabKey]);
88
+ }
89
+
90
+ return (
91
+ <BottomNavigationContainer {...nativeProps}>
92
+ <ContentWrapper>
93
+ {tabs.map((tab) => {
94
+ const { key, component, testID } = tab;
95
+ const active = selectedTabKey === key;
96
+
97
+ if (renderActiveTabOnly && !active) {
98
+ return null;
99
+ }
100
+
101
+ if (!loaded.includes(key)) {
102
+ // Don't render a screen if we've never navigated to it
103
+ return null;
104
+ }
105
+
106
+ return (
107
+ <BottomNavigationTab
108
+ key={key}
109
+ testID={testID ? `route-screen-${testID}` : undefined}
110
+ pointerEvents={active ? 'auto' : 'none'}
111
+ accessibilityElementsHidden={!active}
112
+ importantForAccessibility={
113
+ active ? 'auto' : 'no-hide-descendants'
114
+ }
115
+ collapsable={false}
116
+ removeClippedSubviews={
117
+ // On iOS, set removeClippedSubviews to true only when not focused
118
+ // This is an workaround for a bug where the clipped view never re-appears.
119
+ isIOS ? selectedTabKey !== key : true
120
+ }
121
+ themeVisibility={active}
122
+ >
123
+ {component}
124
+ </BottomNavigationTab>
125
+ );
126
+ })}
127
+ </ContentWrapper>
128
+ <BottomBarWrapper themeInsets={insets}>
129
+ <BottomBar>
130
+ {tabs.map((tab) => {
131
+ const { key, icon, title, testID } = tab;
132
+ const active = selectedTabKey === key;
133
+ const inactiveIcon = getInactiveIcon(icon);
134
+
135
+ return (
136
+ <TouchableWithoutFeedback
137
+ key={key}
138
+ onPress={() => onTabPress(key)}
139
+ testID={testID}
140
+ >
141
+ <BottomBarItem>
142
+ <Icon
143
+ icon={active ? icon : inactiveIcon}
144
+ intent={active ? 'primary' : 'text'}
145
+ testID={`hero-icon-${icon}`}
146
+ />
147
+ {!!title && (
148
+ <StyledBottomBarText
149
+ fontWeight="semi-bold"
150
+ intent={active ? 'primary' : 'body'}
151
+ numberOfLines={1}
152
+ >
153
+ {title}
154
+ </StyledBottomBarText>
155
+ )}
156
+ </BottomBarItem>
157
+ </TouchableWithoutFeedback>
158
+ );
159
+ })}
160
+ </BottomBar>
161
+ </BottomBarWrapper>
162
+ </BottomNavigationContainer>
163
+ );
164
+ };
165
+
166
+ export default BottomNavigation;