@hero-design/rn 8.70.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 (76) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +29 -0
  3. package/es/index.js +402 -219
  4. package/lib/index.js +402 -219
  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/Chip/StyledChip.tsx +44 -8
  19. package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +212 -2
  20. package/src/components/Chip/__tests__/index.spec.tsx +2 -0
  21. package/src/components/Chip/index.tsx +1 -1
  22. package/src/components/FAB/FAB.tsx +6 -1
  23. package/src/components/FAB/Pair/StyledFAB.tsx +19 -0
  24. package/src/components/FAB/Pair/__tests__/__snapshots__/index.spec.tsx.snap +276 -0
  25. package/src/components/FAB/Pair/__tests__/index.spec.tsx +39 -0
  26. package/src/components/FAB/Pair/index.tsx +46 -0
  27. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +31 -14
  28. package/src/components/FAB/index.tsx +3 -1
  29. package/src/components/Progress/ProgressStep.tsx +3 -1
  30. package/src/components/Progress/StyledStep.tsx +13 -11
  31. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +215 -4
  32. package/src/components/Progress/__tests__/index.spec.js +16 -4
  33. package/src/components/Search/SearchOneLine.tsx +7 -1
  34. package/src/components/Search/SearchSuffixIcon.tsx +12 -1
  35. package/src/components/Search/SearchTwoLine.tsx +7 -1
  36. package/src/components/Search/StyledSearch.tsx +42 -16
  37. package/src/components/Search/__tests__/SearchOneLine.spec.tsx +30 -0
  38. package/src/components/Search/__tests__/SearchTwoLine.spec.tsx +15 -0
  39. package/src/components/Search/__tests__/__snapshots__/SearchOneLine.spec.tsx.snap +166 -10
  40. package/src/components/Search/__tests__/__snapshots__/SearchSuffixIcon.spec.tsx.snap +3 -0
  41. package/src/components/Search/__tests__/__snapshots__/SearchTwoLine.spec.tsx.snap +182 -2
  42. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +1 -1
  43. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +9 -0
  44. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +6 -0
  45. package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +3 -0
  46. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +9 -0
  47. package/src/components/Toolbar/StyledToolbar.tsx +11 -0
  48. package/src/components/Toolbar/ToolbarItem.tsx +3 -3
  49. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +24 -4
  50. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +50 -9
  51. package/src/theme/components/badge.ts +10 -1
  52. package/src/theme/components/button.ts +2 -2
  53. package/src/theme/components/chip.ts +4 -0
  54. package/src/theme/components/fab.ts +3 -0
  55. package/src/theme/components/search.ts +30 -5
  56. package/src/theme/components/switch.ts +2 -2
  57. package/src/theme/components/toolbar.ts +1 -1
  58. package/stats/8.71.0/rn-stats.html +4842 -0
  59. package/stats/8.72.0/rn-stats.html +4844 -0
  60. package/types/components/Badge/StyledBadge.d.ts +9 -1
  61. package/types/components/Badge/index.d.ts +3 -34
  62. package/types/components/Badge/types.d.ts +53 -0
  63. package/types/components/Chip/StyledChip.d.ts +1 -1
  64. package/types/components/Chip/index.d.ts +1 -1
  65. package/types/components/FAB/Pair/StyledFAB.d.ts +12 -0
  66. package/types/components/FAB/Pair/index.d.ts +16 -0
  67. package/types/components/FAB/index.d.ts +1 -0
  68. package/types/components/Progress/StyledStep.d.ts +2 -0
  69. package/types/components/Search/SearchOneLine.d.ts +5 -0
  70. package/types/components/Search/SearchTwoLine.d.ts +5 -0
  71. package/types/components/Search/StyledSearch.d.ts +7 -2
  72. package/types/components/Toolbar/StyledToolbar.d.ts +9 -2
  73. package/types/theme/components/badge.d.ts +8 -0
  74. package/types/theme/components/chip.d.ts +4 -0
  75. package/types/theme/components/fab.d.ts +3 -0
  76. package/types/theme/components/search.d.ts +31 -5
@@ -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
  });
@@ -67,7 +67,9 @@ const ProgressStep = ({
67
67
  if (steps === 1) {
68
68
  return (
69
69
  <StyledSingleStepContainer {...props}>
70
- <StyledSingleStep />
70
+ <StyledSingleStep
71
+ themeState={current >= steps ? 'complete' : 'incomplete'}
72
+ />
71
73
  </StyledSingleStepContainer>
72
74
  );
73
75
  }
@@ -28,17 +28,19 @@ const StyledSingleStepContainer = styled(Box)(({ theme }) => ({
28
28
  position: 'relative',
29
29
  }));
30
30
 
31
- const StyledSingleStep = styled(Box)(({ theme }) => ({
32
- height: theme.__hd__.progress.sizes.stepHeight,
33
- borderRadius: theme.__hd__.progress.radii.default,
34
- backgroundColor: theme.__hd__.progress.colors.step.complete,
35
- width: '70%',
36
- position: 'absolute',
37
- top: 0,
38
- left: 0,
39
- bottom: 0,
40
- right: 0,
41
- }));
31
+ const StyledSingleStep = styled(Box)<{ themeState: 'complete' | 'incomplete' }>(
32
+ ({ theme, themeState }) => ({
33
+ height: theme.__hd__.progress.sizes.stepHeight,
34
+ borderRadius: theme.__hd__.progress.radii.default,
35
+ backgroundColor: theme.__hd__.progress.colors.step.complete,
36
+ width: themeState === 'complete' ? '100%' : '70%',
37
+ position: 'absolute',
38
+ top: 0,
39
+ left: 0,
40
+ bottom: 0,
41
+ right: 0,
42
+ })
43
+ );
42
44
 
43
45
  export {
44
46
  StyledStepContainer,