@hero-design/rn 8.2.1 → 8.2.3

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 (47) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +165 -52
  3. package/lib/index.js +163 -50
  4. package/package.json +5 -5
  5. package/src/components/BottomSheet/BottomSheetContext.ts +11 -0
  6. package/src/components/BottomSheet/ScrollView.tsx +57 -0
  7. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +9 -24
  8. package/src/components/BottomSheet/__tests__/index.spec.tsx +17 -0
  9. package/src/components/BottomSheet/index.tsx +21 -8
  10. package/src/components/Box/StyledBox.tsx +8 -6
  11. package/src/components/Card/StyledCard.tsx +1 -1
  12. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +74 -0
  13. package/src/components/Card/__tests__/index.spec.tsx +2 -0
  14. package/src/components/Card/index.tsx +1 -1
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +0 -24
  16. package/src/components/Icon/index.tsx +28 -2
  17. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +0 -72
  18. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +0 -36
  19. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +160 -0
  20. package/src/components/TextInput/__tests__/index.spec.tsx +50 -3
  21. package/src/components/TextInput/index.tsx +65 -30
  22. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +0 -24
  23. package/src/components/Toolbar/ToolbarGroup.tsx +20 -14
  24. package/src/components/Toolbar/ToolbarItem.tsx +9 -1
  25. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +12 -0
  26. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +6 -0
  27. package/src/types.ts +4 -1
  28. package/src/utils/__tests__/helpers.spec.ts +22 -4
  29. package/src/utils/helpers.ts +10 -9
  30. package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +1 -1
  31. package/types/components/BottomSheet/BottomSheetContext.d.ts +5 -0
  32. package/types/components/BottomSheet/ScrollView.d.ts +3 -0
  33. package/types/components/BottomSheet/index.d.ts +5 -3
  34. package/types/components/Box/StyledBox.d.ts +2 -2
  35. package/types/components/Button/StyledButton.d.ts +1 -1
  36. package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +1 -1
  37. package/types/components/Card/StyledCard.d.ts +1 -1
  38. package/types/components/Card/index.d.ts +1 -1
  39. package/types/components/Checkbox/StyledCheckbox.d.ts +1 -1
  40. package/types/components/ContentNavigator/StyledContentNavigator.d.ts +1 -1
  41. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +1 -1
  42. package/types/components/Icon/index.d.ts +3 -3
  43. package/types/components/TextInput/StyledTextInput.d.ts +7 -7
  44. package/types/components/TextInput/index.d.ts +25 -3
  45. package/types/components/Toolbar/ToolbarItem.d.ts +6 -1
  46. package/types/types.d.ts +3 -2
  47. package/types/utils/helpers.d.ts +2 -2
@@ -1,5 +1,14 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`BottomSheet renders correctly with BottomSheet.ScrollView 1`] = `
4
+ <Modal
5
+ hardwareAccelerated={false}
6
+ onRequestClose={[MockFunction]}
7
+ transparent={true}
8
+ visible={false}
9
+ />
10
+ `;
11
+
3
12
  exports[`BottomSheet renders correctly with close state 1`] = `
4
13
  <Modal
5
14
  hardwareAccelerated={false}
@@ -196,34 +205,10 @@ exports[`BottomSheet renders correctly with open state 1`] = `
196
205
  </View>
197
206
  </View>
198
207
  </View>
199
- <View
200
- style={
201
- Array [
202
- Object {
203
- "borderBottomColor": "#e8e9ea",
204
- "borderBottomWidth": 1,
205
- "maxWidth": "100%",
206
- },
207
- undefined,
208
- ]
209
- }
210
- />
211
208
  <Text>
212
209
  Content
213
210
  </Text>
214
211
  <View>
215
- <View
216
- style={
217
- Array [
218
- Object {
219
- "borderBottomColor": "#e8e9ea",
220
- "borderBottomWidth": 1,
221
- "maxWidth": "100%",
222
- },
223
- undefined,
224
- ]
225
- }
226
- />
227
212
  <View
