@hero-design/rn 8.71.0 → 8.72.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 (67) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +23 -0
  3. package/es/index.js +353 -208
  4. package/lib/index.js +353 -208
  5. package/package.json +1 -1
  6. package/src/components/Accordion/AccordionItem.tsx +1 -1
  7. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +8 -8
  8. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
  9. package/src/components/Badge/StyledBadge.tsx +17 -2
  10. package/src/components/Badge/__tests__/Badge.spec.tsx +15 -0
  11. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +187 -0
  12. package/src/components/Badge/index.tsx +20 -36
  13. package/src/components/Badge/types.ts +55 -0
  14. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +3 -3
  15. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
  16. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +7 -7
  17. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +6 -6
  18. package/src/components/FAB/FAB.tsx +6 -1
  19. package/src/components/FAB/Pair/StyledFAB.tsx +19 -0
  20. package/src/components/FAB/Pair/__tests__/__snapshots__/index.spec.tsx.snap +276 -0
  21. package/src/components/FAB/Pair/__tests__/index.spec.tsx +39 -0
  22. package/src/components/FAB/Pair/index.tsx +46 -0
  23. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +31 -14
  24. package/src/components/FAB/index.tsx +3 -1
  25. package/src/components/Progress/ProgressStep.tsx +3 -1
  26. package/src/components/Progress/StyledStep.tsx +13 -11
  27. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +215 -4
  28. package/src/components/Progress/__tests__/index.spec.js +16 -4
  29. package/src/components/Search/SearchOneLine.tsx +7 -1
  30. package/src/components/Search/SearchSuffixIcon.tsx +12 -1
  31. package/src/components/Search/SearchTwoLine.tsx +7 -1
  32. package/src/components/Search/StyledSearch.tsx +42 -16
  33. package/src/components/Search/__tests__/SearchOneLine.spec.tsx +30 -0
  34. package/src/components/Search/__tests__/SearchTwoLine.spec.tsx +15 -0
  35. package/src/components/Search/__tests__/__snapshots__/SearchOneLine.spec.tsx.snap +166 -10
  36. package/src/components/Search/__tests__/__snapshots__/SearchSuffixIcon.spec.tsx.snap +3 -0
  37. package/src/components/Search/__tests__/__snapshots__/SearchTwoLine.spec.tsx.snap +182 -2
  38. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +1 -1
  39. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +9 -0
  40. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +6 -0
  41. package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +3 -0
  42. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +9 -0
  43. package/src/components/Toolbar/StyledToolbar.tsx +11 -0
  44. package/src/components/Toolbar/ToolbarItem.tsx +3 -3
  45. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +24 -4
  46. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +46 -9
  47. package/src/theme/components/badge.ts +10 -1
  48. package/src/theme/components/button.ts +2 -2
  49. package/src/theme/components/fab.ts +3 -0
  50. package/src/theme/components/search.ts +30 -5
  51. package/src/theme/components/switch.ts +2 -2
  52. package/src/theme/components/toolbar.ts +1 -1
  53. package/stats/8.72.0/rn-stats.html +4844 -0
  54. package/types/components/Badge/StyledBadge.d.ts +9 -1
  55. package/types/components/Badge/index.d.ts +3 -34
  56. package/types/components/Badge/types.d.ts +53 -0
  57. package/types/components/FAB/Pair/StyledFAB.d.ts +12 -0
  58. package/types/components/FAB/Pair/index.d.ts +16 -0
  59. package/types/components/FAB/index.d.ts +1 -0
  60. package/types/components/Progress/StyledStep.d.ts +2 -0
  61. package/types/components/Search/SearchOneLine.d.ts +5 -0
  62. package/types/components/Search/SearchTwoLine.d.ts +5 -0
  63. package/types/components/Search/StyledSearch.d.ts +7 -2
  64. package/types/components/Toolbar/StyledToolbar.d.ts +9 -2
  65. package/types/theme/components/badge.d.ts +8 -0
  66. package/types/theme/components/fab.d.ts +3 -0
  67. package/types/theme/components/search.d.ts +31 -5
