@hero-design/rn 7.17.1 → 7.18.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 +2 -2
- package/es/index.js +3680 -3449
- package/lib/index.js +3684 -3451
- package/package.json +2 -2
- package/src/components/BottomNavigation/index.tsx +1 -1
- package/src/components/Button/Button.tsx +1 -0
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +2 -2
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
- package/src/components/Button/UtilityButton/{styled.tsx → StyledUtilityButton.tsx} +2 -2
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Button/UtilityButton/index.tsx +5 -1
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +14 -14
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +1 -0
- package/src/components/Drawer/DragableDrawer/__tests__/__snapshots__/index.spec.tsx.snap +99 -0
- package/src/components/Drawer/DragableDrawer/__tests__/helpers.spec.ts +39 -0
- package/src/components/Drawer/DragableDrawer/__tests__/index.spec.tsx +24 -0
- package/src/components/Drawer/DragableDrawer/helpers.ts +43 -0
- package/src/components/Drawer/DragableDrawer/index.tsx +205 -0
- package/src/components/Drawer/StyledDrawer.tsx +70 -26
- package/src/components/Drawer/index.tsx +4 -1
- package/src/components/Empty/StyledEmpty.tsx +4 -3
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
- package/src/components/Empty/index.tsx +2 -2
- package/src/components/FAB/ActionGroup/index.tsx +1 -1
- package/src/components/List/ListItem.tsx +1 -1
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/Select/MultiSelect/index.tsx +1 -4
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/Select/SingleSelect/index.tsx +2 -6
- package/src/components/Tabs/ScrollableTabs.tsx +1 -1
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +8 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +79 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +79 -0
- package/src/components/Tabs/__tests__/index.spec.tsx +8 -0
- package/src/components/Tabs/index.tsx +8 -3
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +1 -1
- package/src/components/TextInput/StyledTextInput.tsx +1 -0
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +13 -0
- package/src/components/TextInput/index.tsx +2 -2
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +1 -0
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -0
- package/src/index.ts +9 -1
- package/src/theme/ThemeProvider.ts +19 -0
- package/src/theme/ThemeSwitcher.tsx +27 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +25 -12
- package/src/theme/components/button.ts +9 -8
- package/src/theme/components/drawer.ts +14 -2
- package/src/theme/components/empty.ts +3 -2
- package/src/theme/getTheme.ts +129 -0
- package/src/theme/global/{colors.ts → colors/swag.ts} +8 -5
- package/src/theme/global/colors/types.ts +45 -0
- package/src/theme/global/colors/work.ts +14 -0
- package/src/theme/global/index.ts +6 -2
- package/src/theme/index.ts +16 -143
- package/src/utils/scale.ts +4 -1
- package/types/components/Button/Button.d.ts +1 -0
- package/types/components/Button/UtilityButton/{styled.d.ts → StyledUtilityButton.d.ts} +0 -0
- package/types/components/Drawer/DragableDrawer/__tests__/helpers.spec.d.ts +1 -0
- package/types/components/Drawer/DragableDrawer/__tests__/index.spec.d.ts +1 -0
- package/types/components/Drawer/DragableDrawer/helpers.d.ts +8 -0
- package/types/components/Drawer/DragableDrawer/index.d.ts +33 -0
- package/types/components/Drawer/StyledDrawer.d.ts +34 -4
- package/types/components/Drawer/index.d.ts +4 -2
- package/types/components/Empty/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/index.d.ts +2 -2
- package/types/theme/ThemeProvider.d.ts +12 -0
- package/types/theme/ThemeSwitcher.d.ts +7 -0
- package/types/theme/components/button.d.ts +1 -1
- package/types/theme/components/drawer.d.ts +9 -0
- package/types/theme/components/empty.d.ts +3 -2
- package/types/theme/getTheme.d.ts +74 -0
- package/types/theme/global/colors/swag.d.ts +3 -0
- package/types/theme/global/{colors.d.ts → colors/types.d.ts} +4 -3
- package/types/theme/global/colors/work.d.ts +3 -0
- package/types/theme/global/index.d.ts +7 -2
- package/types/theme/index.d.ts +7 -84
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React, { ReactNode, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Animated, PanResponder, Easing } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
StyledDragableContainer,
|
|
6
|
+
StyledDragableDrawerContainer,
|
|
7
|
+
StyledHandler,
|
|
8
|
+
StyledHandlerContainer,
|
|
9
|
+
} from '../StyledDrawer';
|
|
10
|
+
import {
|
|
11
|
+
calculateAnimatedToValue,
|
|
12
|
+
calculateSnapPointsData,
|
|
13
|
+
getOffset,
|
|
14
|
+
SnapPointsData,
|
|
15
|
+
} from './helpers';
|
|
16
|
+
|
|
17
|
+
export interface DragableDrawerProps {
|
|
18
|
+
/**
|
|
19
|
+
* Drawer's content.
|
|
20
|
+
*/
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Initial visible height percentage of the drawer. Can be used to programmatically control the drawer height. Range: [0,100].
|
|
24
|
+
*/
|
|
25
|
+
initialHeightPercentage?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Mininum visible height percentage of the drawer. This will be the lowest point in snap points list. Range: [0,100].
|
|
28
|
+
*/
|
|
29
|
+
minimumHeightPercentage?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Callback function is called when the drawer expand to max position.
|
|
32
|
+
*/
|
|
33
|
+
onExpanded?: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Callback function is called when the drawer collapsed to min position.
|
|
36
|
+
*/
|
|
37
|
+
onCollapsed?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Testing id of the component.
|
|
40
|
+
*/
|
|
41
|
+
testID?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Nearest height snap points that the drawer will attach to on release gesture. Range: [0,100]
|
|
44
|
+
*/
|
|
45
|
+
snapPoints?: number[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const DragableDrawer = ({
|
|
49
|
+
children,
|
|
50
|
+
initialHeightPercentage,
|
|
51
|
+
minimumHeightPercentage = 10,
|
|
52
|
+
snapPoints = [],
|
|
53
|
+
onExpanded,
|
|
54
|
+
onCollapsed,
|
|
55
|
+
testID,
|
|
56
|
+
}: DragableDrawerProps): JSX.Element => {
|
|
57
|
+
const [height, setHeight] = useState(0);
|
|
58
|
+
const baseHeightForMeasure = useRef(0);
|
|
59
|
+
const snapPointsData = useRef<SnapPointsData>({
|
|
60
|
+
list: [],
|
|
61
|
+
minHeightOffset: 0,
|
|
62
|
+
maxHeightOffset: 0,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Track drag
|
|
66
|
+
const pan = useRef(new Animated.Value(0)).current;
|
|
67
|
+
const offset = useRef(0);
|
|
68
|
+
const offsetBeforePan = useRef(0);
|
|
69
|
+
const [animatedToValue, setAnimatedToValue] = useState<number>(-1);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const id = pan.addListener(({ value }) => {
|
|
73
|
+
offset.current = value;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return () => pan.removeListener(id);
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (height > 0) {
|
|
81
|
+
const initialOffset = getOffset(
|
|
82
|
+
height,
|
|
83
|
+
initialHeightPercentage || minimumHeightPercentage
|
|
84
|
+
);
|
|
85
|
+
setAnimatedToValue(initialOffset);
|
|
86
|
+
}
|
|
87
|
+
}, [height]);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (height > 0) {
|
|
91
|
+
pan.setValue(height);
|
|
92
|
+
offset.current = height;
|
|
93
|
+
|
|
94
|
+
baseHeightForMeasure.current = height;
|
|
95
|
+
|
|
96
|
+
// Calculate snap points information
|
|
97
|
+
snapPointsData.current = calculateSnapPointsData(
|
|
98
|
+
minimumHeightPercentage,
|
|
99
|
+
height,
|
|
100
|
+
snapPoints
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}, [height, minimumHeightPercentage]);
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (animatedToValue >= 0) {
|
|
107
|
+
const animation = Animated.timing(pan, {
|
|
108
|
+
toValue: animatedToValue,
|
|
109
|
+
useNativeDriver: true,
|
|
110
|
+
easing: Easing.inOut(Easing.cubic),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
animation.start(() => {
|
|
114
|
+
if (animatedToValue === 0) {
|
|
115
|
+
onExpanded?.();
|
|
116
|
+
} else if (
|
|
117
|
+
animatedToValue === getOffset(height, minimumHeightPercentage)
|
|
118
|
+
) {
|
|
119
|
+
onCollapsed?.();
|
|
120
|
+
}
|
|
121
|
+
setAnimatedToValue(-1);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return () => animation.stop();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return () => {};
|
|
128
|
+
}, [animatedToValue]);
|
|
129
|
+
|
|
130
|
+
const panResponder = useRef(
|
|
131
|
+
PanResponder.create({
|
|
132
|
+
onMoveShouldSetPanResponder: () => true,
|
|
133
|
+
onPanResponderGrant: () => {
|
|
134
|
+
offsetBeforePan.current = offset.current;
|
|
135
|
+
pan.setOffset(offset.current);
|
|
136
|
+
pan.setValue(0);
|
|
137
|
+
},
|
|
138
|
+
onPanResponderMove: (_, gesture) => {
|
|
139
|
+
const panDistance = gesture.dy;
|
|
140
|
+
|
|
141
|
+
// Moving toward top, stop at highest snap point
|
|
142
|
+
if (offsetBeforePan.current + panDistance < 0) {
|
|
143
|
+
pan.setValue(-offsetBeforePan.current);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Moving toward bottom, stop at lowest snap point
|
|
148
|
+
if (
|
|
149
|
+
offsetBeforePan.current + panDistance >
|
|
150
|
+
snapPointsData.current?.minHeightOffset
|
|
151
|
+
) {
|
|
152
|
+
pan.setValue(
|
|
153
|
+
baseHeightForMeasure.current -
|
|
154
|
+
baseHeightForMeasure.current * (minimumHeightPercentage / 100) -
|
|
155
|
+
offsetBeforePan.current
|
|
156
|
+
);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
pan.setValue(panDistance);
|
|
161
|
+
},
|
|
162
|
+
onPanResponderRelease: (_, gesture) => {
|
|
163
|
+
pan.flattenOffset();
|
|
164
|
+
|
|
165
|
+
// Attach to nearest snappoint
|
|
166
|
+
const panDistance = gesture.dy;
|
|
167
|
+
const offsetAfterPan = offsetBeforePan.current + panDistance;
|
|
168
|
+
const animatedValue = calculateAnimatedToValue(
|
|
169
|
+
offsetAfterPan,
|
|
170
|
+
snapPointsData.current.list
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
setAnimatedToValue(animatedValue);
|
|
174
|
+
},
|
|
175
|
+
})
|
|
176
|
+
).current;
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<StyledDragableContainer
|
|
180
|
+
testID={testID}
|
|
181
|
+
enableShadow
|
|
182
|
+
pointerEvents="box-none"
|
|
183
|
+
>
|
|
184
|
+
<StyledDragableDrawerContainer
|
|
185
|
+
enableShadow
|
|
186
|
+
style={{
|
|
187
|
+
transform: [
|
|
188
|
+
{ scaleY: baseHeightForMeasure.current > 0 ? 1 : 0 },
|
|
189
|
+
{ translateY: pan },
|
|
190
|
+
],
|
|
191
|
+
}}
|
|
192
|
+
onLayout={({ nativeEvent }) => {
|
|
193
|
+
setHeight(nativeEvent.layout.height);
|
|
194
|
+
}}
|
|
195
|
+
>
|
|
196
|
+
<StyledHandlerContainer {...panResponder.panHandlers}>
|
|
197
|
+
<StyledHandler />
|
|
198
|
+
</StyledHandlerContainer>
|
|
199
|
+
{children}
|
|
200
|
+
</StyledDragableDrawerContainer>
|
|
201
|
+
</StyledDragableContainer>
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export default DragableDrawer;
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
2
|
import { ComponentProps } from 'react';
|
|
3
|
-
import { Animated, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Animated, Pressable, StyleSheet, View, ViewProps } from 'react-native';
|
|
4
4
|
|
|
5
5
|
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
6
6
|
|
|
7
|
-
const StyledContainer = styled(View)<{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
7
|
+
const StyledContainer = styled(View)<{
|
|
8
|
+
enableShadow: boolean;
|
|
9
|
+
}>(({ theme, enableShadow }) => ({
|
|
10
|
+
...StyleSheet.absoluteFillObject,
|
|
11
|
+
shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
|
|
12
|
+
shadowOffset: theme.__hd__.drawer.shadows.offset,
|
|
13
|
+
shadowOpacity: theme.__hd__.drawer.shadows.opacity,
|
|
14
|
+
shadowRadius: theme.__hd__.drawer.shadows.radius,
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
zIndex: 9999,
|
|
17
|
+
elevation: 9999,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const StyledDragableContainer = styled(View)<{
|
|
21
|
+
enableShadow: boolean;
|
|
22
|
+
}>(({ theme, enableShadow }) => ({
|
|
23
|
+
...StyleSheet.absoluteFillObject,
|
|
24
|
+
shadowColor: enableShadow ? theme.__hd__.drawer.colors.shadow : 'transparent',
|
|
25
|
+
shadowOffset: theme.__hd__.drawer.shadows.offset,
|
|
26
|
+
shadowOpacity: theme.__hd__.drawer.shadows.opacity,
|
|
27
|
+
shadowRadius: theme.__hd__.drawer.shadows.radius,
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
zIndex: 9999,
|
|
30
|
+
elevation: 9999,
|
|
31
|
+
flexDirection: 'column-reverse',
|
|
32
|
+
}));
|
|
21
33
|
|
|
22
34
|
const StyledBackdrop = styled(AnimatedPressable)<
|
|
23
35
|
ComponentProps<typeof AnimatedPressable>
|
|
@@ -26,14 +38,46 @@ const StyledBackdrop = styled(AnimatedPressable)<
|
|
|
26
38
|
backgroundColor: theme.__hd__.drawer.colors.backdrop,
|
|
27
39
|
}));
|
|
28
40
|
|
|
29
|
-
const StyledDrawerContainer = styled(Animated.View)<{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const StyledDrawerContainer = styled(Animated.View)<{
|
|
42
|
+
enableShadow: boolean;
|
|
43
|
+
}>(({ theme, enableShadow }) => ({
|
|
44
|
+
borderBottomLeftRadius: theme.__hd__.drawer.radii.default,
|
|
45
|
+
borderBottomRightRadius: theme.__hd__.drawer.radii.default,
|
|
46
|
+
backgroundColor: theme.__hd__.drawer.colors.background,
|
|
47
|
+
elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
|
|
48
|
+
overflow: 'hidden',
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const StyledDragableDrawerContainer = styled(Animated.View)<{
|
|
52
|
+
enableShadow: boolean;
|
|
53
|
+
}>(({ theme, enableShadow }) => ({
|
|
54
|
+
borderTopLeftRadius: theme.__hd__.drawer.radii.default,
|
|
55
|
+
borderTopRightRadius: theme.__hd__.drawer.radii.default,
|
|
56
|
+
backgroundColor: theme.__hd__.drawer.colors.background,
|
|
57
|
+
elevation: enableShadow ? theme.__hd__.drawer.shadows.elevation : undefined,
|
|
58
|
+
overflow: 'hidden',
|
|
59
|
+
maxHeight: '100%',
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
const StyledHandlerContainer = styled(View)<ViewProps>(({ theme }) => ({
|
|
63
|
+
backgroundColor: theme.__hd__.drawer.colors.background,
|
|
64
|
+
paddingVertical: theme.__hd__.drawer.space.handlerPaddingVertical,
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
const StyledHandler = styled(View)<{ active?: boolean }>(({ theme }) => ({
|
|
69
|
+
width: theme.__hd__.drawer.sizes.handlerWidth,
|
|
70
|
+
height: theme.__hd__.drawer.sizes.handlerHeight,
|
|
71
|
+
backgroundColor: theme.__hd__.drawer.colors.handler,
|
|
72
|
+
borderRadius: theme.__hd__.drawer.radii.handler,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
StyledBackdrop,
|
|
77
|
+
StyledContainer,
|
|
78
|
+
StyledDrawerContainer,
|
|
79
|
+
StyledHandlerContainer,
|
|
80
|
+
StyledHandler,
|
|
81
|
+
StyledDragableContainer,
|
|
82
|
+
StyledDragableDrawerContainer,
|
|
83
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Animated, Easing } from 'react-native';
|
|
3
|
+
import DragableDrawer from './DragableDrawer';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
StyledBackdrop,
|
|
@@ -90,4 +91,6 @@ const Drawer = ({
|
|
|
90
91
|
);
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
export default Drawer
|
|
94
|
+
export default Object.assign(Drawer, {
|
|
95
|
+
Dragable: DragableDrawer,
|
|
96
|
+
});
|
|
@@ -3,12 +3,13 @@ import styled from '@emotion/native';
|
|
|
3
3
|
|
|
4
4
|
type ThemeVariant = 'light' | 'dark';
|
|
5
5
|
|
|
6
|
-
const StyledWrapper = styled(View)(() => ({
|
|
6
|
+
const StyledWrapper = styled(View)(({ theme }) => ({
|
|
7
7
|
display: 'flex',
|
|
8
8
|
flex: 1,
|
|
9
9
|
flexDirection: 'column',
|
|
10
10
|
alignItems: 'center',
|
|
11
11
|
justifyContent: 'center',
|
|
12
|
+
padding: theme.__hd__.empty.space.wrapperPadding,
|
|
12
13
|
}));
|
|
13
14
|
|
|
14
15
|
const StyledIllustration = styled(View)(({ theme }) => ({
|
|
@@ -16,7 +17,7 @@ const StyledIllustration = styled(View)(({ theme }) => ({
|
|
|
16
17
|
width: theme.__hd__.empty.sizes.illustration,
|
|
17
18
|
borderRadius: theme.__hd__.empty.radii.illustration,
|
|
18
19
|
backgroundColor: theme.__hd__.empty.colors.illustrationBackground,
|
|
19
|
-
marginBottom: theme.__hd__.empty.space.
|
|
20
|
+
marginBottom: theme.__hd__.empty.space.illustrationMargin,
|
|
20
21
|
}));
|
|
21
22
|
|
|
22
23
|
const StyledTitle = styled(Text)<{ themeVariant: ThemeVariant }>(
|
|
@@ -24,7 +25,7 @@ const StyledTitle = styled(Text)<{ themeVariant: ThemeVariant }>(
|
|
|
24
25
|
fontFamily: theme.__hd__.empty.fonts.title,
|
|
25
26
|
fontSize: theme.__hd__.empty.fontSizes.title,
|
|
26
27
|
textAlign: 'center',
|
|
27
|
-
marginBottom: theme.__hd__.empty.space.
|
|
28
|
+
marginBottom: theme.__hd__.empty.space.titleMargin,
|
|
28
29
|
color:
|
|
29
30
|
themeVariant === 'dark'
|
|
30
31
|
? theme.__hd__.empty.colors.invertedText
|
|
@@ -19,7 +19,7 @@ interface EmptyProps {
|
|
|
19
19
|
description?: string;
|
|
20
20
|
/**
|
|
21
21
|
* Empty's variant
|
|
22
|
-
* 'dark' if rendered on a dark background and '
|
|
22
|
+
* 'dark' if rendered on a dark background and 'light' otherwise
|
|
23
23
|
*/
|
|
24
24
|
variant?: 'light' | 'dark';
|
|
25
25
|
/**
|
|
@@ -42,7 +42,7 @@ const Empty = ({
|
|
|
42
42
|
<StyledWrapper style={style} testID={testID}>
|
|
43
43
|
<StyledIllustration />
|
|
44
44
|
<StyledTitle themeVariant={variant}>{title}</StyledTitle>
|
|
45
|
-
{description && (
|
|
45
|
+
{!!description && (
|
|
46
46
|
<StyledDescription themeVariant={variant}>
|
|
47
47
|
{description}
|
|
48
48
|
</StyledDescription>
|
|
@@ -52,6 +52,7 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
|
|
|
52
52
|
"alignSelf": "stretch",
|
|
53
53
|
"flexDirection": "row",
|
|
54
54
|
"flexGrow": 2,
|
|
55
|
+
"flexShrink": 1,
|
|
55
56
|
},
|
|
56
57
|
undefined,
|
|
57
58
|
]
|
|
@@ -315,6 +316,7 @@ exports[`RichTextEditor should render correctly 1`] = `
|
|
|
315
316
|
"alignSelf": "stretch",
|
|
316
317
|
"flexDirection": "row",
|
|
317
318
|
"flexGrow": 2,
|
|
319
|
+
"flexShrink": 1,
|
|
318
320
|
},
|
|
319
321
|
undefined,
|
|
320
322
|
]
|
|
@@ -71,6 +71,7 @@ Array [
|
|
|
71
71
|
"alignSelf": "stretch",
|
|
72
72
|
"flexDirection": "row",
|
|
73
73
|
"flexGrow": 2,
|
|
74
|
+
"flexShrink": 1,
|
|
74
75
|
},
|
|
75
76
|
undefined,
|
|
76
77
|
]
|
|
@@ -1438,6 +1439,7 @@ Array [
|
|
|
1438
1439
|
"alignSelf": "stretch",
|
|
1439
1440
|
"flexDirection": "row",
|
|
1440
1441
|
"flexGrow": 2,
|
|
1442
|
+
"flexShrink": 1,
|
|
1441
1443
|
},
|
|
1442
1444
|
undefined,
|
|
1443
1445
|
]
|
|
@@ -2954,6 +2956,7 @@ Array [
|
|
|
2954
2956
|
"alignSelf": "stretch",
|
|
2955
2957
|
"flexDirection": "row",
|
|
2956
2958
|
"flexGrow": 2,
|
|
2959
|
+
"flexShrink": 1,
|
|
2957
2960
|
},
|
|
2958
2961
|
undefined,
|
|
2959
2962
|
]
|
|
@@ -4465,6 +4468,7 @@ Array [
|
|
|
4465
4468
|
"alignSelf": "stretch",
|
|
4466
4469
|
"flexDirection": "row",
|
|
4467
4470
|
"flexGrow": 2,
|
|
4471
|
+
"flexShrink": 1,
|
|
4468
4472
|
},
|
|
4469
4473
|
undefined,
|
|
4470
4474
|
]
|
|
@@ -5995,6 +5999,7 @@ Array [
|
|
|
5995
5999
|
"alignSelf": "stretch",
|
|
5996
6000
|
"flexDirection": "row",
|
|
5997
6001
|
"flexGrow": 2,
|
|
6002
|
+
"flexShrink": 1,
|
|
5998
6003
|
},
|
|
5999
6004
|
undefined,
|
|
6000
6005
|
]
|
|
@@ -82,10 +82,7 @@ function MultiSelect<V, T extends OptionType<V>>({
|
|
|
82
82
|
<BottomSheet
|
|
83
83
|
open={open}
|
|
84
84
|
onRequestClose={() => setOpen(false)}
|
|
85
|
-
onDismiss={
|
|
86
|
-
setSelectingValue(value);
|
|
87
|
-
if (onDimiss) onDimiss();
|
|
88
|
-
}}
|
|
85
|
+
onDismiss={onDimiss}
|
|
89
86
|
header={label}
|
|
90
87
|
style={{
|
|
91
88
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
@@ -71,6 +71,7 @@ Array [
|
|
|
71
71
|
"alignSelf": "stretch",
|
|
72
72
|
"flexDirection": "row",
|
|
73
73
|
"flexGrow": 2,
|
|
74
|
+
"flexShrink": 1,
|
|
74
75
|
},
|
|
75
76
|
undefined,
|
|
76
77
|
]
|
|
@@ -1366,6 +1367,7 @@ Array [
|
|
|
1366
1367
|
"alignSelf": "stretch",
|
|
1367
1368
|
"flexDirection": "row",
|
|
1368
1369
|
"flexGrow": 2,
|
|
1370
|
+
"flexShrink": 1,
|
|
1369
1371
|
},
|
|
1370
1372
|
undefined,
|
|
1371
1373
|
]
|
|
@@ -2759,6 +2761,7 @@ Array [
|
|
|
2759
2761
|
"alignSelf": "stretch",
|
|
2760
2762
|
"flexDirection": "row",
|
|
2761
2763
|
"flexGrow": 2,
|
|
2764
|
+
"flexShrink": 1,
|
|
2762
2765
|
},
|
|
2763
2766
|
undefined,
|
|
2764
2767
|
]
|
|
@@ -4149,6 +4152,7 @@ Array [
|
|
|
4149
4152
|
"alignSelf": "stretch",
|
|
4150
4153
|
"flexDirection": "row",
|
|
4151
4154
|
"flexGrow": 2,
|
|
4155
|
+
"flexShrink": 1,
|
|
4152
4156
|
},
|
|
4153
4157
|
undefined,
|
|
4154
4158
|
]
|
|
@@ -5556,6 +5560,7 @@ Array [
|
|
|
5556
5560
|
"alignSelf": "stretch",
|
|
5557
5561
|
"flexDirection": "row",
|
|
5558
5562
|
"flexGrow": 2,
|
|
5563
|
+
"flexShrink": 1,
|
|
5559
5564
|
},
|
|
5560
5565
|
undefined,
|
|
5561
5566
|
]
|
|
@@ -41,7 +41,6 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
41
41
|
}: SingleSelectProps<V, T>) => {
|
|
42
42
|
const { isKeyboardVisible, keyboardHeight } = useKeyboard();
|
|
43
43
|
const [open, setOpen] = useState(false);
|
|
44
|
-
const [selectingValue, setSelectingValue] = useState<V | null>(value);
|
|
45
44
|
const sections = toSections(options);
|
|
46
45
|
const flatOptions = toFlatOptions(options);
|
|
47
46
|
const displayedValue = flatOptions.find(opt => value === opt.value)?.text;
|
|
@@ -73,10 +72,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
73
72
|
<BottomSheet
|
|
74
73
|
open={open}
|
|
75
74
|
onRequestClose={() => setOpen(false)}
|
|
76
|
-
onDismiss={
|
|
77
|
-
setSelectingValue(value);
|
|
78
|
-
if (onDimiss) onDimiss();
|
|
79
|
-
}}
|
|
75
|
+
onDismiss={onDimiss}
|
|
80
76
|
header={label}
|
|
81
77
|
style={{
|
|
82
78
|
paddingBottom: isKeyboardVisible ? keyboardHeight : 0,
|
|
@@ -99,7 +95,7 @@ const SingleSelect = <V, T extends OptionType<V>>({
|
|
|
99
95
|
loading={loading}
|
|
100
96
|
sections={sections}
|
|
101
97
|
renderOption={renderOption}
|
|
102
|
-
value={
|
|
98
|
+
value={value}
|
|
103
99
|
onPress={selectedValue => {
|
|
104
100
|
setOpen(false);
|
|
105
101
|
onConfirm(selectedValue);
|
|
@@ -79,6 +79,7 @@ const ScrollableTab = ({
|
|
|
79
79
|
index: selectedTabIndex,
|
|
80
80
|
viewPosition: 0.5,
|
|
81
81
|
});
|
|
82
|
+
pagerViewRef.current?.setPage(selectedTabIndex);
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
const animation = Animated.parallel([
|
|
@@ -149,7 +150,6 @@ const ScrollableTab = ({
|
|
|
149
150
|
key={key}
|
|
150
151
|
onPress={() => {
|
|
151
152
|
onTabPress(key);
|
|
152
|
-
pagerViewRef.current?.setPage(index);
|
|
153
153
|
}}
|
|
154
154
|
testID={testID}
|
|
155
155
|
>
|
|
@@ -4,6 +4,7 @@ import { fireEvent } from '@testing-library/react-native';
|
|
|
4
4
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
5
5
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
6
6
|
import Tabs, { TabType } from '..';
|
|
7
|
+
import Button from '../../Button';
|
|
7
8
|
|
|
8
9
|
const TestTabsComponent = (
|
|
9
10
|
props: Omit<
|
|
@@ -40,6 +41,11 @@ const TestTabsComponent = (
|
|
|
40
41
|
insets: { top: 0, left: 0, right: 0, bottom: 0 },
|
|
41
42
|
}}
|
|
42
43
|
>
|
|
44
|
+
<Button.Utility
|
|
45
|
+
text="Move to Work"
|
|
46
|
+
onPress={() => setSelectedTabKey('work')}
|
|
47
|
+
icon="sync"
|
|
48
|
+
/>
|
|
43
49
|
<Tabs.Scroll
|
|
44
50
|
{...props}
|
|
45
51
|
tabs={tabs}
|
|
@@ -65,6 +71,8 @@ describe('Tabs.Scroll', () => {
|
|
|
65
71
|
expect(getByText('Personal Screen')).toBeDefined();
|
|
66
72
|
fireEvent.press(getByTestId('hero-icon-home-outlined'));
|
|
67
73
|
expect(getByText('Home Screen')).toBeDefined();
|
|
74
|
+
fireEvent.press(getByText('Move to Work'));
|
|
75
|
+
expect(getByText('Work Screen')).toBeDefined();
|
|
68
76
|
});
|
|
69
77
|
|
|
70
78
|
it('renders correctly with lazy preloaded', () => {
|
|
@@ -12,6 +12,85 @@ exports[`Tabs.Scroll renders correctly 1`] = `
|
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
>
|
|
15
|
+
<View
|
|
16
|
+
accessible={true}
|
|
17
|
+
collapsable={false}
|
|
18
|
+
focusable={true}
|
|
19
|
+
nativeID="animatedComponent"
|
|
20
|
+
onClick={[Function]}
|
|
21
|
+
onResponderGrant={[Function]}
|
|
22
|
+
onResponderMove={[Function]}
|
|
23
|
+
onResponderRelease={[Function]}
|
|
24
|
+
onResponderTerminate={[Function]}
|
|
25
|
+
onResponderTerminationRequest={[Function]}
|
|
26
|
+
onStartShouldSetResponder={[Function]}
|
|
27
|
+
style={
|
|
28
|
+
Object {
|
|
29
|
+
"alignItems": "center",
|
|
30
|
+
"backgroundColor": "#f6f6f7",
|
|
31
|
+
"borderRadius": 8,
|
|
32
|
+
"flexDirection": "row",
|
|
33
|
+
"justifyContent": "center",
|
|
34
|
+
"opacity": 1,
|
|
35
|
+
"padding": 8,
|
|
36
|
+
"width": "100%",
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
<View
|
|
41
|
+
style={
|
|
42
|
+
Array [
|
|
43
|
+
Object {
|
|
44
|
+
"paddingRight": 12,
|
|
45
|
+
},
|
|
46
|
+
undefined,
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
<HeroIcon
|
|
51
|
+
name="sync"
|
|
52
|
+
style={
|
|
53
|
+
Array [
|
|
54
|
+
Object {
|
|
55
|
+
"color": "#001f23",
|
|
56
|
+
"fontSize": 24,
|
|
57
|
+
},
|
|
58
|
+
undefined,
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
testID="undefined-icon"
|
|
62
|
+
themeIntent="text"
|
|
63
|
+
themeSize="medium"
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
<Text
|
|
67
|
+
style={
|
|
68
|
+
Array [
|
|
69
|
+
Object {
|
|
70
|
+
"color": "#001f23",
|
|
71
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
72
|
+
"fontSize": 14,
|
|
73
|
+
"letterSpacing": 0.42,
|
|
74
|
+
"lineHeight": 22,
|
|
75
|
+
},
|
|
76
|
+
Array [
|
|
77
|
+
Object {
|
|
78
|
+
"flexShrink": 1,
|
|
79
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
80
|
+
"fontSize": 16,
|
|
81
|
+
"textAlign": "center",
|
|
82
|
+
},
|
|
83
|
+
undefined,
|
|
84
|
+
],
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
themeFontSize="medium"
|
|
88
|
+
themeFontWeight="regular"
|
|
89
|
+
themeIntent="body"
|
|
90
|
+
>
|
|
91
|
+
Move to Work
|
|
92
|
+
</Text>
|
|
93
|
+
</View>
|
|
15
94
|
<View
|
|
16
95
|
style={
|
|
17
96
|
Array [
|