@hero-design/rn 7.12.0 → 7.13.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 (42) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +4908 -4728
  3. package/lib/index.js +4907 -4726
  4. package/package.json +2 -2
  5. package/src/components/Button/Button.tsx +64 -60
  6. package/src/components/Button/StyledButton.tsx +4 -6
  7. package/src/components/Button/__tests__/StyledButton.spec.tsx +11 -4
  8. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +312 -78
  9. package/src/components/DatePicker/DatePickerAndroid.tsx +59 -0
  10. package/src/components/DatePicker/DatePickerIOS.tsx +87 -0
  11. package/src/components/DatePicker/StyledDatePicker.tsx +8 -0
  12. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +34 -0
  13. package/src/components/DatePicker/__tests__/DatePickerAndroid.spec.tsx +39 -0
  14. package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +46 -0
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +199 -0
  16. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +513 -0
  17. package/src/components/DatePicker/index.tsx +15 -0
  18. package/src/components/DatePicker/types.ts +49 -0
  19. package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
  20. package/src/components/TimePicker/types.ts +1 -1
  21. package/src/index.ts +2 -0
  22. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +18 -0
  23. package/src/theme/components/button.ts +12 -0
  24. package/src/theme/components/datePicker.ts +11 -0
  25. package/src/theme/global/colors.ts +1 -0
  26. package/src/theme/index.ts +3 -0
  27. package/types/components/Button/StyledButton.d.ts +3 -3
  28. package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -0
  29. package/types/components/DatePicker/DatePickerIOS.d.ts +3 -0
  30. package/types/components/DatePicker/StyledDatePicker.d.ts +8 -0
  31. package/types/components/DatePicker/__tests__/DatePicker.spec.d.ts +1 -0
  32. package/types/components/DatePicker/__tests__/DatePickerAndroid.spec.d.ts +1 -0
  33. package/types/components/DatePicker/__tests__/DatePickerIOS.spec.d.ts +1 -0
  34. package/types/components/DatePicker/index.d.ts +3 -0
  35. package/types/components/DatePicker/types.d.ts +48 -0
  36. package/types/components/TimePicker/types.d.ts +1 -1
  37. package/types/index.d.ts +2 -1
  38. package/types/theme/components/button.d.ts +12 -0
  39. package/types/theme/components/datePicker.d.ts +6 -0
  40. package/types/theme/global/colors.d.ts +1 -0
  41. package/types/theme/global/index.d.ts +1 -0
  42. package/types/theme/index.d.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.12.0",
3
+ "version": "7.13.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@emotion/native": "^11.9.3",
23
23
  "@emotion/react": "^11.9.3",
24
- "@hero-design/colors": "7.12.0",
24
+ "@hero-design/colors": "7.13.0",
25
25
  "date-fns": "^2.16.1"
26
26
  },
