@artsy/palette-mobile 17.9.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,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Insets,
|
|
2
|
+
import { Insets, TouchableWithoutFeedbackProps } from "react-native";
|
|
3
3
|
import { FlexProps } from "../Flex";
|
|
4
|
-
type CheckboxProps = Omit<
|
|
4
|
+
type CheckboxProps = Omit<TouchableWithoutFeedbackProps, "hitSlop"> & Omit<FlexProps, "hitSlop"> & {
|
|
5
5
|
hitSlop?: Insets;
|
|
6
6
|
checked?: boolean;
|
|
7
7
|
disabled?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { themeGet } from "@styled-system/theme-get";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { PixelRatio,
|
|
4
|
+
import { PixelRatio, StyleSheet, TouchableWithoutFeedback, } from "react-native";
|
|
5
5
|
import styled from "styled-components/native";
|
|
6
6
|
import { CssTransition } from "../../animation/CssTransition";
|
|
7
7
|
import { useTheme } from "../../utils/hooks/useTheme";
|
|
@@ -43,7 +43,7 @@ export const Checkbox = ({ checked: checkedProp, disabled, error, onPress, text,
|
|
|
43
43
|
: checkboxStyles[error ? "error" : "default"][isChecked ? "checked" : "unchecked"];
|
|
44
44
|
const textColor = error ? color("red100") : disabled ? color("mono30") : color("mono100");
|
|
45
45
|
const subtitleColor = error ? color("red100") : disabled ? color("mono30") : color("mono60");
|
|
46
|
-
return (_jsx(
|
|
46
|
+
return (_jsx(TouchableWithoutFeedback, { accessibilityRole: "checkbox", accessibilityState: { checked: isChecked, disabled }, accessibilityLabel: accessibilityLabel, accessibilityHint: accessibilityHint, onPress: (event) => {
|
|
47
47
|
if (disabled) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: import("react").FC<Omit<import("react-native/types").
|
|
4
|
+
component: import("react").FC<Omit<import("react-native/types").TouchableWithoutFeedbackProps, "hitSlop"> & Omit<import("..").BoxProps, "hitSlop"> & {
|
|
5
5
|
hitSlop?: import("react-native/types").Insets | undefined;
|
|
6
6
|
checked?: boolean | undefined;
|
|
7
7
|
disabled?: boolean | undefined;
|
|
@@ -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
|
|
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
|
-
|
|
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