@hero-design/rn 8.56.0 → 8.57.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 +1 -1
- package/CHANGELOG.md +22 -0
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +5106 -4266
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +5105 -4265
- package/package.json +2 -1
- package/src/components/AnimatedScroller/__tests__/ScrollablesWithFAB.spec.tsx +172 -0
- package/src/components/AnimatedScroller/__tests__/__snapshots__/ScrollablesWithFAB.spec.tsx.snap +3435 -0
- package/src/components/Button/StyledButton.tsx +16 -30
- package/src/components/Carousel/CardCarousel.tsx +3 -4
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +4 -0
- package/src/components/PinInput/index.tsx +1 -1
- package/src/components/Tabs/SceneView.tsx +6 -4
- package/src/components/Tabs/ScrollableTabs.tsx +8 -2
- package/src/components/Tabs/{ScrollableTabsHeader.tsx → ScrollableTabsHeader/ScrollableTabsHeader.tsx} +73 -42
- package/src/components/Tabs/ScrollableTabsHeader/hooks/useInitHighlightedAnimation.ts +45 -0
- package/src/components/Tabs/ScrollableTabsHeader/hooks/useInitUnderlinedAnimation.ts +91 -0
- package/src/components/Tabs/StyledScrollableTabs.tsx +14 -3
- package/src/components/Tabs/__tests__/ScrollableTabsHeader.spec.tsx +7 -3
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +42 -6
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +623 -3
- package/src/components/Tabs/__tests__/useInitHighlightedAnimation.spec.tsx +56 -0
- package/src/components/Tabs/__tests__/useInitUnderlinedAnimation.spec.tsx +65 -0
- package/src/components/Typography/Body/__tests__/__snapshots__/StyledBody.tsx.snap +2 -2
- package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -1
- package/src/theme/components/typography.ts +1 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Tabs/ScrollableTabs.d.ts +4 -1
- package/types/components/Tabs/{ScrollableTabsHeader.d.ts → ScrollableTabsHeader/ScrollableTabsHeader.d.ts} +7 -3
- package/types/components/Tabs/ScrollableTabsHeader/hooks/useInitHighlightedAnimation.d.ts +9 -0
- package/types/components/Tabs/ScrollableTabsHeader/hooks/useInitUnderlinedAnimation.d.ts +10 -0
- package/types/components/Tabs/StyledScrollableTabs.d.ts +5 -1
- package/types/components/Tabs/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.57.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"jest-junit": "^16.0.0",
|
|
74
74
|
"prettier-config-hd": "8.42.4",
|
|
75
75
|
"react": "18.2.0",
|
|
76
|
+
"react-dom": "^18.2.0",
|
|
76
77
|
"react-native": "0.71.14",
|
|
77
78
|
"react-native-gesture-handler": "~2.5.0",
|
|
78
79
|
"react-native-linear-gradient": "^2.6.2",
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme } from '@emotion/react';
|
|
3
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
4
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
5
|
+
import { FlatListWithFAB, ScrollViewWithFAB, SectionListWithFAB } from '..';
|
|
6
|
+
import Box from '../../Box';
|
|
7
|
+
import { ActionGroupProps } from '../../FAB/ActionGroup';
|
|
8
|
+
import { FABProps } from '../../FAB/FAB';
|
|
9
|
+
import Typography from '../../Typography';
|
|
10
|
+
import { ScrollViewWithFABProps } from '../ScrollViewWithFAB';
|
|
11
|
+
import { FlatListWithFABProps } from '../FlatListWithFAB';
|
|
12
|
+
import SectionHeading from '../../SectionHeading';
|
|
13
|
+
|
|
14
|
+
const ExampleScrollViewWithFAB = ({ fabProps }: ScrollViewWithFABProps) => (
|
|
15
|
+
<ScrollViewWithFAB fabProps={fabProps} testID="scrollable-with-fab">
|
|
16
|
+
<Box style={{ height: 2000 }} justifyContent="space-between">
|
|
17
|
+
<Typography.Body>Content 1</Typography.Body>
|
|
18
|
+
<Typography.Body>Content 2</Typography.Body>
|
|
19
|
+
<Typography.Body>Content 3</Typography.Body>
|
|
20
|
+
</Box>
|
|
21
|
+
</ScrollViewWithFAB>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
function ExampleFlatListWithFAB<T>({ fabProps }: FlatListWithFABProps<T>) {
|
|
25
|
+
return (
|
|
26
|
+
<FlatListWithFAB
|
|
27
|
+
testID="scrollable-with-fab"
|
|
28
|
+
fabProps={fabProps}
|
|
29
|
+
data={Array.from({ length: 30 }, (_, i) => ({
|
|
30
|
+
id: i,
|
|
31
|
+
title: `Content ${i}`,
|
|
32
|
+
}))}
|
|
33
|
+
renderItem={({ item }) => (
|
|
34
|
+
<Box marginBottom="xxxxlarge">
|
|
35
|
+
<Typography.Title level="h5">{item.title}</Typography.Title>
|
|
36
|
+
<Typography.Body>Item {item.id}</Typography.Body>
|
|
37
|
+
</Box>
|
|
38
|
+
)}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ExampleSectionListWithFAB<T>({ fabProps }: FlatListWithFABProps<T>) {
|
|
44
|
+
const theme = useTheme();
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<SectionListWithFAB
|
|
48
|
+
testID="scrollable-with-fab"
|
|
49
|
+
fabProps={fabProps}
|
|
50
|
+
sections={[
|
|
51
|
+
{
|
|
52
|
+
title: 'Title 1',
|
|
53
|
+
data: ['Content 1', 'Content 2', 'Content 3', 'Content 4'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'Title 2',
|
|
57
|
+
data: ['Content 5', 'Content 6', 'Content 7'],
|
|
58
|
+
},
|
|
59
|
+
]}
|
|
60
|
+
renderSectionHeader={({ section: { title } }) => (
|
|
61
|
+
<SectionHeading text={title} />
|
|
62
|
+
)}
|
|
63
|
+
renderItem={({ item }) => (
|
|
64
|
+
<Typography.Title style={{ marginBottom: theme.space.xxxxlarge }}>
|
|
65
|
+
{item}
|
|
66
|
+
</Typography.Title>
|
|
67
|
+
)}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const defaultFabProps: FABProps = {
|
|
73
|
+
icon: 'speaker',
|
|
74
|
+
title: 'Shout out',
|
|
75
|
+
animated: true,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const defaultActionGroupProps: ActionGroupProps = {
|
|
79
|
+
fabTitle: 'Shout out',
|
|
80
|
+
items: [
|
|
81
|
+
{ icon: 'speaker', title: 'Announcements' },
|
|
82
|
+
{ icon: 'target', title: 'Goal' },
|
|
83
|
+
],
|
|
84
|
+
active: false,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
describe('Scrollables With FAB', () => {
|
|
88
|
+
it.each`
|
|
89
|
+
fabComponent | ScrollComponent
|
|
90
|
+
${'FAB'} | ${ExampleScrollViewWithFAB}
|
|
91
|
+
${'ActionGroup'} | ${ExampleScrollViewWithFAB}
|
|
92
|
+
${'FAB'} | ${ExampleFlatListWithFAB}
|
|
93
|
+
${'ActionGroup'} | ${ExampleFlatListWithFAB}
|
|
94
|
+
${'FAB'} | ${ExampleSectionListWithFAB}
|
|
95
|
+
${'ActionGroup'} | ${ExampleSectionListWithFAB}
|
|
96
|
+
`(
|
|
97
|
+
'$ScrollComponent renders $fabComponent correctly',
|
|
98
|
+
({ fabComponent, ScrollComponent }) => {
|
|
99
|
+
const fabProps =
|
|
100
|
+
fabComponent === 'FAB' ? defaultFabProps : defaultActionGroupProps;
|
|
101
|
+
|
|
102
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
103
|
+
<ScrollComponent fabProps={fabProps} />
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(toJSON()).toMatchSnapshot();
|
|
107
|
+
expect(getByText('Content 1')).toBeDefined();
|
|
108
|
+
expect(getByText('Content 2')).toBeDefined();
|
|
109
|
+
expect(getByText('Content 3')).toBeDefined();
|
|
110
|
+
expect(getByText('Shout out')).toBeDefined();
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
it.each`
|
|
115
|
+
fabComponent | ScrollComponent
|
|
116
|
+
${'FAB'} | ${ExampleScrollViewWithFAB}
|
|
117
|
+
${'ActionGroup'} | ${ExampleScrollViewWithFAB}
|
|
118
|
+
${'FAB'} | ${ExampleFlatListWithFAB}
|
|
119
|
+
${'ActionGroup'} | ${ExampleFlatListWithFAB}
|
|
120
|
+
${'FAB'} | ${ExampleSectionListWithFAB}
|
|
121
|
+
${'ActionGroup'} | ${ExampleSectionListWithFAB}
|
|
122
|
+
`(
|
|
123
|
+
'$ScrollComponent animates $fabComponent correctly',
|
|
124
|
+
({ fabComponent, ScrollComponent }) => {
|
|
125
|
+
const fabProps =
|
|
126
|
+
fabComponent === 'FAB' ? defaultFabProps : defaultActionGroupProps;
|
|
127
|
+
|
|
128
|
+
const { getByText, queryByText, getByTestId, queryByTestId } =
|
|
129
|
+
renderWithTheme(<ScrollComponent fabProps={fabProps} />);
|
|
130
|
+
|
|
131
|
+
// Scrolling down
|
|
132
|
+
expect(getByText('Shout out')).toBeDefined();
|
|
133
|
+
|
|
134
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
135
|
+
nativeEvent: {
|
|
136
|
+
contentSize: { height: 1000 },
|
|
137
|
+
contentOffset: { y: 10 },
|
|
138
|
+
layoutMeasurement: { height: 2000, width: 400 },
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Collapsed
|
|
143
|
+
expect(queryByText('Shout out')).toBeNull();
|
|
144
|
+
expect(getByTestId('animated-fab-icon')).toBeDefined();
|
|
145
|
+
|
|
146
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
147
|
+
nativeEvent: {
|
|
148
|
+
contentSize: { height: 1000 },
|
|
149
|
+
contentOffset: { y: 400 },
|
|
150
|
+
layoutMeasurement: { height: 2000, width: 400 },
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Hidden
|
|
155
|
+
expect(queryByText('Shout out')).toBeNull();
|
|
156
|
+
expect(queryByTestId('styled-fab-icon')).toBeNull();
|
|
157
|
+
|
|
158
|
+
// Scrolling up
|
|
159
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
160
|
+
nativeEvent: {
|
|
161
|
+
contentSize: { height: 1000 },
|
|
162
|
+
contentOffset: { y: -10 },
|
|
163
|
+
layoutMeasurement: { height: 2000, width: 400 },
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Collapsed
|
|
168
|
+
expect(queryByText('Shout out')).toBeNull();
|
|
169
|
+
expect(getByTestId('animated-fab-icon')).toBeDefined();
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
});
|