@@ -288,7 +288,7 @@ exports[`StyledLoadingIndicator has outlined-secondary style 1`] = `
288
288
  style={
289
289
  [
290
290
  {
291
- "backgroundColor": "#795e90",
291
+ "backgroundColor": "#4d6265",
292
292
  "borderRadius": 8,
293
293
  "height": 12,
294
294
  "marginHorizontal": 8,
@@ -380,7 +380,7 @@ exports[`StyledLoadingIndicator has text-primary style 1`] = `
380
380
  style={
381
381
  [
382
382
  {
383
- "backgroundColor": "#795e90",
383
+ "backgroundColor": "#4d6265",
384
384
  "borderRadius": 8,
385
385
  "height": 12,
386
386
  "marginHorizontal": 8,
@@ -426,7 +426,7 @@ exports[`StyledLoadingIndicator has text-secondary style 1`] = `
426
426
  style={
427
427
  [
428
428
  {
429
- "backgroundColor": "#795e90",
429
+ "backgroundColor": "#4d6265",
430
430
  "borderRadius": 8,
431
431
  "height": 12,
432
432
  "marginHorizontal": 8,
@@ -849,7 +849,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-second
849
849
  style={
850
850
  [
851
851
  {
852
- "backgroundColor": "#795e90",
852
+ "backgroundColor": "#4d6265",
853
853
  "borderRadius": 8,
854
854
  "height": 12,
855
855
  "marginHorizontal": 8,
@@ -879,7 +879,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-second
879
879
  style={
880
880
  [
881
881
  {
882
- "backgroundColor": "#795e90",
882
+ "backgroundColor": "#4d6265",
883
883
  "borderRadius": 8,
884
884
  "height": 12,
885
885
  "marginHorizontal": 8,
@@ -909,7 +909,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-second
909
909
  style={
910
910
  [
911
911
  {
912
- "backgroundColor": "#795e90",
912
+ "backgroundColor": "#4d6265",
913
913
  "borderRadius": 8,
914
914
  "height": 12,
915
915
  "marginHorizontal": 8,
@@ -1119,7 +1119,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
1119
1119
  style={
1120
1120
  [
1121
1121
  {
1122
- "backgroundColor": "#795e90",
1122
+ "backgroundColor": "#4d6265",
1123
1123
  "borderRadius": 8,
1124
1124
  "height": 12,
1125
1125
  "marginHorizontal": 8,
@@ -1149,7 +1149,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
1149
1149
  style={
1150
1150
  [
1151
1151
  {
1152
- "backgroundColor": "#795e90",
1152
+ "backgroundColor": "#4d6265",
1153
1153
  "borderRadius": 8,
1154
1154
  "height": 12,
1155
1155
  "marginHorizontal": 8,
@@ -1179,7 +1179,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-primary 1`
1179
1179
  style={
1180
1180
  [
1181
1181
  {
1182
- "backgroundColor": "#795e90",
1182
+ "backgroundColor": "#4d6265",
1183
1183
  "borderRadius": 8,
1184
1184
  "height": 12,
1185
1185
  "marginHorizontal": 8,
@@ -1254,7 +1254,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-secondary
1254
1254
  style={
1255
1255
  [
1256
1256
  {
1257
- "backgroundColor": "#795e90",
1257
+ "backgroundColor": "#4d6265",
1258
1258
  "borderRadius": 8,
1259
1259
  "height": 12,
1260
1260
  "marginHorizontal": 8,
@@ -1284,7 +1284,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-secondary
1284
1284
  style={
1285
1285
  [
1286
1286
  {
1287
- "backgroundColor": "#795e90",
1287
+ "backgroundColor": "#4d6265",
1288
1288
  "borderRadius": 8,
1289
1289
  "height": 12,
1290
1290
  "marginHorizontal": 8,
@@ -1314,7 +1314,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-secondary
1314
1314
  style={
1315
1315
  [
1316
1316
  {
1317
- "backgroundColor": "#795e90",
1317
+ "backgroundColor": "#4d6265",
1318
1318
  "borderRadius": 8,
1319
1319
  "height": 12,
1320
1320
  "marginHorizontal": 8,
@@ -1104,7 +1104,7 @@ exports[`Button renders correctly 8`] = `
1104
1104
  style={
1105
1105
  [
1106
1106
  {
1107
- "backgroundColor": "#795e90",
1107
+ "backgroundColor": "#4d6265",
1108
1108
  "borderRadius": 8,
1109
1109
  "height": 12,
1110
1110
  "marginHorizontal": 8,
@@ -1134,7 +1134,7 @@ exports[`Button renders correctly 8`] = `
1134
1134
  style={
1135
1135
  [
1136
1136
  {
1137
- "backgroundColor": "#795e90",
1137
+ "backgroundColor": "#4d6265",
1138
1138
  "borderRadius": 8,
1139
1139
  "height": 12,
1140
1140
  "marginHorizontal": 8,
@@ -1164,7 +1164,7 @@ exports[`Button renders correctly 8`] = `
1164
1164
  style={
1165
1165
  [
1166
1166
  {
1167
- "backgroundColor": "#795e90",
1167
+ "backgroundColor": "#4d6265",
1168
1168
  "borderRadius": 8,
1169
1169
  "height": 12,
1170
1170
  "marginHorizontal": 8,
@@ -1367,7 +1367,7 @@ exports[`Button renders correctly 10`] = `
1367
1367
  },
1368
1368
  [
1369
1369
  {
1370
- "color": "#795e90",
1370
+ "color": "#4d6265",
1371
1371
  "flexShrink": 1,
1372
1372
  "lineHeight": 22,
1373
1373
  "textAlign": "center",
@@ -1486,7 +1486,7 @@ exports[`Button renders correctly 11`] = `
1486
1486
  style={
1487
1487
  [
1488
1488
  {
1489
- "backgroundColor": "#795e90",
1489
+ "backgroundColor": "#4d6265",
1490
1490
  "borderRadius": 8,
1491
1491
  "height": 12,
1492
1492
  "marginHorizontal": 8,
@@ -1516,7 +1516,7 @@ exports[`Button renders correctly 11`] = `
1516
1516
  style={
1517
1517
  [
1518
1518
  {
1519
- "backgroundColor": "#795e90",
1519
+ "backgroundColor": "#4d6265",
1520
1520
  "borderRadius": 8,
1521
1521
  "height": 12,
1522
1522
  "marginHorizontal": 8,
@@ -1546,7 +1546,7 @@ exports[`Button renders correctly 11`] = `
1546
1546
  style={
1547
1547
  [
1548
1548
  {
1549
- "backgroundColor": "#795e90",
1549
+ "backgroundColor": "#4d6265",
1550
1550
  "borderRadius": 8,
1551
1551
  "height": 12,
1552
1552
  "marginHorizontal": 8,
@@ -169,7 +169,7 @@ exports[`StyledButtonContainer has filled-secondary style 1`] = `
169
169
  {
170
170
  "alignItems": "center",
171
171
  "alignSelf": "stretch",
172
- "backgroundColor": "#795e90",
172
+ "backgroundColor": "#4d6265",
173
173
  "borderRadius": 32,
174
174
  "flexDirection": "row",
175
175
  "height": 60,
@@ -381,7 +381,7 @@ exports[`StyledButtonContainer has outlined-secondary style 1`] = `
381
381
  "alignItems": "center",
382
382
  "alignSelf": "stretch",
383
383
  "backgroundColor": "transparent",
384
- "borderColor": "#795e90",
384
+ "borderColor": "#4d6265",
385
385
  "borderRadius": 32,
386
386
  "borderWidth": 2,
387
387
  "flexDirection": "row",
@@ -974,7 +974,7 @@ exports[`StyledButtonIcon has outlined-secondary style 1`] = `
974
974
  },
975
975
  [
976
976
  {
977
- "color": "#795e90",
977
+ "color": "#4d6265",
978
978
  "fontSize": 20,
979
979
  },
980
980
  undefined,
@@ -1127,7 +1127,7 @@ exports[`StyledButtonIcon has text-secondary style 1`] = `
1127
1127
  },
1128
1128
  [
1129
1129
  {
1130
- "color": "#795e90",
1130
+ "color": "#4d6265",
1131
1131
  "fontSize": 20,
1132
1132
  },
1133
1133
  undefined,
@@ -1611,7 +1611,7 @@ exports[`StyledButtonText has outlined-secondary style 1`] = `
1611
1611
  },
1612
1612
  [
1613
1613
  {
1614
- "color": "#795e90",
1614
+ "color": "#4d6265",
1615
1615
  "flexShrink": 1,
1616
1616
  "textAlign": "center",
1617
1617
  },
@@ -1788,7 +1788,7 @@ exports[`StyledButtonText has text-secondary style 1`] = `
1788
1788
  },
1789
1789
  [
1790
1790
  {
1791
- "color": "#795e90",
1791
+ "color": "#4d6265",
1792
1792
  "flexShrink": 1,
1793
1793
  "textAlign": "center",
1794
1794
  },
@@ -83,11 +83,16 @@ const IconOnlyContent = ({
83
83
  active={active}
84
84
  icon={icon}
85
85
  testID="animated-fab-icon"
86
+ size="xsmall"
86
87
  />
87
88
  </StyledIconContainer>
88
89
  );
89
90
  }
90
- return <StyledFABIcon icon={icon} testID="styled-fab-icon" />;
91
+ return (
92
+ <StyledIconContainer>
93
+ <StyledFABIcon size="xsmall" icon={icon} testID="styled-fab-icon" />
94
+ </StyledIconContainer>
95
+ );
91
96
  };
92
97
 
93
98
  const IconWithTextContent = ({
@@ -0,0 +1,19 @@
1
+ import styled from '@emotion/native';
2
+ import FAB from '../FAB';
3
+ import Box from '../../Box';
4
+
5
+ const StyledFABPairWrapper = styled(Box)({
6
+ flexDirection: 'row',
7
+ justifyContent: 'center',
8
+ alignItems: 'center',
9
+ });
10
+
11
+ const StyledFAB = styled(FAB)<{ iconOnly?: boolean; isLast?: boolean }>(
12
+ ({ theme, iconOnly = false, isLast = false }) => ({
13
+ height: theme.__hd__.fab.sizes.fabPairHeight,
14
+ width: iconOnly ? theme.__hd__.fab.sizes.fabPairIconOnlyWidth : undefined,
15
+ marginRight: isLast ? undefined : theme.__hd__.fab.space.fabPairMarginRight,
16
+ })
17
+ );
18
+
19
+ export { StyledFABPairWrapper, StyledFAB };
@@ -0,0 +1,276 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`FABPair renders correctly 1`] = `
4
+ <View
5
+ style={
6
+ {
7
+ "flex": 1,
8
+ }
9
+ }
10
+ >
11
+ <View
12
+ style={
13
+ [
14
+ {},
15
+ [
16
+ {
17
+ "alignItems": "center",
18
+ "flexDirection": "row",
19
+ "justifyContent": "center",
20
+ },
21
+ undefined,
22
+ ],
23
+ ]
24
+ }
25
+ >
26
+ <View
27
+ accessibilityValue={
28
+ {
29
+ "max": undefined,
30
+ "min": undefined,
31
+ "now": undefined,
32
+ "text": undefined,
33
+ }
34
+ }
35
+ accessible={true}
36
+ focusable={true}
37
+ onClick={[Function]}
38
+ onLayout={[Function]}
39
+ onResponderGrant={[Function]}
40
+ onResponderMove={[Function]}
41
+ onResponderRelease={[Function]}
42
+ onResponderTerminate={[Function]}
43
+ onResponderTerminationRequest={[Function]}
44
+ onStartShouldSetResponder={[Function]}
45
+ style={
46
+ {
47
+ "alignItems": "center",
48
+ "alignSelf": "flex-start",
49
+ "backgroundColor": "#401960",
50
+ "borderRadius": 999,
51
+ "bottom": undefined,
52
+ "elevation": 3,
53
+ "flexDirection": "row",
54
+ "height": 48,
55
+ "justifyContent": "center",
56
+ "marginRight": 8,
57
+ "padding": 20,
58
+ "shadowColor": "#001f23",
59
+ "shadowOffset": {
60
+ "height": 2,
61
+ "width": 0,
62
+ },
63
+ "shadowOpacity": 0.12,
64
+ "shadowRadius": 4,
65
+ "transform": [
66
+ {
67
+ "translateY": 0,
68
+ },
69
+ ],
70
+ "width": 48,
71
+ }
72
+ }
73
+ testID="fab-pair-cancel"
74
+ >
75
+ <View
76
+ collapsable={false}
77
+ style={
78
+ {
79
+ "flexDirection": "row",
80
+ "opacity": 1,
81
+ }
82
+ }
83
+ >
84
+ <View
85
+ style={
86
+ [
87
+ {},
88
+ [
89
+ {
90
+ "alignItems": "center",
91
+ "height": 24,
92
+ "justifyContent": "center",
93
+ "width": 24,
94
+ },
95
+ undefined,
96
+ ],
97
+ ]
98
+ }
99
+ >
100
+ <HeroIcon
101
+ name="cancel"
102
+ style={
103
+ [
104
+ {
105
+ "color": "#001f23",
106
+ "fontSize": 16,
107
+ },
108
+ [
109
+ {
110
+ "color": "#ffffff",
111
+ "lineHeight": 24,
112
+ "textAlign": "center",
113
+ "textAlignVertical": "center",
114
+ },
115
+ undefined,
116
+ ],
117
+ ]
118
+ }
119
+ testID="styled-fab-icon"
120
+ themeIntent="text"
121
+ themeSize="xsmall"
122
+ />
123
+ </View>
124
+ </View>
125
+ </View>
126
+ <View
127
+ accessibilityValue={
128
+ {
129
+ "max": undefined,
130
+ "min": undefined,
131
+ "now": undefined,
132
+ "text": undefined,
133
+ }
134
+ }
135
+ accessible={true}
136
+ focusable={true}
137
+ onClick={[Function]}
138
+ onLayout={[Function]}
139
+ onResponderGrant={[Function]}
140
+ onResponderMove={[Function]}
141
+ onResponderRelease={[Function]}
142
+ onResponderTerminate={[Function]}
143
+ onResponderTerminationRequest={[Function]}
144
+ onStartShouldSetResponder={[Function]}
145
+ style={
146
+ {
147
+ "alignItems": "center",
148
+ "alignSelf": "flex-start",
149
+ "backgroundColor": "#401960",
150
+ "borderRadius": 999,
151
+ "bottom": undefined,
152
+ "elevation": 3,
153
+ "flexDirection": "row",
154
+ "height": 48,
155
+ "justifyContent": "center",
156
+ "marginRight": undefined,
157
+ "padding": 20,
158
+ "shadowColor": "#001f23",
159
+ "shadowOffset": {
160
+ "height": 2,
161
+ "width": 0,
162
+ },
163
+ "shadowOpacity": 0.12,
164
+ "shadowRadius": 4,
165
+ "transform": [
166
+ {
167
+ "translateY": 0,
168
+ },
169
+ ],
170
+ "width": undefined,
171
+ }
172
+ }
173
+ testID="confirm"
174
+ >
175
+ <View
176
+ collapsable={false}
177
+ style={
178
+ {
179
+ "flexDirection": "row",
180
+ "opacity": 1,
181
+ }
182
+ }
183
+ >
184
+ <View
185
+ style={
186
+ [
187
+ {},
188
+ [
189
+ {
190
+ "alignItems": "center",
191
+ "height": 24,
192
+ "justifyContent": "center",
193
+ "width": 24,
194
+ },
195
+ undefined,
196
+ ],
197
+ ]
198
+ }
199
+ >
200
+ <HeroIcon
201
+ name="checkmark"
202
+ style={
203
+ [
204
+ {
205
+ "color": "#001f23",
206
+ "fontSize": 16,
207
+ },
208
+ [
209
+ {
210
+ "color": "#ffffff",
211
+ "lineHeight": 24,
212
+ "textAlign": "center",
213
+ "textAlignVertical": "center",
214
+ },
215
+ undefined,
216
+ ],
217
+ ]
218
+ }
219
+ testID="styled-fab-icon"
220
+ themeIntent="text"
221
+ themeSize="xsmall"
222
+ />
223
+ </View>
224
+ <Text
225
+ allowFontScaling={false}
226
+ style={
227
+ [
228
+ {
229
+ "color": "#001f23",
230
+ "fontFamily": "BeVietnamPro-Regular",
231
+ "fontSize": 16,
232
+ "letterSpacing": 0.48,
233
+ "lineHeight": 24,
234
+ },
235
+ [
236
+ {
237
+ "color": "#ffffff",
238
+ "marginHorizontal": 8,
239
+ "textAlign": "center",
240
+ "textAlignVertical": "center",
241
+ },
242
+ undefined,
243
+ ],
244
+ ]
245
+ }
246
+ themeIntent="body"
247
+ themeTypeface="neutral"
248
+ themeVariant="regular"
249
+ >
250
+ Confirm
251
+ </Text>
252
+ </View>
253
+ </View>
254
+ </View>
255
+ <View
256
+ pointerEvents="box-none"
257
+ position="bottom"
258
+ style={
259
+ [
260
+ {
261
+ "bottom": 0,
262
+ "elevation": 9999,
263
+ "flexDirection": "column-reverse",
264
+ "left": 0,
265
+ "paddingHorizontal": 24,
266
+ "paddingVertical": 16,
267
+ "position": "absolute",
268
+ "right": 0,
269
+ "top": 0,
270
+ },
271
+ undefined,
272
+ ]
273
+ }
274
+ />
275
+ </View>
276
+ `;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { fireEvent } from '@testing-library/react-native';
3
+ import Pair, { InnerFABProps } from '..';
4
+ import renderWithTheme from '../../../../testHelpers/renderWithTheme';
5
+
6
+ describe('FABPair', () => {
7
+ const onConfirmPress = jest.fn();
8
+
9
+ const defaultFabConfig: InnerFABProps = {
10
+ icon: 'checkmark',
11
+ title: 'Confirm',
12
+ onPress: onConfirmPress,
13
+ testID: 'confirm',
14
+ };
15
+
16
+ it('renders correctly', () => {
17
+ const { toJSON, getByText, getByTestId } = renderWithTheme(
18
+ <Pair onCancel={jest.fn()} fabConfig={defaultFabConfig} />
19
+ );
20
+
21
+ expect(toJSON()).toMatchSnapshot();
22
+ expect(getByText('Confirm')).toBeDefined();
23
+ expect(getByTestId('fab-pair-cancel')).toBeDefined();
24
+ expect(getByTestId('confirm')).toBeDefined();
25
+ });
26
+
27
+ it('call onPress correctly', () => {
28
+ const onCancelPress = jest.fn();
29
+
30
+ const { getByTestId } = renderWithTheme(
31
+ <Pair onCancel={onCancelPress} fabConfig={defaultFabConfig} />
32
+ );
33
+
34
+ fireEvent.press(getByTestId('fab-pair-cancel'));
35
+ expect(onCancelPress).toBeCalledTimes(1);
36
+ fireEvent.press(getByTestId('confirm'));
37
+ expect(onConfirmPress).toBeCalledTimes(1);
38
+ });
39
+ });
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { ViewProps } from 'react-native';
3
+ import { FABProps } from '../FAB';
4
+ import { StyledFAB, StyledFABPairWrapper } from './StyledFAB';
5
+
6
+ export type InnerFABProps = Pick<
7
+ FABProps,
8
+ 'icon' | 'title' | 'onPress' | 'testID'
9
+ >;
10
+
11
+ export interface FABPairProps extends ViewProps {
12
+ /**
13
+ * Configuration for the main FAB.
14
+ */
15
+ fabConfig: InnerFABProps;
16
+ /**
17
+ * Callback to be called when the cancel FAB is pressed.
18
+ */
19
+ onCancel: () => void;
20
+ }
21
+
22
+ const Pair = ({ fabConfig, onCancel, ...props }: FABPairProps) => {
23
+ const { icon, title, onPress, testID } = fabConfig;
24
+
25
+ return (
26
+ <StyledFABPairWrapper {...props}>
27
+ <StyledFAB
28
+ icon="cancel"
29
+ onPress={onCancel}
30
+ testID="fab-pair-cancel"
31
+ iconOnly
32
+ />
33
+
34
+ <StyledFAB
35
+ icon={icon}
36
+ title={title}
37
+ onPress={onPress}
38
+ testID={testID}
39
+ iconOnly={!title}
40
+ isLast
41
+ />
42
+ </StyledFABPairWrapper>
43
+ );
44
+ };
45
+
46
+ export default Pair;
@@ -63,29 +63,46 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
63
63
  }
64
64
  }
65
65
  >
66
- <HeroIcon
67
- name="add"
66
+ <View
68
67
  style={
69
68
  [
70
- {
71
- "color": "#001f23",
72
- "fontSize": 24,
73
- },
69
+ {},
74
70
  [
75
71
  {
76
- "color": "#ffffff",
77
- "lineHeight": 24,
78
- "textAlign": "center",
79
- "textAlignVertical": "center",
72
+ "alignItems": "center",
73
+ "height": 24,
74
+ "justifyContent": "center",
75
+ "width": 24,
80
76
  },
81
77
  undefined,
82
78
  ],
83
79
  ]
84
80
  }
85
- testID="styled-fab-icon"
86
- themeIntent="text"
87
- themeSize="medium"
88
- />
81
+ >
82
+ <HeroIcon
83
+ name="add"
84
+ style={
85
+ [
86
+ {
87
+ "color": "#001f23",
88
+ "fontSize": 16,
89
+ },
90
+ [
91
+ {
92
+ "color": "#ffffff",
93
+ "lineHeight": 24,
94
+ "textAlign": "center",
95
+ "textAlignVertical": "center",
96
+ },
97
+ undefined,
98
+ ],
99
+ ]
100
+ }
101
+ testID="styled-fab-icon"
102
+ themeIntent="text"
103
+ themeSize="xsmall"
104
+ />
105
+ </View>
89
106
  </View>
90
107
  </View>
91
108
  <View
@@ -1,6 +1,8 @@
1
- import FAB from './FAB';
2
1
  import ActionGroup from './ActionGroup';
2
+ import FAB from './FAB';
3
+ import Pair from './Pair';
3
4
 
4
5
  export default Object.assign(FAB, {
5
6
  ActionGroup,
7
+ Pair,
6
8
  });