228
213
  style={
229
214
  Array [
@@ -40,6 +40,23 @@ describe('BottomSheet', () => {
40
40
  expect(toJSON()).toMatchSnapshot();
41
41
  });
42
42
 
43
+ it('renders correctly with BottomSheet.ScrollView', () => {
44
+ const { toJSON } = renderWithTheme(
45
+ <BottomSheet
46
+ open={false}
47
+ header="Title"
48
+ footer={<Button title="Footer CTA" />}
49
+ onRequestClose={jest.fn()}
50
+ >
51
+ <BottomSheet.ScrollView>
52
+ <Content />
53
+ </BottomSheet.ScrollView>
54
+ </BottomSheet>
55
+ );
56
+
57
+ expect(toJSON()).toMatchSnapshot();
58
+ });
59
+
43
60
  describe('Header', () => {
44
61
  it('renders default header correctly', () => {
45
62
  const { getByText } = renderWithTheme(
@@ -1,4 +1,6 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
3
+ import type { StyleProp, ViewStyle } from 'react-native';
2
4
  import {
3
5
  Animated,
4
6
  Dimensions,
@@ -7,8 +9,7 @@ import {
7
9
  Modal,
8
10
  Platform,
9
11
  } from 'react-native';
10
- import type { ReactElement, ReactNode } from 'react';
11
- import type { StyleProp, ViewStyle } from 'react-native';
12
+ import BottomSheetContext from './BottomSheetContext';
12
13
  import Footer from './Footer';
13
14
  import Header from './Header';
14
15
  import {
@@ -17,6 +18,7 @@ import {
17
18
  StyledKeyboardAvoidingView,
18
19
  StyledWrapper,
19
20
  } from './StyledBottomSheet';
21
+ import ScrollView from './ScrollView';
20
22
 
21
23
  interface BottomSheetProps {
22
24
  /**
@@ -72,7 +74,6 @@ interface BottomSheetProps {
72
74
  * Testing id of the component.
73
75
  */
74
76
  testID?: string;
75
-
76
77
  /**
77
78
  * keyboardAvoidingView's props
78
79
  * */
@@ -90,7 +91,7 @@ const BottomSheet = ({
90
91
  onDismiss,
91
92
  showCloseButton = true,
92
93
  hasBackdrop = true,
93
- showDivider = true,
94
+ showDivider = false,
94
95
  style,
95
96
  testID,
96
97
  keyboardAvoidingViewProps = {},
@@ -100,6 +101,8 @@ const BottomSheet = ({
100
101
  // Internal state to control modal open/close timing with animation
101
102
  const [visible, setVisibility] = useState<boolean>(open);
102
103
  const animatedValue = useRef(new Animated.Value(open ? 0 : 1));
104
+ const [internalShowDivider, setInternalShowDivider] =
105
+ useState<boolean>(showDivider);
103
106
 
104
107
  useEffect(() => {
105
108
  // Show the modal before the open animation start
@@ -146,6 +149,11 @@ const BottomSheet = ({
146
149
  })
147
150
  : 0;
148
151
 
152
+ const BottomSheetContextValue = useMemo(
153
+ () => ({ setInternalShowDivider }),
154
+ [setInternalShowDivider]
155
+ );
156
+
149
157
  return (
150
158
  <Modal
151
159
  visible={visible}
@@ -179,12 +187,15 @@ const BottomSheet = ({
179
187
  {header !== undefined ? (
180
188
  <Header
181
189
  content={header}
182
- showDivider={showDivider}
190
+ showDivider={internalShowDivider}
183
191
  onRequestClose={onRequestClose}
184
192
  showCloseButton={showCloseButton}
185
193
  />
186
194
  ) : null}
187
- {children}
195
+ <BottomSheetContext.Provider value={BottomSheetContextValue}>
196
+ {children}
197
+ </BottomSheetContext.Provider>
198
+
188
199
  {footer ? (
189
200
  <Footer showDivider={showDivider}>{footer}</Footer>
190
201
  ) : null}
@@ -195,4 +206,6 @@ const BottomSheet = ({
195
206
  );
196
207
  };
197
208
 
198
- export default BottomSheet;
209
+ export default Object.assign(BottomSheet, {
210
+ ScrollView,
211
+ });
@@ -1,7 +1,7 @@
1
1
  import styled from '@emotion/native';
2
2
  import { Theme } from '@emotion/react';
3
3
  import { View } from 'react-native';
4
- import { StyleProps, ThemeScale } from './types';
4
+ import { FlexStyleProps, StyleProps, ThemeScale } from './types';
5
5
  import { pick } from '../../utils/helpers';
6
6
  import config, { ConfigType, flexPropsKey } from './config';
7
7
 
@@ -44,10 +44,12 @@ const mapStylePropToThemeValue = (theme: Theme, props: StyleProps) => {
44
44
 
45
45
  const configKeys = Object.keys(config) as Array<keyof ConfigType>;
46
46
 
47
- const StyledBox = styled(View)<StyleProps>(({ theme, ...otherProps }) => {
48
- const styleProps = pick(configKeys, otherProps);
49
- const flexProps = pick([...flexPropsKey], otherProps);
50
- return { ...mapStylePropToThemeValue(theme, styleProps), ...flexProps };
51
- });
47
+ const StyledBox = styled(View)<StyleProps & FlexStyleProps>(
48
+ ({ theme, ...otherProps }) => {
49
+ const styleProps = pick(configKeys, otherProps);
50
+ const flexProps = pick([...flexPropsKey], otherProps);
51
+ return { ...mapStylePropToThemeValue(theme, styleProps), ...flexProps };
52
+ }
53
+ );
52
54
 
53
55
  export { StyledBox };
@@ -2,7 +2,7 @@ import { View } from 'react-native';
2
2
  import styled from '@emotion/native';
3
3
 
4
4
  const StyledCard = styled(View)<{
5
- themeIntent?: 'primary' | 'success' | 'warning';
5
+ themeIntent?: 'primary' | 'success' | 'warning' | 'danger' | 'archived';
6
6
  }>(({ theme, themeIntent }) => ({
7
7
  ...(themeIntent !== undefined && {
8
8
  backgroundColor: theme.__hd__.card.colors[themeIntent],
@@ -1,5 +1,79 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`Card renders correctly when intent is archived 1`] = `
4
+ <View
5
+ style={
6
+ Array [
7
+ Object {
8
+ "backgroundColor": "#abacaf",
9
+ "borderRadius": 12,
10
+ "overflow": "hidden",
11
+ },
12
+ undefined,
13
+ ]
14
+ }
15
+ themeIntent="archived"
16
+ >
17
+ <Text
18
+ style={
19
+ Array [
20
+ Object {
21
+ "color": "#001f23",
22
+ "fontFamily": "BeVietnamPro-Regular",
23
+ "fontSize": 14,
24
+ "letterSpacing": 0.42,
25
+ "lineHeight": 22,
26
+ },
27
+ undefined,
28
+ ]
29
+ }
30
+ themeFontSize="medium"
31
+ themeFontWeight="regular"
32
+ themeIntent="body"
33
+ themeTypeface="neutral"
34
+ >
35
+ Card Content
36
+ </Text>
37
+ </View>
38
+ `;
39
+
40
+ exports[`Card renders correctly when intent is danger 1`] = `
41
+ <View
42
+ style={
43
+ Array [
44
+ Object {
45
+ "backgroundColor": "#f46363",
46
+ "borderRadius": 12,
47
+ "overflow": "hidden",
48
+ },
49
+ undefined,
50
+ ]
51
+ }
52
+ themeIntent="danger"
53
+ >
54
+ <Text
55
+ style={
56
+ Array [
57
+ Object {
58
+ "color": "#001f23",
59
+ "fontFamily": "BeVietnamPro-Regular",
60
+ "fontSize": 14,
61
+ "letterSpacing": 0.42,
62
+ "lineHeight": 22,
63
+ },
64
+ undefined,
65
+ ]
66
+ }
67
+ themeFontSize="medium"
68
+ themeFontWeight="regular"
69
+ themeIntent="body"
70
+ themeTypeface="neutral"
71
+ >
72
+ Card Content
73
+ </Text>
74
+ </View>
75
+ `;
76
+
3
77
  exports[`Card renders correctly when intent is info 1`] = `
4
78
  <View
5
79
  style={
@@ -23,6 +23,8 @@ describe('Card', () => {
23
23
  ${'primary'}
24
24
  ${'success'}
25
25
  ${'info'}
26
+ ${'danger'}
27
+ ${'archived'}
26
28
  `('renders correctly when intent is $intent', ({ intent }) => {
27
29
  const { toJSON, getByText } = renderWithTheme(
28
30
  <Card intent={intent}>
@@ -12,7 +12,7 @@ interface CardProps extends ViewProps {
12
12
  /**
13
13
  * Visual intent color to apply to card.
14
14
  */
15
- intent?: 'primary' | 'success' | 'warning';
15
+ intent?: 'primary' | 'success' | 'warning' | 'danger' | 'archived';
16
16
  /**
17
17
  * Additional style.
18
18
  */
@@ -428,18 +428,6 @@ exports[`DatePickerIOS renders correctly 1`] = `
428
428
  </View>
429
429
  </View>
430
430
  </View>
431
- <View
432
- style={
433
- Array [
434
- Object {
435
- "borderBottomColor": "#e8e9ea",
436
- "borderBottomWidth": 1,
437
- "maxWidth": "100%",
438
- },
439
- undefined,
440
- ]
441
- }
442
- />
443
431
  <View
444
432
  style={
445
433
  Array [
@@ -464,18 +452,6 @@ exports[`DatePickerIOS renders correctly 1`] = `
464
452
  />
465
453
  </View>
466
454
  <View>
467
- <View
468
- style={
469
- Array [
470
- Object {
471
- "borderBottomColor": "#e8e9ea",
472
- "borderBottomWidth": 1,
473
- "maxWidth": "100%",
474
- },
475
- undefined,
476
- ]
477
- }
478
- />
479
455
  <View
480
456
  style={
481
457
  Array [
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { StyleProp, TextStyle } from 'react-native';
2
+ import type { AccessibilityProps, StyleProp, TextStyle } from 'react-native';
3
3
  import IconList from './IconList';
4
4
  import HeroIcon from './HeroIcon';
5
5
  import AnimatedIcon from './AnimatedIcon';
@@ -7,7 +7,7 @@ import { useDeprecation } from '../../utils/hooks';
7
7
 
8
8
  export type IconName = typeof IconList[number];
9
9
 
10
- export interface IconProps {
10
+ export interface IconProps extends AccessibilityProps {
11
11
  /**
12
12
  * Name of the Icon.
13
13
  */
@@ -50,6 +50,17 @@ const Icon = ({
50
50
  intent = 'text',
51
51
  testID,
52
52
  spin = false,
53
+ accessibilityLabel,
54
+ accessibilityHint,
55
+ accessibilityRole,
56
+ accessibilityState,
57
+ accessibilityValue,
58
+ accessibilityLiveRegion,
59
+ accessibilityElementsHidden,
60
+ accessible,
61
+ accessibilityIgnoresInvertColors,
62
+ accessibilityViewIsModal,
63
+ accessibilityActions,
53
64
  }: IconProps) => {
54
65
  useDeprecation(
55
66
  `${icon} icon is deprecated and will be removed in the next major release, please use ${icon.replace(
@@ -58,6 +69,19 @@ const Icon = ({
58
69
  )} instead.`,
59
70
  icon.startsWith('carat')
60
71
  );
72
+ const accessibilityProps = {
73
+ accessibilityLabel,
74
+ accessibilityHint,
75
+ accessibilityRole,
76
+ accessibilityState,
77
+ accessibilityValue,
78
+ accessibilityLiveRegion,
79
+ accessibilityElementsHidden,
80
+ accessible,
81
+ accessibilityIgnoresInvertColors,
82
+ accessibilityViewIsModal,
83
+ accessibilityActions,
84
+ };
61
85
 
62
86
  return spin ? (
63
87
  <AnimatedIcon
@@ -66,6 +90,7 @@ const Icon = ({
66
90
  themeSize={size}
67
91
  style={style}
68
92
  testID={testID}
93
+ {...accessibilityProps}
69
94
  />
70
95
  ) : (
71
96
  <HeroIcon
@@ -74,6 +99,7 @@ const Icon = ({
74
99
  themeSize={size}
75
100
  style={style}
76
101
  testID={testID}
102
+ {...accessibilityProps}
77
103
  />
78
104
  );
79
105
  };
@@ -395,18 +395,6 @@ Array [
395
395
  </View>
396
396
  </View>
397
397
  </View>
398
- <View
399
- style={
400
- Array [
401
- Object {
402
- "borderBottomColor": "#e8e9ea",
403
- "borderBottomWidth": 1,
404
- "maxWidth": "100%",
405
- },
406
- undefined,
407
- ]
408
- }
409
- />
410
398
  <RCTScrollView
411
399
  ListFooterComponent={null}
412
400
  data={
@@ -1288,18 +1276,6 @@ Array [
1288
1276
  </View>
1289
1277
  </RCTScrollView>
1290
1278
  <View>
1291
- <View
1292
- style={
1293
- Array [
1294
- Object {
1295
- "borderBottomColor": "#e8e9ea",
1296
- "borderBottomWidth": 1,
1297
- "maxWidth": "100%",
1298
- },
1299
- undefined,
1300
- ]
1301
- }
1302
- />
1303
1279
  <View
1304
1280
  style={
1305
1281
  Array [
@@ -1985,18 +1961,6 @@ Array [
1985
1961
  </View>
1986
1962
  </View>
1987
1963
  </View>
1988
- <View
1989
- style={
1990
- Array [
1991
- Object {
1992
- "borderBottomColor": "#e8e9ea",
1993
- "borderBottomWidth": 1,
1994
- "maxWidth": "100%",
1995
- },
1996
- undefined,
1997
- ]
1998
- }
1999
- />
2000
1964
  <RCTScrollView
2001
1965
  ListFooterComponent={null}
2002
1966
  data={
@@ -3055,18 +3019,6 @@ Array [
3055
3019
  </View>
3056
3020
  </RCTScrollView>
3057
3021
  <View>
3058
- <View
3059
- style={
3060
- Array [
3061
- Object {
3062
- "borderBottomColor": "#e8e9ea",
3063
- "borderBottomWidth": 1,
3064
- "maxWidth": "100%",
3065
- },
3066
- undefined,
3067
- ]
3068
- }
3069
- />
3070
3022
  <View
3071
3023
  style={
3072
3024
  Array [
@@ -3765,18 +3717,6 @@ Array [
3765
3717
  </View>
3766
3718
  </View>
3767
3719
  </View>
3768
- <View
3769
- style={
3770
- Array [
3771
- Object {
3772
- "borderBottomColor": "#e8e9ea",
3773
- "borderBottomWidth": 1,
3774
- "maxWidth": "100%",
3775
- },
3776
- undefined,
3777
- ]
3778
- }
3779
- />
3780
3720
  <RCTScrollView
3781
3721
  ListFooterComponent={null}
3782
3722
  data={
@@ -4453,18 +4393,6 @@ Array [
4453
4393
  </View>
4454
4394
  </RCTScrollView>
4455
4395
  <View>
4456
- <View
4457
- style={
4458
- Array [
4459
- Object {
4460
- "borderBottomColor": "#e8e9ea",
4461
- "borderBottomWidth": 1,
4462
- "maxWidth": "100%",
4463
- },
4464
- undefined,
4465
- ]
4466
- }
4467
- />
4468
4396
  <View
4469
4397
  style={
4470
4398
  Array [
@@ -394,18 +394,6 @@ Array [
394
394
  </View>
395
395
  </View>
396
396
  </View>
397
- <View
398
- style={
399
- Array [
400
- Object {
401
- "borderBottomColor": "#e8e9ea",
402
- "borderBottomWidth": 1,
403
- "maxWidth": "100%",
404
- },
405
- undefined,
406
- ]
407
- }
408
- />
409
397
  <RCTScrollView
410
398
  ListFooterComponent={null}
411
399
  data={
@@ -1893,18 +1881,6 @@ Array [
1893
1881
  </View>
1894
1882
  </View>
1895
1883
  </View>
1896
- <View
1897
- style={
1898
- Array [
1899
- Object {
1900
- "borderBottomColor": "#e8e9ea",
1901
- "borderBottomWidth": 1,
1902
- "maxWidth": "100%",
1903
- },
1904
- undefined,
1905
- ]
1906
- }
1907
- />
1908
1884
  <RCTScrollView
1909
1885
  ListFooterComponent={null}
1910
1886
  data={
@@ -3528,18 +3504,6 @@ Array [
3528
3504
  </View>
3529
3505
  </View>
3530
3506
  </View>
3531
- <View
3532
- style={
3533
- Array [
3534
- Object {
3535
- "borderBottomColor": "#e8e9ea",
3536
- "borderBottomWidth": 1,
3537
- "maxWidth": "100%",
3538
- },
3539
- undefined,
3540
- ]
3541
- }
3542
- />
3543
3507
  <RCTScrollView
3544
3508
  ListFooterComponent={null}
3545
3509
  data={