@artsy/palette-mobile 17.10.0 → 17.11.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.
@@ -1,9 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { debounce } from "lodash";
3
2
  import { useState } from "react";
4
3
  import { Platform } from "react-native";
5
4
  import { Tabs as BaseTabs, MaterialTabBar, MaterialTabItem, } from "react-native-collapsible-tab-view";
6
- import { runOnJS, useAnimatedReaction } from "react-native-reanimated";
7
5
  import { DEFAULT_ACTIVE_OPACITY } from "../../constants";
8
6
  import { useColor } from "../../utils/hooks/useColor";
9
7
  import { useSpace } from "../../utils/hooks/useSpace";
@@ -11,13 +9,7 @@ import { Box } from "../Box";
11
9
  import { Flex } from "../Flex";
12
10
  import { Pill } from "../Pill";
13
11
  const TAB_BAR_HEIGHT = 50;
14
- const PillTabItem = ({ focusedTab: focusedTabProp, ...props }) => {
15
- const [focusedTab, setFocusedTab] = useState(focusedTabProp.value);
16
- // We want to debounce the focusedTab value to avoid showing two pills at once
17
- const debouncedFocusedTab = debounce(setFocusedTab, 50);
18
- useAnimatedReaction(() => focusedTabProp.value, (value) => {
19
- runOnJS(debouncedFocusedTab)(value);
20
- });
12
+ const PillTabItem = ({ focusedTab, ...props }) => {
21
13
  return (_jsx(Pill, { selected: props.name === focusedTab, onPress: () => {
22
14
  props.onTabPress?.(props.name);
23
15
  }, variant: "link", children: props.name }, props.name));
@@ -31,6 +23,7 @@ const DefaultTabItem = (props) => {
31
23
  export const TabsContainer = ({ children, indicators = [], initialTabName, onTabPress, renderHeader, stickyTabBarComponent, tabScrollEnabled = false, variant = "tabs", ...tabContainerProps }) => {
32
24
  const space = useSpace();
33
25
  const color = useColor();
26
+ const [focusedTabState, setFocusedTabState] = useState(initialTabName);
34
27
  const isIOS = Platform.OS === "ios";
35
28
  return (_jsx(BaseTabs.Container, { renderHeader: renderHeader, headerContainerStyle: {
36
29
  shadowOpacity: 0,
@@ -44,7 +37,8 @@ export const TabsContainer = ({ children, indicators = [], initialTabName, onTab
44
37
  return (_jsxs(Flex, { flexDirection: "row", gap: 2, alignItems: "center", py: 1, children: [_jsx(MaterialTabBar, { ...tabBarProps, scrollEnabled: true, TabItemComponent: (props) => (_jsx(PillTabItem, { ...props, onTabPress: (tab) => {
45
38
  onTabPress?.(tab);
46
39
  tabBarProps.onTabPress(tab);
47
- }, focusedTab: tabBarProps.focusedTab })), indicatorStyle: {
40
+ setFocusedTabState(tab);
41
+ }, focusedTab: focusedTabState || tabBarProps.focusedTab.value })), indicatorStyle: {
48
42
  backgroundColor: "transparent",
49
43
  }, contentContainerStyle: {
50
44
  gap: space(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "17.10.0",
3
+ "version": "17.11.0",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "RCT_METRO_PORT=8082 react-native run-android --port 8082 --terminal terminal",