@particle-network/ui-native 0.0.2
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/README.md +57 -0
- package/dist/components/ProgressWrapper/index.d.ts +35 -0
- package/dist/components/ProgressWrapper/index.js +120 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/Text/index.js +2 -0
- package/dist/components/Text/text.d.ts +4 -0
- package/dist/components/Text/text.js +196 -0
- package/dist/components/Text/text.types.d.ts +109 -0
- package/dist/components/Text/text.types.js +77 -0
- package/dist/components/UXButton/button.d.ts +3 -0
- package/dist/components/UXButton/button.js +74 -0
- package/dist/components/UXButton/button.styles.d.ts +53 -0
- package/dist/components/UXButton/button.styles.js +157 -0
- package/dist/components/UXButton/button.types.d.ts +18 -0
- package/dist/components/UXButton/button.types.js +0 -0
- package/dist/components/UXButton/index.d.ts +2 -0
- package/dist/components/UXButton/index.js +1 -0
- package/dist/components/UXCheckbox/checkbox-group.d.ts +8 -0
- package/dist/components/UXCheckbox/checkbox-group.js +30 -0
- package/dist/components/UXCheckbox/checkbox.d.ts +10 -0
- package/dist/components/UXCheckbox/checkbox.js +78 -0
- package/dist/components/UXCheckbox/context.d.ts +8 -0
- package/dist/components/UXCheckbox/context.js +8 -0
- package/dist/components/UXCheckbox/index.d.ts +4 -0
- package/dist/components/UXCheckbox/index.js +3 -0
- package/dist/components/UXCheckbox/types.d.ts +6 -0
- package/dist/components/UXCheckbox/types.js +0 -0
- package/dist/components/UXChip/chip.d.ts +3 -0
- package/dist/components/UXChip/chip.js +48 -0
- package/dist/components/UXChip/index.d.ts +2 -0
- package/dist/components/UXChip/index.js +1 -0
- package/dist/components/UXChip/styles.d.ts +24 -0
- package/dist/components/UXChip/styles.js +70 -0
- package/dist/components/UXChip/types.d.ts +11 -0
- package/dist/components/UXChip/types.js +0 -0
- package/dist/components/UXDivider/index.d.ts +8 -0
- package/dist/components/UXDivider/index.js +34 -0
- package/dist/components/UXHint/index.d.ts +7 -0
- package/dist/components/UXHint/index.js +19 -0
- package/dist/components/UXModal/index.d.ts +24 -0
- package/dist/components/UXModal/index.js +271 -0
- package/dist/components/UXPressable/index.d.ts +4 -0
- package/dist/components/UXPressable/index.js +36 -0
- package/dist/components/UXRadio/context.d.ts +7 -0
- package/dist/components/UXRadio/context.js +10 -0
- package/dist/components/UXRadio/index.d.ts +2 -0
- package/dist/components/UXRadio/index.js +2 -0
- package/dist/components/UXRadio/radio-group.d.ts +5 -0
- package/dist/components/UXRadio/radio-group.js +21 -0
- package/dist/components/UXRadio/radio.d.ts +5 -0
- package/dist/components/UXRadio/radio.js +67 -0
- package/dist/components/UXRadio/types.d.ts +10 -0
- package/dist/components/UXRadio/types.js +0 -0
- package/dist/components/UXSwitch/index.d.ts +2 -0
- package/dist/components/UXSwitch/index.js +1 -0
- package/dist/components/UXSwitch/styles.d.ts +16 -0
- package/dist/components/UXSwitch/styles.js +58 -0
- package/dist/components/UXSwitch/switch.d.ts +3 -0
- package/dist/components/UXSwitch/switch.js +103 -0
- package/dist/components/UXSwitch/types.d.ts +11 -0
- package/dist/components/UXSwitch/types.js +0 -0
- package/dist/components/UXTabs/context.d.ts +5 -0
- package/dist/components/UXTabs/context.js +8 -0
- package/dist/components/UXTabs/index.d.ts +4 -0
- package/dist/components/UXTabs/index.js +3 -0
- package/dist/components/UXTabs/styles.d.ts +30 -0
- package/dist/components/UXTabs/styles.js +191 -0
- package/dist/components/UXTabs/tab.d.ts +3 -0
- package/dist/components/UXTabs/tab.js +55 -0
- package/dist/components/UXTabs/tabs.d.ts +3 -0
- package/dist/components/UXTabs/tabs.js +66 -0
- package/dist/components/UXTabs/types.d.ts +23 -0
- package/dist/components/UXTabs/types.js +0 -0
- package/dist/components/UXTooltip/index.d.ts +6 -0
- package/dist/components/UXTooltip/index.js +32 -0
- package/dist/components/UXTouchableOpacity/index.d.ts +4 -0
- package/dist/components/UXTouchableOpacity/index.js +24 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +22 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/input.d.ts +3 -0
- package/dist/components/input/input.js +138 -0
- package/dist/components/input/number-input.d.ts +3 -0
- package/dist/components/input/number-input.js +231 -0
- package/dist/components/input/styles.d.ts +31 -0
- package/dist/components/input/styles.js +102 -0
- package/dist/components/input/types.d.ts +61 -0
- package/dist/components/input/types.js +0 -0
- package/dist/components/layout/Box/box.d.ts +12 -0
- package/dist/components/layout/Box/box.js +89 -0
- package/dist/components/layout/Box/index.d.ts +3 -0
- package/dist/components/layout/Box/index.js +2 -0
- package/dist/components/layout/Box/useBox.style.d.ts +3 -0
- package/dist/components/layout/Box/useBox.style.js +141 -0
- package/dist/components/layout/Box/useBox.type.d.ts +292 -0
- package/dist/components/layout/Box/useBox.type.js +0 -0
- package/dist/components/layout/Center.d.ts +5 -0
- package/dist/components/layout/Center.js +10 -0
- package/dist/components/layout/Circle.d.ts +7 -0
- package/dist/components/layout/Circle.js +14 -0
- package/dist/components/layout/Flex/flex.d.ts +6 -0
- package/dist/components/layout/Flex/flex.js +33 -0
- package/dist/components/layout/Flex/index.d.ts +4 -0
- package/dist/components/layout/Flex/index.js +3 -0
- package/dist/components/layout/Flex/useFlex.style.d.ts +3 -0
- package/dist/components/layout/Flex/useFlex.style.js +122 -0
- package/dist/components/layout/Flex/useFlex.type.d.ts +65 -0
- package/dist/components/layout/Flex/useFlex.type.js +0 -0
- package/dist/components/layout/Flex/useFlexBox.style.d.ts +134 -0
- package/dist/components/layout/Flex/useFlexBox.style.js +26 -0
- package/dist/components/layout/HStack.d.ts +5 -0
- package/dist/components/layout/HStack.js +11 -0
- package/dist/components/layout/Square.d.ts +9 -0
- package/dist/components/layout/Square.js +14 -0
- package/dist/components/layout/VStack.d.ts +5 -0
- package/dist/components/layout/VStack.js +14 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/useColors.d.ts +7 -0
- package/dist/hooks/useColors.js +18 -0
- package/dist/hooks/useKeyboard.d.ts +4 -0
- package/dist/hooks/useKeyboard.js +29 -0
- package/dist/hooks/useRadius.d.ts +7 -0
- package/dist/hooks/useRadius.js +16 -0
- package/dist/hooks/useSpacing.d.ts +7 -0
- package/dist/hooks/useSpacing.js +16 -0
- package/dist/hooks/useTheme.d.ts +5 -0
- package/dist/hooks/useTheme.js +6 -0
- package/dist/icons/CheckboxOffIcon.d.ts +4 -0
- package/dist/icons/CheckboxOffIcon.js +21 -0
- package/dist/icons/CheckboxOnIcon.d.ts +4 -0
- package/dist/icons/CheckboxOnIcon.js +26 -0
- package/dist/icons/DotIcon.d.ts +4 -0
- package/dist/icons/DotIcon.js +23 -0
- package/dist/icons/QuestionIcon.d.ts +4 -0
- package/dist/icons/QuestionIcon.js +30 -0
- package/dist/icons/RadioOffIcon.d.ts +4 -0
- package/dist/icons/RadioOffIcon.js +22 -0
- package/dist/icons/RadioOnIcon.d.ts +4 -0
- package/dist/icons/RadioOnIcon.js +42 -0
- package/dist/icons/types.d.ts +6 -0
- package/dist/icons/types.js +0 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/provider/ThemeContext.d.ts +3 -0
- package/dist/provider/ThemeContext.js +15 -0
- package/dist/provider/ThemeProvider.d.ts +10 -0
- package/dist/provider/ThemeProvider.js +31 -0
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/theme/colors.d.ts +6 -0
- package/dist/theme/colors.js +17 -0
- package/dist/theme/index.d.ts +7 -0
- package/dist/theme/index.js +16 -0
- package/dist/theme/opacity.d.ts +2 -0
- package/dist/theme/opacity.js +3 -0
- package/dist/theme/radius.d.ts +3 -0
- package/dist/theme/radius.js +10 -0
- package/dist/theme/spacing.d.ts +3 -0
- package/dist/theme/spacing.js +10 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +0 -0
- package/dist/types/theme.d.ts +17 -0
- package/dist/types/theme.js +0 -0
- package/dist/utils/triggerHapticFeedback.d.ts +5 -0
- package/dist/utils/triggerHapticFeedback.js +16 -0
- package/package.json +110 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UXForegroundColor, UXSize } from '@particle-network/ui-shared';
|
|
2
|
+
import type { FlexProps } from '..';
|
|
3
|
+
export type UXSwitchProps = FlexProps & {
|
|
4
|
+
color?: UXForegroundColor;
|
|
5
|
+
size?: UXSize;
|
|
6
|
+
isSelected?: boolean;
|
|
7
|
+
onValueChange?: (isSelected: boolean) => void;
|
|
8
|
+
isReadOnly?: boolean;
|
|
9
|
+
isDisabled?: boolean;
|
|
10
|
+
defaultSelected?: boolean;
|
|
11
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UXTabsProps } from './types';
|
|
2
|
+
type TabsContextType = Pick<UXTabsProps, 'selectedKey' | 'onSelectionChange' | 'size' | 'color' | 'variant' | 'radius' | 'isDisabled'>;
|
|
3
|
+
export declare const TabsContext: import("react").Context<TabsContextType>;
|
|
4
|
+
export declare const useTabsContext: () => TabsContextType;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const TabsContext = createContext({});
|
|
3
|
+
const useTabsContext = ()=>{
|
|
4
|
+
const context = useContext(TabsContext);
|
|
5
|
+
if (!context) throw new Error('useTabsContext must be used within a UXTabs');
|
|
6
|
+
return context;
|
|
7
|
+
};
|
|
8
|
+
export { TabsContext, useTabsContext };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UXTabsProps } from './types';
|
|
2
|
+
export declare const useStyles: (props: Partial<UXTabsProps> & {
|
|
3
|
+
isSelected?: boolean;
|
|
4
|
+
}) => {
|
|
5
|
+
tabsWrapper: {
|
|
6
|
+
backgroundColor: string | undefined;
|
|
7
|
+
gap: import("@particle-network/ui-shared").SpacingType;
|
|
8
|
+
flex: number;
|
|
9
|
+
justifyContent: "flex-start" | "space-between";
|
|
10
|
+
borderRadius: number | undefined;
|
|
11
|
+
height: number;
|
|
12
|
+
padding: number;
|
|
13
|
+
opacity: number;
|
|
14
|
+
};
|
|
15
|
+
tab: {
|
|
16
|
+
flexGrow: number;
|
|
17
|
+
height: "100%";
|
|
18
|
+
alignItems: "center";
|
|
19
|
+
justifyContent: "center";
|
|
20
|
+
paddingHorizontal: number;
|
|
21
|
+
borderRadius: number | undefined;
|
|
22
|
+
backgroundColor: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
tabText: {
|
|
25
|
+
fontSize: number;
|
|
26
|
+
lineHeight: number;
|
|
27
|
+
fontWeight: "500";
|
|
28
|
+
color: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { ms } from "react-native-size-matters";
|
|
4
|
+
import { useColors, useRadius } from "../../hooks/index.js";
|
|
5
|
+
import { disabledOpacity } from "../../theme/index.js";
|
|
6
|
+
const useStyles = (props)=>{
|
|
7
|
+
const { size = 'md', radius, fullWidth, variant = 'solid', color = 'default', isDisabled, isSelected, w, gap } = props;
|
|
8
|
+
const { getColor } = useColors();
|
|
9
|
+
const { getRadius } = useRadius();
|
|
10
|
+
const height = useMemo(()=>{
|
|
11
|
+
if ('text' === variant) switch(size){
|
|
12
|
+
case 'sm':
|
|
13
|
+
return ms(16);
|
|
14
|
+
case 'lg':
|
|
15
|
+
return ms(20);
|
|
16
|
+
default:
|
|
17
|
+
return ms(18);
|
|
18
|
+
}
|
|
19
|
+
if ('solid' === variant) switch(size){
|
|
20
|
+
case 'sm':
|
|
21
|
+
return ms(24);
|
|
22
|
+
case 'lg':
|
|
23
|
+
return ms(40);
|
|
24
|
+
default:
|
|
25
|
+
return ms(30);
|
|
26
|
+
}
|
|
27
|
+
switch(size){
|
|
28
|
+
case 'sm':
|
|
29
|
+
return ms(24);
|
|
30
|
+
case 'lg':
|
|
31
|
+
return ms(34);
|
|
32
|
+
default:
|
|
33
|
+
return ms(30);
|
|
34
|
+
}
|
|
35
|
+
}, [
|
|
36
|
+
size,
|
|
37
|
+
variant
|
|
38
|
+
]);
|
|
39
|
+
const fontSize = useMemo(()=>{
|
|
40
|
+
switch(size){
|
|
41
|
+
case 'sm':
|
|
42
|
+
return ms(12);
|
|
43
|
+
case 'lg':
|
|
44
|
+
return ms(16);
|
|
45
|
+
default:
|
|
46
|
+
return ms(14);
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
size
|
|
50
|
+
]);
|
|
51
|
+
const paddingHorizontal = useMemo(()=>{
|
|
52
|
+
if ('text' === variant) return 0;
|
|
53
|
+
switch(size){
|
|
54
|
+
case 'sm':
|
|
55
|
+
return ms(8);
|
|
56
|
+
case 'lg':
|
|
57
|
+
return ms(12);
|
|
58
|
+
default:
|
|
59
|
+
return ms(10);
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
size,
|
|
63
|
+
variant
|
|
64
|
+
]);
|
|
65
|
+
const gapValue = useMemo(()=>{
|
|
66
|
+
if (gap) return gap;
|
|
67
|
+
if ('text' === variant) switch(size){
|
|
68
|
+
case 'sm':
|
|
69
|
+
return ms(14);
|
|
70
|
+
case 'lg':
|
|
71
|
+
return ms(24);
|
|
72
|
+
default:
|
|
73
|
+
return ms(20);
|
|
74
|
+
}
|
|
75
|
+
if ('light' === variant) return ms(10);
|
|
76
|
+
return 0;
|
|
77
|
+
}, [
|
|
78
|
+
variant,
|
|
79
|
+
size,
|
|
80
|
+
gap
|
|
81
|
+
]);
|
|
82
|
+
const wrapperBackgroundColor = useMemo(()=>{
|
|
83
|
+
if ('switch' === variant) return getColor('bg-200');
|
|
84
|
+
if ('solid' === variant) return getColor('bg-400');
|
|
85
|
+
return 'transparent';
|
|
86
|
+
}, [
|
|
87
|
+
variant,
|
|
88
|
+
getColor
|
|
89
|
+
]);
|
|
90
|
+
const wrapperBorderRadius = useMemo(()=>{
|
|
91
|
+
if ('solid' === variant || 'switch' === variant) {
|
|
92
|
+
if (radius) return getRadius(radius);
|
|
93
|
+
if ('lg' === size) return ms(10);
|
|
94
|
+
return ms(6);
|
|
95
|
+
}
|
|
96
|
+
return 0;
|
|
97
|
+
}, [
|
|
98
|
+
variant,
|
|
99
|
+
size,
|
|
100
|
+
radius
|
|
101
|
+
]);
|
|
102
|
+
const wrapperPadding = useMemo(()=>{
|
|
103
|
+
if ('solid' === variant) {
|
|
104
|
+
if ('lg' === size) return ms(4);
|
|
105
|
+
return ms(2);
|
|
106
|
+
}
|
|
107
|
+
return 0;
|
|
108
|
+
}, [
|
|
109
|
+
variant,
|
|
110
|
+
size
|
|
111
|
+
]);
|
|
112
|
+
const tabBorderRadius = useMemo(()=>{
|
|
113
|
+
if (radius) return getRadius(radius);
|
|
114
|
+
return ms(6);
|
|
115
|
+
}, [
|
|
116
|
+
variant,
|
|
117
|
+
radius
|
|
118
|
+
]);
|
|
119
|
+
const tabBg = useMemo(()=>{
|
|
120
|
+
if (!isSelected) return 'transparent';
|
|
121
|
+
if ('text' === variant) return 'transparent';
|
|
122
|
+
if ('default' === color) {
|
|
123
|
+
if ('switch' === variant) return getColor('tertiary');
|
|
124
|
+
return getColor('bg-200');
|
|
125
|
+
}
|
|
126
|
+
return getColor(color);
|
|
127
|
+
}, [
|
|
128
|
+
variant,
|
|
129
|
+
color,
|
|
130
|
+
getColor,
|
|
131
|
+
isSelected
|
|
132
|
+
]);
|
|
133
|
+
const tabTextColor = useMemo(()=>{
|
|
134
|
+
if (!isSelected) return getColor('secondary');
|
|
135
|
+
if ('text' === variant) {
|
|
136
|
+
if ('default' === color) return getColor('foreground');
|
|
137
|
+
return getColor(color);
|
|
138
|
+
}
|
|
139
|
+
if ('default' === color) return getColor('foreground');
|
|
140
|
+
return 'white';
|
|
141
|
+
}, [
|
|
142
|
+
variant,
|
|
143
|
+
color,
|
|
144
|
+
getColor,
|
|
145
|
+
isSelected
|
|
146
|
+
]);
|
|
147
|
+
const styles = useMemo(()=>StyleSheet.create({
|
|
148
|
+
tabsWrapper: {
|
|
149
|
+
backgroundColor: wrapperBackgroundColor,
|
|
150
|
+
gap: gapValue,
|
|
151
|
+
flex: fullWidth || w ? 1 : 0,
|
|
152
|
+
justifyContent: fullWidth || w ? 'space-between' : 'flex-start',
|
|
153
|
+
borderRadius: wrapperBorderRadius,
|
|
154
|
+
height,
|
|
155
|
+
padding: wrapperPadding,
|
|
156
|
+
opacity: isDisabled ? disabledOpacity : 1
|
|
157
|
+
},
|
|
158
|
+
tab: {
|
|
159
|
+
flexGrow: 'text' === variant || 'light' === variant ? 0 : 1,
|
|
160
|
+
height: '100%',
|
|
161
|
+
alignItems: 'center',
|
|
162
|
+
justifyContent: 'center',
|
|
163
|
+
paddingHorizontal,
|
|
164
|
+
borderRadius: tabBorderRadius,
|
|
165
|
+
backgroundColor: tabBg
|
|
166
|
+
},
|
|
167
|
+
tabText: {
|
|
168
|
+
fontSize,
|
|
169
|
+
lineHeight: fontSize + ms(4),
|
|
170
|
+
fontWeight: '500',
|
|
171
|
+
color: tabTextColor
|
|
172
|
+
}
|
|
173
|
+
}), [
|
|
174
|
+
variant,
|
|
175
|
+
height,
|
|
176
|
+
paddingHorizontal,
|
|
177
|
+
fontSize,
|
|
178
|
+
gapValue,
|
|
179
|
+
wrapperBackgroundColor,
|
|
180
|
+
wrapperBorderRadius,
|
|
181
|
+
tabBorderRadius,
|
|
182
|
+
wrapperPadding,
|
|
183
|
+
tabBg,
|
|
184
|
+
isDisabled,
|
|
185
|
+
tabTextColor,
|
|
186
|
+
fullWidth,
|
|
187
|
+
w
|
|
188
|
+
]);
|
|
189
|
+
return styles;
|
|
190
|
+
};
|
|
191
|
+
export { useStyles };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { HStack, Text, UXTouchableOpacity } from "../index.js";
|
|
4
|
+
import DotIcon from "../../icons/DotIcon.js";
|
|
5
|
+
import { useTabsContext } from "./context.js";
|
|
6
|
+
import { useStyles } from "./styles.js";
|
|
7
|
+
const UXTab = ({ tabKey = '', title, icon, style, notification })=>{
|
|
8
|
+
const { selectedKey, onSelectionChange, size, color, variant, radius, isDisabled } = useTabsContext();
|
|
9
|
+
const isSelected = selectedKey === tabKey;
|
|
10
|
+
const handlePress = useCallback(()=>{
|
|
11
|
+
if (!isDisabled && tabKey) onSelectionChange?.(tabKey);
|
|
12
|
+
}, [
|
|
13
|
+
isDisabled,
|
|
14
|
+
onSelectionChange,
|
|
15
|
+
tabKey
|
|
16
|
+
]);
|
|
17
|
+
const styles = useStyles({
|
|
18
|
+
variant,
|
|
19
|
+
color,
|
|
20
|
+
size,
|
|
21
|
+
radius,
|
|
22
|
+
isSelected
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/ jsx(UXTouchableOpacity, {
|
|
25
|
+
activeOpacity: 0.7,
|
|
26
|
+
disabled: isDisabled,
|
|
27
|
+
style: [
|
|
28
|
+
styles.tab,
|
|
29
|
+
style
|
|
30
|
+
],
|
|
31
|
+
onPress: handlePress,
|
|
32
|
+
children: /*#__PURE__*/ jsxs(HStack, {
|
|
33
|
+
gap: 4,
|
|
34
|
+
position: "relative",
|
|
35
|
+
children: [
|
|
36
|
+
'function' == typeof icon ? icon(isSelected) : icon,
|
|
37
|
+
'function' == typeof title ? title(isSelected) : /*#__PURE__*/ jsx(Text, {
|
|
38
|
+
style: styles.tabText,
|
|
39
|
+
children: title
|
|
40
|
+
}),
|
|
41
|
+
notification ? /*#__PURE__*/ jsx(DotIcon, {
|
|
42
|
+
color: "danger",
|
|
43
|
+
size: 5,
|
|
44
|
+
style: {
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
right: -4,
|
|
47
|
+
top: 0
|
|
48
|
+
}
|
|
49
|
+
}) : null
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
UXTab.displayName = 'UXTab';
|
|
55
|
+
export { UXTab };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, cloneElement, isValidElement, useState } from "react";
|
|
3
|
+
import useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
4
|
+
import { HStack, VStack } from "../index.js";
|
|
5
|
+
import { disabledOpacity } from "../../theme/index.js";
|
|
6
|
+
import { TabsContext } from "./context.js";
|
|
7
|
+
import { useStyles } from "./styles.js";
|
|
8
|
+
const UXTabs = (props)=>{
|
|
9
|
+
const { style, tabStyle, color, size, variant, radius, selectedKey: selectedKeyProp, defaultSelectedKey, onSelectionChange, isDisabled, children, ...restProps } = props;
|
|
10
|
+
const firstTabKey = Children.toArray(children).find((child)=>{
|
|
11
|
+
if (/*#__PURE__*/ isValidElement(child) && child.key) return true;
|
|
12
|
+
return false;
|
|
13
|
+
});
|
|
14
|
+
const [selectedKey, setSelectedKey] = useState(selectedKeyProp || defaultSelectedKey || firstTabKey?.key || '');
|
|
15
|
+
useUpdateEffect(()=>{
|
|
16
|
+
if (void 0 !== selectedKeyProp) setSelectedKey(selectedKeyProp);
|
|
17
|
+
}, [
|
|
18
|
+
selectedKeyProp
|
|
19
|
+
]);
|
|
20
|
+
const styles = useStyles(props);
|
|
21
|
+
const handleSelectionChange = (key)=>{
|
|
22
|
+
if (!isDisabled) {
|
|
23
|
+
setSelectedKey(key);
|
|
24
|
+
onSelectionChange?.(key);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const tabs = Children.map(children, async (child)=>{
|
|
28
|
+
if (/*#__PURE__*/ isValidElement(child) && child.key) return /*#__PURE__*/ cloneElement(child, {
|
|
29
|
+
tabKey: String(child.key),
|
|
30
|
+
style: tabStyle
|
|
31
|
+
});
|
|
32
|
+
return child;
|
|
33
|
+
});
|
|
34
|
+
const renderSelectedTabContent = ()=>Children.map(children, async (child)=>{
|
|
35
|
+
if (/*#__PURE__*/ isValidElement(child) && child.key === selectedKey) return child.props.children;
|
|
36
|
+
return null;
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/ jsx(TabsContext.Provider, {
|
|
39
|
+
value: {
|
|
40
|
+
selectedKey,
|
|
41
|
+
onSelectionChange: handleSelectionChange,
|
|
42
|
+
size,
|
|
43
|
+
color,
|
|
44
|
+
variant,
|
|
45
|
+
radius,
|
|
46
|
+
isDisabled
|
|
47
|
+
},
|
|
48
|
+
children: /*#__PURE__*/ jsxs(VStack, {
|
|
49
|
+
gap: "md",
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ jsx(HStack, {
|
|
52
|
+
opacity: isDisabled ? disabledOpacity : 1,
|
|
53
|
+
style: [
|
|
54
|
+
styles.tabsWrapper,
|
|
55
|
+
style
|
|
56
|
+
],
|
|
57
|
+
...restProps,
|
|
58
|
+
children: tabs
|
|
59
|
+
}),
|
|
60
|
+
renderSelectedTabContent()
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
UXTabs.displayName = 'UXTabs';
|
|
66
|
+
export { UXTabs };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type { UXForegroundColor, UXSize } from '@particle-network/ui-shared';
|
|
4
|
+
import type { HStackProps } from '..';
|
|
5
|
+
export interface UXTabsProps extends HStackProps {
|
|
6
|
+
color?: UXForegroundColor;
|
|
7
|
+
size?: UXSize;
|
|
8
|
+
variant?: 'solid' | 'light' | 'text' | 'switch';
|
|
9
|
+
selectedKey?: string;
|
|
10
|
+
defaultSelectedKey?: string;
|
|
11
|
+
onSelectionChange?: (key: string) => void;
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
14
|
+
tabStyle?: StyleProp<ViewStyle>;
|
|
15
|
+
}
|
|
16
|
+
export interface UXTabProps {
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
tabKey?: string;
|
|
19
|
+
title?: string | ((isSelected: boolean) => React.ReactNode);
|
|
20
|
+
icon?: React.ReactNode | ((isSelected: boolean) => React.ReactNode);
|
|
21
|
+
notification?: boolean;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Text, UXModal, UXPressable } from "../index.js";
|
|
4
|
+
const UXTooltip = (props)=>{
|
|
5
|
+
const { content, children, ...restProps } = props;
|
|
6
|
+
const [isShow, setIsShow] = useState(false);
|
|
7
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
8
|
+
children: [
|
|
9
|
+
/*#__PURE__*/ jsx(UXPressable, {
|
|
10
|
+
onPress: ()=>{
|
|
11
|
+
setIsShow(true);
|
|
12
|
+
},
|
|
13
|
+
children: children
|
|
14
|
+
}),
|
|
15
|
+
/*#__PURE__*/ jsx(UXModal, {
|
|
16
|
+
wrapPortal: true,
|
|
17
|
+
isOpen: isShow,
|
|
18
|
+
onClose: ()=>{
|
|
19
|
+
setIsShow(false);
|
|
20
|
+
},
|
|
21
|
+
...restProps,
|
|
22
|
+
children: 'string' == typeof content ? /*#__PURE__*/ jsx(Text, {
|
|
23
|
+
body2: true,
|
|
24
|
+
lineHeight: "1.4",
|
|
25
|
+
children: content
|
|
26
|
+
}) : content
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
UXTooltip.displayName = 'UXTooltip';
|
|
32
|
+
export { UXTooltip };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type TouchableOpacityProps, type View } from 'react-native';
|
|
2
|
+
import { type UseBoxProps, type UseFlexProps } from '..';
|
|
3
|
+
export type UXTouchableOpacityProps = TouchableOpacityProps & UseBoxProps & UseFlexProps;
|
|
4
|
+
export declare const UXTouchableOpacity: import("react").ForwardRefExoticComponent<TouchableOpacityProps & UseBoxProps & UseFlexProps & import("react").RefAttributes<View>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { TouchableOpacity } from "react-native";
|
|
4
|
+
import useDebounceFn from "ahooks/es/useDebounceFn";
|
|
5
|
+
import { useFlexBoxStyle } from "../index.js";
|
|
6
|
+
const UXTouchableOpacity = /*#__PURE__*/ forwardRef(({ onPress, style, ...props }, ref)=>{
|
|
7
|
+
const { run } = useDebounceFn(onPress || (()=>null), {
|
|
8
|
+
wait: 300,
|
|
9
|
+
leading: true,
|
|
10
|
+
trailing: false
|
|
11
|
+
});
|
|
12
|
+
const boxFlexStyle = useFlexBoxStyle(props);
|
|
13
|
+
return /*#__PURE__*/ jsx(TouchableOpacity, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
style: [
|
|
16
|
+
boxFlexStyle,
|
|
17
|
+
style
|
|
18
|
+
],
|
|
19
|
+
onPress: run,
|
|
20
|
+
...props
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
UXTouchableOpacity.displayName = 'UXTouchableOpacity';
|
|
24
|
+
export { UXTouchableOpacity };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './input';
|
|
2
|
+
export * from './layout/Box';
|
|
3
|
+
export * from './layout/Center';
|
|
4
|
+
export * from './layout/Circle';
|
|
5
|
+
export * from './layout/Flex';
|
|
6
|
+
export * from './layout/HStack';
|
|
7
|
+
export * from './layout/Square';
|
|
8
|
+
export * from './layout/VStack';
|
|
9
|
+
export * from './ProgressWrapper';
|
|
10
|
+
export * from './Text';
|
|
11
|
+
export * from './UXButton';
|
|
12
|
+
export * from './UXCheckbox';
|
|
13
|
+
export * from './UXChip';
|
|
14
|
+
export * from './UXDivider';
|
|
15
|
+
export * from './UXHint';
|
|
16
|
+
export * from './UXModal';
|
|
17
|
+
export * from './UXPressable';
|
|
18
|
+
export * from './UXRadio';
|
|
19
|
+
export * from './UXSwitch';
|
|
20
|
+
export * from './UXTabs';
|
|
21
|
+
export * from './UXTooltip';
|
|
22
|
+
export * from './UXTouchableOpacity';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from "./input/index.js";
|
|
2
|
+
export * from "./layout/Box/index.js";
|
|
3
|
+
export * from "./layout/Center.js";
|
|
4
|
+
export * from "./layout/Circle.js";
|
|
5
|
+
export * from "./layout/Flex/index.js";
|
|
6
|
+
export * from "./layout/HStack.js";
|
|
7
|
+
export * from "./layout/Square.js";
|
|
8
|
+
export * from "./layout/VStack.js";
|
|
9
|
+
export * from "./ProgressWrapper/index.js";
|
|
10
|
+
export * from "./Text/index.js";
|
|
11
|
+
export * from "./UXButton/index.js";
|
|
12
|
+
export * from "./UXCheckbox/index.js";
|
|
13
|
+
export * from "./UXChip/index.js";
|
|
14
|
+
export * from "./UXDivider/index.js";
|
|
15
|
+
export * from "./UXHint/index.js";
|
|
16
|
+
export * from "./UXModal/index.js";
|
|
17
|
+
export * from "./UXPressable/index.js";
|
|
18
|
+
export * from "./UXRadio/index.js";
|
|
19
|
+
export * from "./UXSwitch/index.js";
|
|
20
|
+
export * from "./UXTabs/index.js";
|
|
21
|
+
export * from "./UXTooltip/index.js";
|
|
22
|
+
export * from "./UXTouchableOpacity/index.js";
|