react-native-ui-lib 7.37.2-snapshot.6126 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.37.2-snapshot.6126",
3
+ "version": "7.37.2-snapshot.6132",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -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