27
27
  "peerDependencies": {
@@ -1,5 +1,6 @@
1
+ import { useTheme } from '@emotion/react';
1
2
  import React, { ReactChild } from 'react';
2
- import { Pressable, StyleProp, ViewStyle } from 'react-native';
3
+ import { StyleProp, ViewStyle } from 'react-native';
3
4
 
4
5
  import { IconName } from '../Icon';
5
6
  import LoadingIndicator from './LoadingIndicator';
@@ -110,64 +111,67 @@ const Button = ({
110
111
  testID,
111
112
  text,
112
113
  variant = 'filled',
113
- }: ButtonProps) => (
114
- <Pressable
115
- accessibilityHint={accessibilityHint}
116
- accessibilityLabel={accessibilityLabel}
117
- disabled={disabled || loading}
118
- onPress={onPress}
119
- testID={testID}
120
- >
121
- {({ pressed }) => (
122
- <StyledButtonContainer
123
- disabled={disabled}
124
- pressed={pressed}
125
- style={style}
126
- themeVariant={getThemeVariant(variant, intent)}
127
- >
128
- {loading === true ? (
129
- <LoadingIndicator
130
- testID={`${testID}-loading-indicator`}
131
- themeVariant={getThemeVariant(variant, intent)}
132
- />
133
- ) : (
134
- <>
135
- {icon !== undefined && (
136
- <StyledButtonIconWrapper themePosition="left">
137
- <StyledButtonIcon
138
- disabled={disabled}
139
- icon={icon}
140
- pressed={pressed}
141
- testID={`${testID}-left-icon`}
142
- themeVariant={getThemeVariant(variant, intent)}
143
- />
144
- </StyledButtonIconWrapper>
145
- )}
146
- <StyledButtonText
147
- disabled={disabled}
148
- ellipsizeMode="tail"
149
- numberOfLines={1}
150
- pressed={pressed}
151
- themeVariant={getThemeVariant(variant, intent)}
152
- >
153
- {text}
154
- </StyledButtonText>
155
- {rightIcon !== undefined && (
156
- <StyledButtonIconWrapper themePosition="right">
157
- <StyledButtonIcon
158
- disabled={disabled}
159
- icon={rightIcon}
160
- pressed={pressed}
161
- testID={`${testID}-right-icon`}
162
- themeVariant={getThemeVariant(variant, intent)}
163
- />
164
- </StyledButtonIconWrapper>
165
- )}
166
- </>
167
- )}
168
- </StyledButtonContainer>
169
- )}
170
- </Pressable>
171
- );
114
+ }: ButtonProps): JSX.Element => {
115
+ const [pressed, setPressed] = React.useState(false);
116
+ const theme = useTheme();
117
+ const themeVariant = getThemeVariant(variant, intent);
118
+ return (
119
+ <StyledButtonContainer
120
+ onShowUnderlay={() => setPressed(true)}
121
+ onHideUnderlay={() => setPressed(false)}
122
+ underlayColor={theme.__hd__.button.colors.underlayColors[themeVariant]}
123
+ accessibilityHint={accessibilityHint}
124
+ accessibilityLabel={accessibilityLabel}
125
+ disabled={disabled || loading}
126
+ activeOpacity={0.5}
127
+ onPress={onPress}
128
+ testID={testID}
129
+ pressed={pressed}
130
+ themeVariant={themeVariant}
131
+ style={style}
132
+ >
133
+ {loading === true ? (
134
+ <LoadingIndicator
135
+ testID={`${testID}-loading-indicator`}
136
+ themeVariant={themeVariant}
137
+ />
138
+ ) : (
139
+ <>
140
+ {icon !== undefined && (
141
+ <StyledButtonIconWrapper themePosition="left">
142
+ <StyledButtonIcon
143
+ disabled={disabled}
144
+ icon={icon}
145
+ pressed={pressed}
146
+ testID={`${testID}-left-icon`}
147
+ themeVariant={themeVariant}
148
+ />
149
+ </StyledButtonIconWrapper>
150
+ )}
151
+ <StyledButtonText
152
+ disabled={disabled}
153
+ ellipsizeMode="tail"
154
+ numberOfLines={1}
155
+ pressed={pressed}
156
+ themeVariant={themeVariant}
157
+ >
158
+ {text}
159
+ </StyledButtonText>
160
+ {rightIcon !== undefined && (
161
+ <StyledButtonIconWrapper themePosition="right">
162
+ <StyledButtonIcon
163
+ disabled={disabled}
164
+ icon={rightIcon}
165
+ pressed={pressed}
166
+ testID={`${testID}-right-icon`}
167
+ themeVariant={themeVariant}
168
+ />
169
+ </StyledButtonIconWrapper>
170
+ )}
171
+ </>
172
+ )}
173
+ </StyledButtonContainer>
174
+ );
175
+ };
172
176
 
173
177
  export default Button;
@@ -1,4 +1,4 @@
1
- import { View } from 'react-native';
1
+ import { TouchableHighlight, View } from 'react-native';
2
2
  import styled, { ReactNativeStyle } from '@emotion/native';
