@hero-design/rn 8.63.4-alpha.0 → 8.64.1
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 +5 -0
- package/CHANGELOG.md +12 -0
- package/es/index.js +85 -38
- package/lib/index.js +85 -38
- package/package.json +1 -1
- package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/BottomSheet/__tests__/index.spec.tsx +17 -0
- package/src/components/BottomSheet/index.tsx +6 -0
- package/src/components/Calendar/CalendarRowItem.tsx +3 -1
- package/src/components/Calendar/StyledCalendar.tsx +21 -8
- package/src/components/Calendar/__tests__/CalendarRowItem.spec.tsx +1 -0
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +4 -2
- package/src/components/Calendar/__tests__/index.spec.tsx +7 -1
- package/src/components/Calendar/index.tsx +30 -8
- package/src/components/DatePicker/DatePickerCalendar.tsx +14 -10
- package/src/components/DatePicker/DatePickerIOS.tsx +2 -0
- package/src/components/DatePicker/__tests__/DatePickerCalendar.spec.tsx +37 -0
- package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +34 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +5 -0
- package/src/components/DatePicker/types.ts +4 -0
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +45 -24
- package/src/components/FAB/ActionGroup/index.tsx +6 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +20 -0
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +28 -0
- package/src/components/Select/MultiSelect/index.tsx +6 -0
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +15 -0
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +25 -0
- package/src/components/Select/SingleSelect/index.tsx +6 -0
- package/src/components/TimePicker/TimePickerIOS.tsx +2 -0
- package/src/components/TimePicker/__tests__/TimePickerIOS.spec.tsx +31 -0
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +5 -0
- package/src/components/TimePicker/types.ts +4 -0
- package/src/testHelpers/utils.ts +21 -0
- package/stats/8.64.0/rn-stats.html +4844 -0
- package/stats/8.64.1/rn-stats.html +4842 -0
- package/types/components/BottomSheet/index.d.ts +5 -1
- package/types/components/Calendar/CalendarRowItem.d.ts +2 -1
- package/types/components/Calendar/StyledCalendar.d.ts +7 -0
- package/types/components/DatePicker/DatePickerCalendar.d.ts +1 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
- package/types/components/DatePicker/types.d.ts +4 -0
- package/types/components/FAB/ActionGroup/index.d.ts +4 -0
- package/types/components/Select/MultiSelect/index.d.ts +5 -1
- package/types/components/Select/SingleSelect/index.d.ts +5 -1
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/TimePicker/TimePickerIOS.d.ts +1 -1
- package/types/components/TimePicker/types.d.ts +4 -0
|
@@ -266,6 +266,11 @@ exports[`rendering allows custom renderer 1`] = `
|
|
|
266
266
|
<Modal
|
|
267
267
|
hardwareAccelerated={false}
|
|
268
268
|
onRequestClose={[Function]}
|
|
269
|
+
supportedOrientations={
|
|
270
|
+
[
|
|
271
|
+
"portrait",
|
|
272
|
+
]
|
|
273
|
+
}
|
|
269
274
|
transparent={true}
|
|
270
275
|
visible={true}
|
|
271
276
|
>
|
|
@@ -2084,6 +2089,11 @@ exports[`rendering renders correctly when bottom sheet is visible 1`] = `
|
|
|
2084
2089
|
<Modal
|
|
2085
2090
|
hardwareAccelerated={false}
|
|
2086
2091
|
onRequestClose={[Function]}
|
|
2092
|
+
supportedOrientations={
|
|
2093
|
+
[
|
|
2094
|
+
"portrait",
|
|
2095
|
+
]
|
|
2096
|
+
}
|
|
2087
2097
|
transparent={true}
|
|
2088
2098
|
visible={true}
|
|
2089
2099
|
>
|
|
@@ -4121,6 +4131,11 @@ exports[`rendering renders correctly when receives sections 1`] = `
|
|
|
4121
4131
|
<Modal
|
|
4122
4132
|
hardwareAccelerated={false}
|
|
4123
4133
|
onRequestClose={[Function]}
|
|
4134
|
+
supportedOrientations={
|
|
4135
|
+
[
|
|
4136
|
+
"portrait",
|
|
4137
|
+
]
|
|
4138
|
+
}
|
|
4124
4139
|
transparent={true}
|
|
4125
4140
|
visible={true}
|
|
4126
4141
|
>
|
|
@@ -5439,6 +5454,11 @@ exports[`rendering renders correctly when receives sections 2`] = `
|
|
|
5439
5454
|
<Modal
|
|
5440
5455
|
hardwareAccelerated={false}
|
|
5441
5456
|
onRequestClose={[Function]}
|
|
5457
|
+
supportedOrientations={
|
|
5458
|
+
[
|
|
5459
|
+
"portrait",
|
|
5460
|
+
]
|
|
5461
|
+
}
|
|
5442
5462
|
transparent={true}
|
|
5443
5463
|
visible={true}
|
|
5444
5464
|
>
|
|
@@ -9,6 +9,7 @@ import HeroDesignProvider from '../../../HeroDesignProvider';
|
|
|
9
9
|
import List from '../../../List';
|
|
10
10
|
import Typography from '../../../Typography';
|
|
11
11
|
import type { ListRenderOptionInfo } from '../../types';
|
|
12
|
+
import { setOrientation } from '../../../../testHelpers/utils';
|
|
12
13
|
|
|
13
14
|
const options = [
|
|
14
15
|
{ text: 'Monday', value: 'mon' },
|
|
@@ -113,6 +114,33 @@ describe('rendering', () => {
|
|
|
113
114
|
expect(getByText('Confirm')).toBeDefined();
|
|
114
115
|
});
|
|
115
116
|
|
|
117
|
+
it('renders correctly in landscape mode when bottom sheet is visible', () => {
|
|
118
|
+
setOrientation('landscape');
|
|
119
|
+
|
|
120
|
+
const { queryAllByText, getByText, getByTestId } = renderWithTheme(
|
|
121
|
+
<MultiSelect
|
|
122
|
+
label="Allow notifications"
|
|
123
|
+
footerLabel="Confirm"
|
|
124
|
+
options={options}
|
|
125
|
+
value={['mon', 'tue']}
|
|
126
|
+
onConfirm={jest.fn()}
|
|
127
|
+
supportedOrientations={['landscape']}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
fireEvent.press(getByTestId('text-input'));
|
|
132
|
+
|
|
133
|
+
expect(queryAllByText('Allow notifications')).toHaveLength(2);
|
|
134
|
+
expect(getByText('Monday')).toBeDefined();
|
|
135
|
+
expect(getByText('Tuesday')).toBeDefined();
|
|
136
|
+
expect(getByText('Wednesday')).toBeDefined();
|
|
137
|
+
expect(getByText('Thursday')).toBeDefined();
|
|
138
|
+
expect(getByText('Friday')).toBeDefined();
|
|
139
|
+
expect(getByText('Saturday')).toBeDefined();
|
|
140
|
+
expect(getByText('Sunday')).toBeDefined();
|
|
141
|
+
expect(getByText('Confirm')).toBeDefined();
|
|
142
|
+
});
|
|
143
|
+
|
|
116
144
|
it('renders correctly when input is loading', () => {
|
|
117
145
|
const { toJSON, getByTestId } = renderWithTheme(
|
|
118
146
|
<MultiSelect
|
|
@@ -47,6 +47,10 @@ export interface MultiSelectProps<V, T extends OptionType<V> = OptionType<V>>
|
|
|
47
47
|
selectedValue: V[],
|
|
48
48
|
inputProps: NativeTextInputProps
|
|
49
49
|
) => React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Supported orientations for the MultiSelect modal, iOS only.
|
|
52
|
+
*/
|
|
53
|
+
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
function MultiSelect<V, T extends OptionType<V>>({
|
|
@@ -69,6 +73,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
69
73
|
style,
|
|
70
74
|
testID,
|
|
71
75
|
value,
|
|
76
|
+
supportedOrientations = ['portrait'],
|
|
72
77
|
}: MultiSelectProps<V, T>) {
|
|
73
78
|
const { isKeyboardVisible, keyboardHeight } = useKeyboard();
|
|
74
79
|
const [open, setOpen] = useState(false);
|
|
@@ -154,6 +159,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
154
159
|
sectionListRef.current?.scrollToLocation(scrollParams);
|
|
155
160
|
}
|
|
156
161
|
}}
|
|
162
|
+
supportedOrientations={supportedOrientations}
|
|
157
163
|
>
|
|
158
164
|
{onQueryChange && (
|
|
159
165
|
<StyledSearchBar>
|
|
@@ -265,6 +265,11 @@ exports[`rendering allows custom renderer 1`] = `
|
|
|
265
265
|
<Modal
|
|
266
266
|
hardwareAccelerated={false}
|
|
267
267
|
onRequestClose={[Function]}
|
|
268
|
+
supportedOrientations={
|
|
269
|
+
[
|
|
270
|
+
"portrait",
|
|
271
|
+
]
|
|
272
|
+
}
|
|
268
273
|
transparent={true}
|
|
269
274
|
visible={true}
|
|
270
275
|
>
|
|
@@ -1999,6 +2004,11 @@ exports[`rendering renders correctly when bottom sheet is visible 1`] = `
|
|
|
1999
2004
|
<Modal
|
|
2000
2005
|
hardwareAccelerated={false}
|
|
2001
2006
|
onRequestClose={[Function]}
|
|
2007
|
+
supportedOrientations={
|
|
2008
|
+
[
|
|
2009
|
+
"portrait",
|
|
2010
|
+
]
|
|
2011
|
+
}
|
|
2002
2012
|
transparent={true}
|
|
2003
2013
|
visible={true}
|
|
2004
2014
|
>
|
|
@@ -3896,6 +3906,11 @@ exports[`rendering renders correctly when receives sections 1`] = `
|
|
|
3896
3906
|
<Modal
|
|
3897
3907
|
hardwareAccelerated={false}
|
|
3898
3908
|
onRequestClose={[Function]}
|
|
3909
|
+
supportedOrientations={
|
|
3910
|
+
[
|
|
3911
|
+
"portrait",
|
|
3912
|
+
]
|
|
3913
|
+
}
|
|
3899
3914
|
transparent={true}
|
|
3900
3915
|
visible={true}
|
|
3901
3916
|
>
|
|
@@ -5,6 +5,7 @@ import SingleSelect from '..';
|
|
|
5
5
|
import Typography from '../../../Typography';
|
|
6
6
|
import List from '../../../List';
|
|
7
7
|
import type { ListRenderOptionInfo } from '../../types';
|
|
8
|
+
import { setOrientation } from '../../../../testHelpers/utils';
|
|
8
9
|
|
|
9
10
|
const options = [
|
|
10
11
|
{ text: 'Monday', value: 'mon' },
|
|
@@ -105,6 +106,30 @@ describe('rendering', () => {
|
|
|
105
106
|
expect(getByText('Sunday')).toBeDefined();
|
|
106
107
|
});
|
|
107
108
|
|
|
109
|
+
it('renders correctly in landscape mode when bottom sheet is visible', () => {
|
|
110
|
+
setOrientation('landscape');
|
|
111
|
+
|
|
112
|
+
const { queryAllByText, getByText, getByTestId } = renderWithTheme(
|
|
113
|
+
<SingleSelect
|
|
114
|
+
label="Allow notifications"
|
|
115
|
+
options={options}
|
|
116
|
+
value="mon"
|
|
117
|
+
onConfirm={jest.fn()}
|
|
118
|
+
supportedOrientations={['landscape']}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
fireEvent.press(getByTestId('text-input'));
|
|
122
|
+
|
|
123
|
+
expect(queryAllByText('Allow notifications')).toHaveLength(2);
|
|
124
|
+
expect(getByText('Monday')).toBeDefined();
|
|
125
|
+
expect(getByText('Tuesday')).toBeDefined();
|
|
126
|
+
expect(getByText('Wednesday')).toBeDefined();
|
|
127
|
+
expect(getByText('Thursday')).toBeDefined();
|
|
128
|
+
expect(getByText('Friday')).toBeDefined();
|
|
129
|
+
expect(getByText('Saturday')).toBeDefined();
|
|
130
|
+
expect(getByText('Sunday')).toBeDefined();
|
|
131
|
+
});
|
|
132
|
+
|
|
108
133
|
it('renders correctly when input is loading', () => {
|
|
109
134
|
const { toJSON, getByTestId } = renderWithTheme(
|
|
110
135
|
<SingleSelect
|
|
@@ -33,6 +33,10 @@ export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>>
|
|
|
33
33
|
selectedValue: V | null,
|
|
34
34
|
inputProps: NativeTextInputProps
|
|
35
35
|
) => React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Supported orientations for the Select modal, iOS only.
|
|
38
|
+
*/
|
|
39
|
+
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
const SingleSelect = <V, T extends OptionType<V>>({
|
|
@@ -54,6 +58,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
54
58
|
style,
|
|
55
59
|
testID,
|
|
56
60
|
value,
|
|
61
|
+
supportedOrientations = ['portrait'],
|
|
57
62
|
}: SingleSelectProps<V, T>) => {
|
|
58
63
|
const { isKeyboardVisible, keyboardHeight } = useKeyboard();
|
|
59
64
|
const [open, setOpen] = useState(false);
|
|
@@ -113,6 +118,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
113
118
|
sectionListRef.current?.scrollToLocation(scrollParams);
|
|
114
119
|
}
|
|
115
120
|
}}
|
|
121
|
+
supportedOrientations={supportedOrientations}
|
|
116
122
|
>
|
|
117
123
|
{onQueryChange && (
|
|
118
124
|
<StyledSearchBar>
|
|
@@ -24,6 +24,7 @@ const TimePickerIOS = ({
|
|
|
24
24
|
style,
|
|
25
25
|
testID,
|
|
26
26
|
showSuffix = true,
|
|
27
|
+
supportedOrientations = ['portrait'],
|
|
27
28
|
}: TimePickerProps) => {
|
|
28
29
|
const [selectingDate, setSelectingDate] = useState<Date>(value || new Date());
|
|
29
30
|
const [open, setOpen] = useState(false);
|
|
@@ -64,6 +65,7 @@ const TimePickerIOS = ({
|
|
|
64
65
|
}}
|
|
65
66
|
/>
|
|
66
67
|
}
|
|
68
|
+
supportedOrientations={supportedOrientations}
|
|
67
69
|
>
|
|
68
70
|
<StyledPickerWrapper>
|
|
69
71
|
<DateTimePicker
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import type { ModalProps } from 'react-native';
|
|
4
4
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
5
5
|
import TimePickerIOS from '../TimePickerIOS';
|
|
6
|
+
import { setOrientation } from '../../../testHelpers/utils';
|
|
6
7
|
|
|
7
8
|
jest.mock('react-native/Libraries/Modal/Modal', () => {
|
|
8
9
|
const Modal = jest.requireActual('react-native/Libraries/Modal/Modal');
|
|
@@ -43,6 +44,36 @@ describe('TimePickerIOS', () => {
|
|
|
43
44
|
expect(onChange).toBeCalledWith(new Date('December 17, 1995 05:30:00'));
|
|
44
45
|
});
|
|
45
46
|
|
|
47
|
+
it('renders correctly in landscape mode', () => {
|
|
48
|
+
setOrientation('landscape');
|
|
49
|
+
|
|
50
|
+
const onChange = jest.fn();
|
|
51
|
+
const { getByText, queryByTestId } = renderWithTheme(
|
|
52
|
+
<TimePickerIOS
|
|
53
|
+
value={new Date('December 17, 1995 03:24:00')}
|
|
54
|
+
label="Break time"
|
|
55
|
+
confirmLabel="Confirm"
|
|
56
|
+
onChange={onChange}
|
|
57
|
+
supportedOrientations={['landscape']}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// Open time picker
|
|
62
|
+
fireEvent.press(getByText('Break time'));
|
|
63
|
+
expect(queryByTestId('timePickerIOS')).toBeTruthy();
|
|
64
|
+
|
|
65
|
+
// Change time
|
|
66
|
+
fireEvent(
|
|
67
|
+
queryByTestId('timePickerIOS'),
|
|
68
|
+
'onChange',
|
|
69
|
+
null,
|
|
70
|
+
new Date('December 17, 1995 05:30:00')
|
|
71
|
+
);
|
|
72
|
+
fireEvent.press(getByText('Confirm'));
|
|
73
|
+
|
|
74
|
+
expect(onChange).toBeCalledWith(new Date('December 17, 1995 05:30:00'));
|
|
75
|
+
});
|
|
76
|
+
|
|
46
77
|
it('renders correct help text', () => {
|
|
47
78
|
const { getByText } = renderWithTheme(
|
|
48
79
|
<TimePickerIOS
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_DIMENSIONS = {
|
|
4
|
+
width: 390,
|
|
5
|
+
height: 844,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const setOrientation = (orientation: 'portrait' | 'landscape') => {
|
|
9
|
+
jest.spyOn(Dimensions, 'get').mockImplementation(() => ({
|
|
10
|
+
width:
|
|
11
|
+
orientation === 'landscape'
|
|
12
|
+
? DEFAULT_DIMENSIONS.height
|
|
13
|
+
: DEFAULT_DIMENSIONS.width,
|
|
14
|
+
height:
|
|
15
|
+
orientation === 'landscape'
|
|
16
|
+
? DEFAULT_DIMENSIONS.width
|
|
17
|
+
: DEFAULT_DIMENSIONS.height,
|
|
18
|
+
scale: 1,
|
|
19
|
+
fontScale: 1,
|
|
20
|
+
}));
|
|
21
|
+
};
|