@hero-design/rn 7.12.1 → 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.
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +4908 -4728
- package/lib/index.js +4907 -4726
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +64 -60
- package/src/components/Button/StyledButton.tsx +4 -6
- package/src/components/Button/__tests__/StyledButton.spec.tsx +11 -4
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +312 -78
- package/src/components/DatePicker/DatePickerAndroid.tsx +59 -0
- package/src/components/DatePicker/DatePickerIOS.tsx +87 -0
- package/src/components/DatePicker/StyledDatePicker.tsx +8 -0
- package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +34 -0
- package/src/components/DatePicker/__tests__/DatePickerAndroid.spec.tsx +39 -0
- package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +46 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +199 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +513 -0
- package/src/components/DatePicker/index.tsx +15 -0
- package/src/components/DatePicker/types.ts +49 -0
- package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
- package/src/components/TimePicker/types.ts +1 -1
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +18 -0
- package/src/theme/components/button.ts +12 -0
- package/src/theme/components/datePicker.ts +11 -0
- package/src/theme/global/colors.ts +1 -0
- package/src/theme/index.ts +3 -0
- package/types/components/Button/StyledButton.d.ts +3 -3
- package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -0
- package/types/components/DatePicker/DatePickerIOS.d.ts +3 -0
- package/types/components/DatePicker/StyledDatePicker.d.ts +8 -0
- package/types/components/DatePicker/__tests__/DatePicker.spec.d.ts +1 -0
- package/types/components/DatePicker/__tests__/DatePickerAndroid.spec.d.ts +1 -0
- package/types/components/DatePicker/__tests__/DatePickerIOS.spec.d.ts +1 -0
- package/types/components/DatePicker/index.d.ts +3 -0
- package/types/components/DatePicker/types.d.ts +48 -0
- package/types/components/TimePicker/types.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/theme/components/button.d.ts +12 -0
- package/types/theme/components/datePicker.d.ts +6 -0
- package/types/theme/global/colors.d.ts +1 -0
- package/types/theme/global/index.d.ts +1 -0
- 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.
|
|
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.
|
|
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 {
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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(
|
|
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();
|