3
3
  import { Theme } from '@emotion/react';
4
4
 
@@ -79,10 +79,10 @@ const genFilledContainerStyles = (
79
79
  };
80
80
 
81
81
  return {
82
- width: '100%',
83
82
  flexDirection: 'row',
84
83
  justifyContent: 'center',
85
84
  alignItems: 'center',
85
+ alignSelf: 'stretch',
86
86
  padding: theme.__hd__.button.space.buttonPadding,
87
87
  borderRadius: theme.__hd__.button.radii.default,
88
88
  ...backgroundColorStyling(),
@@ -112,10 +112,10 @@ const genOutlineContainerStyles = (
112
112
  };
113
113
 
114
114
  return {
115
- width: '100%',
116
115
  flexDirection: 'row',
117
116
  justifyContent: 'center',
118
117
  alignItems: 'center',
118
+ alignSelf: 'stretch',
119
119
  padding:
120
120
  theme.__hd__.button.space.buttonPadding -
121
121
  theme.__hd__.button.borderWidth.default,
@@ -184,7 +184,7 @@ const genTextVariantTextStyles = (
184
184
  };
185
185
  };
186
186
 
187
- const StyledButtonContainer = styled(View)<{
187
+ const StyledButtonContainer = styled(TouchableHighlight)<{
188
188
  disabled?: boolean;
189
189
  pressed?: boolean;
190
190
  themeVariant: ThemeVariant;
@@ -208,13 +208,11 @@ const StyledButtonContainer = styled(View)<{
208
208
  case 'text-secondary':
209
209
  case 'text-danger':
210
210
  return {
211
- width: '100%',
212
211
  flexDirection: 'row',
213
212
  justifyContent: 'center',
214
213
  alignItems: 'center',
215
214
  padding: theme.__hd__.button.space.buttonPadding,
216
215
  borderWidth: 0,
217
- backgroundColor: 'transparent',
218
216
  };
219
217
  }
220
218
  });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
+ import { Text } from 'react-native';
3
4
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
5
 
5
6
  import {
@@ -22,9 +23,11 @@ describe('StyledButtonContainer', () => {
22
23
  ${'text-primary'}
23
24
  ${'text-secondary'}
24
25
  ${'text-danger'}
25
- `('has $themeVariant style', ({ themeVariant }) => {
26
+ `('has $themeVariant style', ({ themeVariant }): void => {
26
27
  const { toJSON } = renderWithTheme(
27
- <StyledButtonContainer themeVariant={themeVariant} />
28
+ <StyledButtonContainer themeVariant={themeVariant}>
29
+ <Text>Title</Text>
30
+ </StyledButtonContainer>
28
31
  );
29
32
 
30
33
  expect(toJSON()).toMatchSnapshot();
@@ -46,7 +49,9 @@ describe('StyledButtonContainer', () => {
46
49
  'has pressed with the correct variant $themeVariant style',
47
50
  ({ themeVariant }) => {
48
51
  const { toJSON } = renderWithTheme(
49
- <StyledButtonContainer themeVariant={themeVariant} pressed />
52
+ <StyledButtonContainer themeVariant={themeVariant} pressed>
53
+ <Text>Title</Text>
54
+ </StyledButtonContainer>
50
55
  );
51
56
  expect(toJSON()).toMatchSnapshot();
52
57
  }
@@ -54,7 +59,9 @@ describe('StyledButtonContainer', () => {
54
59
 
55
60
  it('renders disabled correctly', () => {
56
61
  const { toJSON } = renderWithTheme(
57
- <StyledButtonContainer themeVariant="filled-primary" disabled />
62
+ <StyledButtonContainer themeVariant="filled-primary" disabled>
63
+ <Text>Title</Text>
64
+ </StyledButtonContainer>
58
65
  );
59
66
 
60
67
  expect(toJSON()).toMatchSnapshot();