@hero-design/rn 8.27.1 → 8.27.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.
- package/.turbo/turbo-build.log +1 -1
- package/es/index.js +44 -76
- package/lib/index.js +44 -76
- package/package.json +5 -5
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +4 -0
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +6 -0
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +6 -6
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
- package/src/components/Collapse/index.tsx +25 -4
- package/src/components/DatePicker/DatePickerIOS.tsx +19 -1
- package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +25 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +9 -9
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +3 -3
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +3 -3
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +3 -3
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +3 -17
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +1065 -557
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +15 -9
- package/src/components/FAB/ActionGroup/index.tsx +35 -97
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +2 -2
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +3 -3
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +14 -14
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +14 -14
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +3 -3
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +1 -1
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +1 -1
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
- package/src/components/Tag/StyledTag.tsx +1 -0
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +19 -10
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -1
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +24 -24
- package/src/components/TextInput/index.tsx +1 -1
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +4 -4
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +4 -4
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +10 -8
- package/src/theme/components/fab.ts +0 -1
- package/src/theme/components/tag.ts +5 -2
- package/src/theme/global/typography.ts +2 -2
- package/types/components/Collapse/index.d.ts +1 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +1 -0
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +1 -7
- package/types/theme/components/fab.d.ts +0 -1
- package/types/theme/components/tag.d.ts +3 -0
|
@@ -143,7 +143,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
143
143
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
144
144
|
"fontSize": 12,
|
|
145
145
|
"letterSpacing": 0.36,
|
|
146
|
-
"lineHeight":
|
|
146
|
+
"lineHeight": 16,
|
|
147
147
|
},
|
|
148
148
|
Array [
|
|
149
149
|
Object {
|
|
@@ -206,7 +206,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
206
206
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
207
207
|
"fontSize": 12,
|
|
208
208
|
"letterSpacing": 0.36,
|
|
209
|
-
"lineHeight":
|
|
209
|
+
"lineHeight": 16,
|
|
210
210
|
},
|
|
211
211
|
Array [
|
|
212
212
|
Object {
|
|
@@ -269,7 +269,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
269
269
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
270
270
|
"fontSize": 12,
|
|
271
271
|
"letterSpacing": 0.36,
|
|
272
|
-
"lineHeight":
|
|
272
|
+
"lineHeight": 16,
|
|
273
273
|
},
|
|
274
274
|
Array [
|
|
275
275
|
Object {
|
|
@@ -332,7 +332,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
332
332
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
333
333
|
"fontSize": 12,
|
|
334
334
|
"letterSpacing": 0.36,
|
|
335
|
-
"lineHeight":
|
|
335
|
+
"lineHeight": 16,
|
|
336
336
|
},
|
|
337
337
|
Array [
|
|
338
338
|
Object {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports[`Collapse renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
collapsable={false}
|
|
6
|
+
onLayout={[Function]}
|
|
6
7
|
style={
|
|
7
8
|
Object {
|
|
8
9
|
"height": 0,
|
|
@@ -46,6 +47,7 @@ exports[`Collapse renders correctly 1`] = `
|
|
|
46
47
|
exports[`Collapse should render Sample Text but not visible 1`] = `
|
|
47
48
|
<View
|
|
48
49
|
collapsable={false}
|
|
50
|
+
onLayout={[Function]}
|
|
49
51
|
style={
|
|
50
52
|
Object {
|
|
51
53
|
"height": 0,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React, { useCallback, useEffect } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
LayoutChangeEvent,
|
|
5
|
+
StyleProp,
|
|
6
|
+
ViewProps,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
4
9
|
import { LayoutAnimation, Platform, UIManager } from 'react-native';
|
|
5
10
|
import { usePrevious } from '../../utils/hooks';
|
|
6
11
|
import {
|
|
@@ -34,15 +39,24 @@ if (Platform.OS === 'android') {
|
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
const Collapse = ({
|
|
42
|
+
const Collapse = ({
|
|
43
|
+
open = false,
|
|
44
|
+
children,
|
|
45
|
+
testID,
|
|
46
|
+
style,
|
|
47
|
+
onLayout,
|
|
48
|
+
}: CollapseProps) => {
|
|
38
49
|
const [contentHeight, setContentHeight] = React.useState<number>(0);
|
|
50
|
+
const [componentMounted, setComponentMounted] =
|
|
51
|
+
React.useState<boolean>(false);
|
|
39
52
|
|
|
40
53
|
const previousOpenState = usePrevious(open);
|
|
41
54
|
|
|
42
55
|
useEffect(() => {
|
|
43
56
|
if (
|
|
44
|
-
(open !== previousOpenState && previousOpenState !== undefined) ||
|
|
45
|
-
|
|
57
|
+
((open !== previousOpenState && previousOpenState !== undefined) ||
|
|
58
|
+
open) &&
|
|
59
|
+
componentMounted
|
|
46
60
|
) {
|
|
47
61
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
48
62
|
}
|
|
@@ -52,11 +66,18 @@ const Collapse = ({ open = false, children, testID, style }: CollapseProps) => {
|
|
|
52
66
|
setContentHeight(height);
|
|
53
67
|
}, []);
|
|
54
68
|
|
|
69
|
+
const onCollapseLayout = useCallback((e: LayoutChangeEvent) => {
|
|
70
|
+
setComponentMounted(true);
|
|
71
|
+
|
|
72
|
+
onLayout?.(e);
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
55
75
|
return (
|
|
56
76
|
<StyledWrapper
|
|
57
77
|
style={{
|
|
58
78
|
height: open ? contentHeight : 0,
|
|
59
79
|
}}
|
|
80
|
+
onLayout={onCollapseLayout}
|
|
60
81
|
testID={testID}
|
|
61
82
|
>
|
|
62
83
|
<StyledHiddenWrapper>
|
|
@@ -10,6 +10,22 @@ import { StyledPickerWrapper } from './StyledDatePicker';
|
|
|
10
10
|
import type { DatePickerProps } from './types';
|
|
11
11
|
import { useTheme } from '../../theme';
|
|
12
12
|
|
|
13
|
+
export const getInitialDateValue = (
|
|
14
|
+
value: Date,
|
|
15
|
+
minDate?: Date | undefined,
|
|
16
|
+
maxDate?: Date | undefined
|
|
17
|
+
) => {
|
|
18
|
+
if (minDate && value < minDate) {
|
|
19
|
+
return minDate;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (maxDate && value > maxDate) {
|
|
23
|
+
return maxDate;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
|
|
13
29
|
const DatePickerIOS = ({
|
|
14
30
|
value,
|
|
15
31
|
minDate,
|
|
@@ -26,7 +42,9 @@ const DatePickerIOS = ({
|
|
|
26
42
|
style,
|
|
27
43
|
testID,
|
|
28
44
|
}: Omit<DatePickerProps, 'variant'>) => {
|
|
29
|
-
const [selectingDate, setSelectingDate] = useState<Date>(
|
|
45
|
+
const [selectingDate, setSelectingDate] = useState<Date>(
|
|
46
|
+
getInitialDateValue(value || new Date(), minDate, maxDate)
|
|
47
|
+
);
|
|
30
48
|
const [open, setOpen] = useState(false);
|
|
31
49
|
|
|
32
50
|
const displayValue = value ? formatDate(displayFormat, value) : '';
|
|
@@ -2,13 +2,37 @@ import { fireEvent } from '@testing-library/react-native';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ModalProps } from 'react-native';
|
|
4
4
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
5
|
-
import DatePickerIOS from '../DatePickerIOS';
|
|
5
|
+
import DatePickerIOS, { getInitialDateValue } from '../DatePickerIOS';
|
|
6
6
|
|
|
7
7
|
jest.mock('react-native/Libraries/Modal/Modal', () => {
|
|
8
8
|
const Modal = jest.requireActual('react-native/Libraries/Modal/Modal');
|
|
9
9
|
return (props: ModalProps) => <Modal {...props} />;
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
describe('getInitialDateValue', () => {
|
|
13
|
+
describe('when value is less than minDate', () => {
|
|
14
|
+
it('should return minDate', () => {
|
|
15
|
+
const value = new Date('2022-01-01T00:00:00.000Z');
|
|
16
|
+
const minDate = new Date('2025-01-01T00:00:00.000Z');
|
|
17
|
+
expect(getInitialDateValue(value, minDate)).toBe(minDate);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('when value is greater than maxDate', () => {
|
|
21
|
+
it('should return maxDate', () => {
|
|
22
|
+
const value = new Date('2025-01-01T00:00:00.000Z');
|
|
23
|
+
const maxDate = new Date('2022-01-01T00:00:00.000Z');
|
|
24
|
+
expect(getInitialDateValue(value, undefined, maxDate)).toBe(maxDate);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('when minDate < value < maxDate', () => {
|
|
28
|
+
it('should return value', () => {
|
|
29
|
+
const minDate = new Date('2022-01-01T00:00:00.000Z');
|
|
30
|
+
const value = new Date('2023-01-01T00:00:00.000Z');
|
|
31
|
+
const maxDate = new Date('2025-01-01T00:00:00.000Z');
|
|
32
|
+
expect(getInitialDateValue(value, minDate, maxDate)).toBe(value);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
12
36
|
describe('DatePickerIOS', () => {
|
|
13
37
|
it('renders correctly', () => {
|
|
14
38
|
const onChange = jest.fn();
|
|
@@ -88,7 +88,7 @@ exports[`DatePicker renders DatePickerAndroid when OS is android 1`] = `
|
|
|
88
88
|
"left": 16,
|
|
89
89
|
"paddingHorizontal": 4,
|
|
90
90
|
"position": "absolute",
|
|
91
|
-
"top": -
|
|
91
|
+
"top": -4,
|
|
92
92
|
"zIndex": 1,
|
|
93
93
|
},
|
|
94
94
|
Object {
|
|
@@ -187,14 +187,14 @@ exports[`DatePicker renders DatePickerAndroid when OS is android 1`] = `
|
|
|
187
187
|
Array [
|
|
188
188
|
Object {
|
|
189
189
|
"color": "#001f23",
|
|
190
|
-
"fontSize":
|
|
190
|
+
"fontSize": 24,
|
|
191
191
|
},
|
|
192
192
|
undefined,
|
|
193
193
|
]
|
|
194
194
|
}
|
|
195
195
|
testID="input-suffix"
|
|
196
196
|
themeIntent="text"
|
|
197
|
-
themeSize="
|
|
197
|
+
themeSize="medium"
|
|
198
198
|
/>
|
|
199
199
|
</View>
|
|
200
200
|
<View
|
|
@@ -313,7 +313,7 @@ exports[`DatePicker renders DatePickerIOS when OS is iOS 1`] = `
|
|
|
313
313
|
"left": 16,
|
|
314
314
|
"paddingHorizontal": 4,
|
|
315
315
|
"position": "absolute",
|
|
316
|
-
"top": -
|
|
316
|
+
"top": -4,
|
|
317
317
|
"zIndex": 1,
|
|
318
318
|
},
|
|
319
319
|
Object {
|
|
@@ -412,14 +412,14 @@ exports[`DatePicker renders DatePickerIOS when OS is iOS 1`] = `
|
|
|
412
412
|
Array [
|
|
413
413
|
Object {
|
|
414
414
|
"color": "#001f23",
|
|
415
|
-
"fontSize":
|
|
415
|
+
"fontSize": 24,
|
|
416
416
|
},
|
|
417
417
|
undefined,
|
|
418
418
|
]
|
|
419
419
|
}
|
|
420
420
|
testID="input-suffix"
|
|
421
421
|
themeIntent="text"
|
|
422
|
-
themeSize="
|
|
422
|
+
themeSize="medium"
|
|
423
423
|
/>
|
|
424
424
|
</View>
|
|
425
425
|
<View
|
|
@@ -544,7 +544,7 @@ exports[`DatePicker renders variant Calendar 1`] = `
|
|
|
544
544
|
"left": 16,
|
|
545
545
|
"paddingHorizontal": 4,
|
|
546
546
|
"position": "absolute",
|
|
547
|
-
"top": -
|
|
547
|
+
"top": -4,
|
|
548
548
|
"zIndex": 1,
|
|
549
549
|
},
|
|
550
550
|
Object {
|
|
@@ -643,14 +643,14 @@ exports[`DatePicker renders variant Calendar 1`] = `
|
|
|
643
643
|
Array [
|
|
644
644
|
Object {
|
|
645
645
|
"color": "#001f23",
|
|
646
|
-
"fontSize":
|
|
646
|
+
"fontSize": 24,
|
|
647
647
|
},
|
|
648
648
|
undefined,
|
|
649
649
|
]
|
|
650
650
|
}
|
|
651
651
|
testID="input-suffix"
|
|
652
652
|
themeIntent="text"
|
|
653
|
-
themeSize="
|
|
653
|
+
themeSize="medium"
|
|
654
654
|
/>
|
|
655
655
|
</View>
|
|
656
656
|
<View
|
|
@@ -88,7 +88,7 @@ exports[`DatePickerAndroid renders correctly 1`] = `
|
|
|
88
88
|
"left": 16,
|
|
89
89
|
"paddingHorizontal": 4,
|
|
90
90
|
"position": "absolute",
|
|
91
|
-
"top": -
|
|
91
|
+
"top": -4,
|
|
92
92
|
"zIndex": 1,
|
|
93
93
|
},
|
|
94
94
|
Object {
|
|
@@ -187,14 +187,14 @@ exports[`DatePickerAndroid renders correctly 1`] = `
|
|
|
187
187
|
Array [
|
|
188
188
|
Object {
|
|
189
189
|
"color": "#001f23",
|
|
190
|
-
"fontSize":
|
|
190
|
+
"fontSize": 24,
|
|
191
191
|
},
|
|
192
192
|
undefined,
|
|
193
193
|
]
|
|
194
194
|
}
|
|
195
195
|
testID="input-suffix"
|
|
196
196
|
themeIntent="text"
|
|
197
|
-
themeSize="
|
|
197
|
+
themeSize="medium"
|
|
198
198
|
/>
|
|
199
199
|
</View>
|
|
200
200
|
<View
|
|
@@ -88,7 +88,7 @@ exports[`DatePickerCalendar renders correctly 1`] = `
|
|
|
88
88
|
"left": 16,
|
|
89
89
|
"paddingHorizontal": 4,
|
|
90
90
|
"position": "absolute",
|
|
91
|
-
"top": -
|
|
91
|
+
"top": -4,
|
|
92
92
|
"zIndex": 1,
|
|
93
93
|
},
|
|
94
94
|
Object {
|
|
@@ -187,14 +187,14 @@ exports[`DatePickerCalendar renders correctly 1`] = `
|
|
|
187
187
|
Array [
|
|
188
188
|
Object {
|
|
189
189
|
"color": "#001f23",
|
|
190
|
-
"fontSize":
|
|
190
|
+
"fontSize": 24,
|
|
191
191
|
},
|
|
192
192
|
undefined,
|
|
193
193
|
]
|
|
194
194
|
}
|
|
195
195
|
testID="input-suffix"
|
|
196
196
|
themeIntent="text"
|
|
197
|
-
themeSize="
|
|
197
|
+
themeSize="medium"
|
|
198
198
|
/>
|
|
199
199
|
</View>
|
|
200
200
|
<View
|
|
@@ -88,7 +88,7 @@ exports[`DatePickerIOS renders correctly 1`] = `
|
|
|
88
88
|
"left": 16,
|
|
89
89
|
"paddingHorizontal": 4,
|
|
90
90
|
"position": "absolute",
|
|
91
|
-
"top": -
|
|
91
|
+
"top": -4,
|
|
92
92
|
"zIndex": 1,
|
|
93
93
|
},
|
|
94
94
|
Object {
|
|
@@ -187,14 +187,14 @@ exports[`DatePickerIOS renders correctly 1`] = `
|
|
|
187
187
|
Array [
|
|
188
188
|
Object {
|
|
189
189
|
"color": "#001f23",
|
|
190
|
-
"fontSize":
|
|
190
|
+
"fontSize": 24,
|
|
191
191
|
},
|
|
192
192
|
undefined,
|
|
193
193
|
]
|
|
194
194
|
}
|
|
195
195
|
testID="input-suffix"
|
|
196
196
|
themeIntent="text"
|
|
197
|
-
themeSize="
|
|
197
|
+
themeSize="medium"
|
|
198
198
|
/>
|
|
199
199
|
</View>
|
|
200
200
|
<View
|
|
@@ -34,11 +34,10 @@ const StyledBackdrop = styled(Animated.View)<
|
|
|
34
34
|
ComponentProps<typeof Animated.View>
|
|
35
35
|
>(({ theme }) => ({
|
|
36
36
|
position: 'absolute',
|
|
37
|
-
|
|
38
|
-
height: '100%',
|
|
39
|
-
width: '100%',
|
|
40
|
-
bottom: 0,
|
|
37
|
+
left: 0,
|
|
41
38
|
right: 0,
|
|
39
|
+
top: 0,
|
|
40
|
+
bottom: 0,
|
|
42
41
|
backgroundColor: theme.__hd__.fab.colors.backdropBackground,
|
|
43
42
|
}));
|
|
44
43
|
|
|
@@ -52,23 +51,10 @@ const StyledHeaderText = styled(Typography.Text)<TextProps>(({ theme }) => ({
|
|
|
52
51
|
textAlign: 'right',
|
|
53
52
|
}));
|
|
54
53
|
|
|
55
|
-
const StyledModalView = styled(View)({
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
flex: 1,
|
|
58
|
-
height: '100%',
|
|
59
|
-
width: '100%',
|
|
60
|
-
bottom: 0,
|
|
61
|
-
right: 0,
|
|
62
|
-
justifyContent: 'flex-end',
|
|
63
|
-
alignItems: 'flex-end',
|
|
64
|
-
backgroundColor: 'transparent',
|
|
65
|
-
});
|
|
66
|
-
|
|
67
54
|
export {
|
|
68
55
|
StyledHeaderText,
|
|
69
56
|
StyledBackdrop,
|
|
70
57
|
StyledContainer,
|
|
71
58
|
StyledActionGroupContainer,
|
|
72
59
|
StyledFAB,
|
|
73
|
-
StyledModalView,
|
|
74
60
|
};
|