@hero-design/rn 8.59.0 → 8.60.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 +6 -0
- package/es/index.js +183 -102
- package/lib/index.js +183 -102
- package/package.json +1 -1
- package/src/components/AnimatedScroller/AnimatedFAB.tsx +99 -49
- package/src/components/AnimatedScroller/AnimatedScrollable.tsx +18 -3
- package/src/components/AnimatedScroller/__tests__/ScrollablesWithFAB.spec.tsx +30 -9
- package/src/components/AnimatedScroller/__tests__/__snapshots__/ScrollablesWithFAB.spec.tsx.snap +474 -447
- package/src/components/FAB/ActionGroup/ActionItem.tsx +3 -1
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +216 -211
- package/src/components/FAB/ActionGroup/index.tsx +34 -28
- package/src/components/FAB/FAB.tsx +102 -41
- package/src/components/FAB/StyledFAB.tsx +10 -8
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +34 -38
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +191 -170
- package/types/components/AnimatedScroller/AnimatedFAB.d.ts +3 -1
- package/types/components/AnimatedScroller/AnimatedScrollable.d.ts +1 -1
- package/types/components/FAB/StyledFAB.d.ts +4 -6
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
ScrollViewProps as RnScrollViewProps,
|
|
6
6
|
SectionListProps,
|
|
7
7
|
} from 'react-native';
|
|
8
|
+
import { ActionGroupProps } from '../FAB/ActionGroup';
|
|
8
9
|
import { FABProps } from '../FAB/FAB';
|
|
9
10
|
import AnimatedFAB from './AnimatedFAB';
|
|
10
|
-
import { ActionGroupProps } from '../FAB/ActionGroup';
|
|
11
11
|
|
|
12
12
|
export interface AnimatedScrollerProps<T> {
|
|
13
13
|
/**
|
|
@@ -27,6 +27,8 @@ function AnimatedScroller<T>({
|
|
|
27
27
|
fabProps,
|
|
28
28
|
}: AnimatedScrollerProps<T>) {
|
|
29
29
|
const contentOffsetY = React.useRef(new Animated.Value(0)).current;
|
|
30
|
+
const contentHeight = React.useRef(new Animated.Value(0)).current;
|
|
31
|
+
const layoutHeight = React.useRef(new Animated.Value(0)).current;
|
|
30
32
|
|
|
31
33
|
// Common props for all ScrollView, FlatList and SectionList.
|
|
32
34
|
const { onScroll, scrollEventThrottle } = ScrollComponent.props;
|
|
@@ -37,7 +39,15 @@ function AnimatedScroller<T>({
|
|
|
37
39
|
...ScrollComponent.props,
|
|
38
40
|
scrollEventThrottle: scrollEventThrottle || 100,
|
|
39
41
|
onScroll: Animated.event(
|
|
40
|
-
[
|
|
42
|
+
[
|
|
43
|
+
{
|
|
44
|
+
nativeEvent: {
|
|
45
|
+
contentOffset: { y: contentOffsetY },
|
|
46
|
+
contentSize: { height: contentHeight },
|
|
47
|
+
layoutMeasurement: { height: layoutHeight },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
41
51
|
{
|
|
42
52
|
useNativeDriver: false,
|
|
43
53
|
listener: onScroll,
|
|
@@ -46,7 +56,12 @@ function AnimatedScroller<T>({
|
|
|
46
56
|
})}
|
|
47
57
|
|
|
48
58
|
{!!fabProps && (
|
|
49
|
-
<AnimatedFAB
|
|
59
|
+
<AnimatedFAB
|
|
60
|
+
fabProps={fabProps}
|
|
61
|
+
contentOffsetY={contentOffsetY}
|
|
62
|
+
contentHeight={contentHeight}
|
|
63
|
+
layoutHeight={layoutHeight}
|
|
64
|
+
/>
|
|
50
65
|
)}
|
|
51
66
|
</>
|
|
52
67
|
);
|
|
@@ -125,17 +125,28 @@ describe('Scrollables With FAB', () => {
|
|
|
125
125
|
const fabProps =
|
|
126
126
|
fabComponent === 'FAB' ? defaultFabProps : defaultActionGroupProps;
|
|
127
127
|
|
|
128
|
+
const scrollConfig = {
|
|
129
|
+
contentSize: { height: 2000 },
|
|
130
|
+
layoutMeasurement: { height: 700, width: 400 },
|
|
131
|
+
};
|
|
132
|
+
|
|
128
133
|
const { getByText, queryByText, getByTestId, queryByTestId } =
|
|
129
134
|
renderWithTheme(<ScrollComponent fabProps={fabProps} />);
|
|
130
135
|
|
|
136
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
137
|
+
nativeEvent: {
|
|
138
|
+
...scrollConfig,
|
|
139
|
+
contentOffset: { y: 50 },
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
131
143
|
// Scrolling down
|
|
132
144
|
expect(getByText('Shout out')).toBeDefined();
|
|
133
145
|
|
|
134
146
|
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
135
147
|
nativeEvent: {
|
|
136
|
-
|
|
137
|
-
contentOffset: { y:
|
|
138
|
-
layoutMeasurement: { height: 2000, width: 400 },
|
|
148
|
+
...scrollConfig,
|
|
149
|
+
contentOffset: { y: 150 },
|
|
139
150
|
},
|
|
140
151
|
});
|
|
141
152
|
|
|
@@ -145,9 +156,8 @@ describe('Scrollables With FAB', () => {
|
|
|
145
156
|
|
|
146
157
|
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
147
158
|
nativeEvent: {
|
|
148
|
-
|
|
149
|
-
contentOffset: { y:
|
|
150
|
-
layoutMeasurement: { height: 2000, width: 400 },
|
|
159
|
+
...scrollConfig,
|
|
160
|
+
contentOffset: { y: 500 },
|
|
151
161
|
},
|
|
152
162
|
});
|
|
153
163
|
|
|
@@ -158,15 +168,26 @@ describe('Scrollables With FAB', () => {
|
|
|
158
168
|
// Scrolling up
|
|
159
169
|
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
160
170
|
nativeEvent: {
|
|
161
|
-
|
|
162
|
-
contentOffset: { y: -
|
|
163
|
-
layoutMeasurement: { height: 2000, width: 400 },
|
|
171
|
+
...scrollConfig,
|
|
172
|
+
contentOffset: { y: -150 },
|
|
164
173
|
},
|
|
165
174
|
});
|
|
166
175
|
|
|
167
176
|
// Collapsed
|
|
168
177
|
expect(queryByText('Shout out')).toBeNull();
|
|
169
178
|
expect(getByTestId('animated-fab-icon')).toBeDefined();
|
|
179
|
+
|
|
180
|
+
// Scrolling up to top
|
|
181
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
182
|
+
nativeEvent: {
|
|
183
|
+
...scrollConfig,
|
|
184
|
+
contentOffset: { y: 0 },
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Expanded
|
|
189
|
+
expect(getByText('Shout out')).toBeDefined();
|
|
190
|
+
expect(getByTestId('styled-fab-icon')).toBeDefined();
|
|
170
191
|
}
|
|
171
192
|
);
|
|
172
193
|
});
|