react-native-ui-lib 7.37.2-snapshot.6131 → 7.37.2-snapshot.6132
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/package.json +1 -1
- package/src/components/tabController/TabBar.js +1 -1
- package/src/components/tabController/TabBarContext.d.ts +1 -0
- package/src/components/tabController/TabBarItem.js +5 -2
- package/src/components/tabController/index.js +4 -1
- package/src/incubator/expandableOverlay/index.js +3 -12
package/package.json
CHANGED
|
@@ -149,7 +149,7 @@ const TabBar = props => {
|
|
|
149
149
|
}, [labelColor, selectedLabelColor]);
|
|
150
150
|
return <View style={_containerStyle} key={key} bg-$backgroundElevated>
|
|
151
151
|
<FadedScrollView ref={tabBar} horizontal showsHorizontalScrollIndicator={false} showStartFader startFaderProps={faderProps} showEndFader endFaderProps={faderProps} contentContainerStyle={scrollViewContainerStyle} testID={testID} onContentSizeChange={onContentSizeChange} onLayout={onLayout}>
|
|
152
|
-
<View style={tabBarContainerStyle}>{tabBarItems}</View>
|
|
152
|
+
<View style={tabBarContainerStyle} accessibilityRole="tablist">{tabBarItems}</View>
|
|
153
153
|
{itemsCount > 1 && <Reanimated.View style={[styles.selectedIndicator, indicatorStyle, _indicatorTransitionStyle]} />}
|
|
154
154
|
</FadedScrollView>
|
|
155
155
|
</View>;
|
|
@@ -13,6 +13,7 @@ interface TabControllerContext {
|
|
|
13
13
|
/** transition page index (can be a fraction when transitioning between pages) */
|
|
14
14
|
targetPage: Reanimated.SharedValue<number>;
|
|
15
15
|
setCurrentIndex: (index: number) => void;
|
|
16
|
+
selectedIndex: number;
|
|
16
17
|
}
|
|
17
18
|
declare const TabBarContext: React.Context<TabControllerContext>;
|
|
18
19
|
export default TabBarContext;
|
|
@@ -44,7 +44,8 @@ export default function TabBarItem({
|
|
|
44
44
|
}) {
|
|
45
45
|
const {
|
|
46
46
|
currentPage,
|
|
47
|
-
setCurrentIndex
|
|
47
|
+
setCurrentIndex,
|
|
48
|
+
selectedIndex
|
|
48
49
|
} = useContext(TabBarContext);
|
|
49
50
|
const itemRef = useRef();
|
|
50
51
|
const itemWidth = useRef(props.width);
|
|
@@ -133,7 +134,9 @@ export default function TabBarItem({
|
|
|
133
134
|
return <GestureDetector gesture={gesture}>
|
|
134
135
|
<View reanimated
|
|
135
136
|
// @ts-expect-error
|
|
136
|
-
ref={itemRef} style={_style} onLayout={onLayout} testID={testID}
|
|
137
|
+
ref={itemRef} style={_style} onLayout={onLayout} testID={testID} accessible accessibilityRole="tab" accessibilityState={{
|
|
138
|
+
selected: selectedIndex === index
|
|
139
|
+
}}>
|
|
137
140
|
{leadingAccessory}
|
|
138
141
|
{icon && <Reanimated.Image source={icon} style={[!_isUndefined(label) && styles.tabItemIconWithLabel, animatedIconStyle]} />}
|
|
139
142
|
{!_isEmpty(label) && <Reanimated.Text {...labelProps} fsTagName={'unmask'} style={[styles.tabItemLabel, labelStyle, animatedLabelStyle, animatedLabelColorStyle]}>
|
|
@@ -38,6 +38,7 @@ const TabController = React.forwardRef((props, ref) => {
|
|
|
38
38
|
children
|
|
39
39
|
} = themeProps;
|
|
40
40
|
const [screenWidth, setScreenWidth] = useState(getScreenWidth(useSafeArea));
|
|
41
|
+
const [selectedIndex, setSelectedIndex] = useState(initialIndex);
|
|
41
42
|
if (items?.length < 2) {
|
|
42
43
|
console.warn('TabController component expect a minimum of 2 items');
|
|
43
44
|
}
|
|
@@ -61,6 +62,7 @@ const TabController = React.forwardRef((props, ref) => {
|
|
|
61
62
|
'worklet';
|
|
62
63
|
|
|
63
64
|
currentPage.value = index;
|
|
65
|
+
runOnJS(setSelectedIndex)(index);
|
|
64
66
|
}, []);
|
|
65
67
|
useEffect(() => {
|
|
66
68
|
setCurrentIndex(initialIndex);
|
|
@@ -88,12 +90,13 @@ const TabController = React.forwardRef((props, ref) => {
|
|
|
88
90
|
/* Animated Values */
|
|
89
91
|
targetPage,
|
|
90
92
|
currentPage,
|
|
93
|
+
selectedIndex,
|
|
91
94
|
containerWidth: screenWidth,
|
|
92
95
|
/* Callbacks */
|
|
93
96
|
onChangeIndex,
|
|
94
97
|
setCurrentIndex
|
|
95
98
|
};
|
|
96
|
-
}, [initialIndex, asCarousel, items, onChangeIndex, screenWidth, nestedInScrollView]);
|
|
99
|
+
}, [initialIndex, asCarousel, items, onChangeIndex, screenWidth, nestedInScrollView, selectedIndex]);
|
|
97
100
|
return <TabBarContext.Provider value={context}>{children}</TabBarContext.Provider>;
|
|
98
101
|
});
|
|
99
102
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState, forwardRef, useImperativeHandle
|
|
2
|
-
import { AccessibilityInfo, findNodeHandle } from 'react-native';
|
|
1
|
+
import React, { useCallback, useState, forwardRef, useImperativeHandle } from 'react';
|
|
3
2
|
import TouchableOpacity from "../../components/touchableOpacity";
|
|
4
3
|
import View from "../../components/view";
|
|
5
4
|
import Modal from "../../components/modal";
|
|
@@ -24,22 +23,14 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
24
23
|
...others
|
|
25
24
|
} = props;
|
|
26
25
|
const [visible, setExpandableVisible] = useState(false);
|
|
27
|
-
const containerRef = useRef(null);
|
|
28
|
-
const focusAccessibility = useCallback(() => {
|
|
29
|
-
const reactTag = findNodeHandle(containerRef.current);
|
|
30
|
-
if (reactTag) {
|
|
31
|
-
AccessibilityInfo.setAccessibilityFocus(reactTag);
|
|
32
|
-
}
|
|
33
|
-
}, []);
|
|
34
26
|
const openExpandable = useCallback(() => {
|
|
35
27
|
setExpandableVisible(true);
|
|
36
28
|
onPress?.(props);
|
|
37
29
|
}, [onPress, customValue]);
|
|
38
30
|
const closeExpandable = useCallback(() => {
|
|
39
31
|
setExpandableVisible(false);
|
|
40
|
-
focusAccessibility();
|
|
41
32
|
useDialog ? dialogProps?.onDismiss?.() : modalProps?.onDismiss?.();
|
|
42
|
-
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss
|
|
33
|
+
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss]);
|
|
43
34
|
const toggleExpandable = useCallback(() => visible ? closeExpandable() : openExpandable(), [visible, openExpandable, closeExpandable]);
|
|
44
35
|
useImperativeHandle(ref, () => ({
|
|
45
36
|
openExpandable,
|
|
@@ -70,7 +61,7 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
70
61
|
return useDialog ? renderDialog() : renderModal();
|
|
71
62
|
}
|
|
72
63
|
};
|
|
73
|
-
return <TouchableOpacity
|
|
64
|
+
return <TouchableOpacity {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
|
|
74
65
|
<View pointerEvents="none">{children}</View>
|
|
75
66
|
{renderOverlay()}
|
|
76
67
|
</TouchableOpacity>;
|