@particle-network/ui-native 0.0.12 → 0.0.13
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/dist/components/Text/index.d.ts +1 -1
- package/dist/components/Text/index.js +0 -1
- package/dist/components/Text/text.js +12 -39
- package/dist/components/Text/text.style.d.ts +24 -0
- package/dist/components/Text/text.style.js +124 -0
- package/dist/components/Text/text.types.d.ts +0 -10
- package/dist/components/Text/text.types.js +0 -77
- package/dist/components/UXButton/button.js +3 -2
- package/dist/components/UXButton/button.styles.d.ts +2 -21
- package/dist/components/UXButton/button.styles.js +71 -45
- package/dist/components/UXButton/button.types.d.ts +15 -6
- package/dist/components/UXCheckbox/checkbox.js +2 -1
- package/dist/components/UXChip/chip.js +3 -1
- package/dist/components/UXChip/styles.d.ts +0 -10
- package/dist/components/UXChip/styles.js +13 -13
- package/dist/components/UXHint/index.js +2 -1
- package/dist/components/UXListBox/UXListBoxItem.js +2 -1
- package/dist/components/UXModal/index.js +7 -5
- package/dist/components/UXRadio/radio.js +2 -1
- package/dist/components/UXSwitch/styles.js +2 -1
- package/dist/components/UXSwitch/switch.js +2 -2
- package/dist/components/UXTabs/styles.d.ts +4 -1
- package/dist/components/UXTabs/styles.js +38 -34
- package/dist/components/UXTabs/tab.js +33 -21
- package/dist/components/UXTabs/types.d.ts +16 -1
- package/dist/components/input/styles.d.ts +1 -1
- package/dist/components/input/styles.js +19 -19
- package/dist/components/layout/Box/useBox.style.js +6 -6
- package/dist/config/config.default.d.ts +2 -0
- package/dist/config/config.default.js +55 -0
- package/dist/config/config.ux.d.ts +2 -0
- package/dist/config/config.ux.js +61 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +7 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useComponentConfig.d.ts +1 -0
- package/dist/hooks/useComponentConfig.js +7 -0
- package/dist/hooks/useMs.d.ts +3 -0
- package/dist/hooks/useMs.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/provider/ThemeContext.d.ts +1 -1
- package/dist/provider/ThemeContext.js +5 -2
- package/dist/provider/ThemeProvider.d.ts +4 -2
- package/dist/provider/ThemeProvider.js +18 -6
- package/dist/theme/colors.d.ts +1 -1
- package/dist/theme/colors.js +2 -2
- package/dist/theme/index.d.ts +1 -3
- package/dist/theme/index.js +1 -12
- package/dist/theme/radius.d.ts +1 -1
- package/dist/theme/radius.js +3 -3
- package/dist/theme/spacing.d.ts +1 -1
- package/dist/theme/spacing.js +2 -2
- package/dist/theme/theme.d.ts +3 -0
- package/dist/theme/theme.js +13 -0
- package/dist/types/theme.d.ts +33 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/mergeConfig.d.ts +8 -0
- package/dist/utils/mergeConfig.js +6 -0
- package/package.json +4 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './text';
|
|
2
|
-
export
|
|
2
|
+
export type { TextProps } from './text.types';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef,
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
3
|
import { StyleSheet, Text, View } from "react-native";
|
|
4
4
|
import { useColors } from "../../hooks/index.js";
|
|
5
5
|
import { Box, useBoxStyle } from "../layout/Box/index.js";
|
|
6
6
|
import { HStack } from "../layout/HStack.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useTextStyles } from "./text.style.js";
|
|
8
8
|
const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
9
9
|
const { variant = 'body2Bold', fontWeight, color = 'default', lineHeight, align, style, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, underlineStyle, fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow, ...restProps } = props;
|
|
10
10
|
const [textWidth, setTextWidth] = useState(0);
|
|
@@ -73,20 +73,12 @@ const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
73
73
|
zIndex,
|
|
74
74
|
overflow
|
|
75
75
|
});
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (body2) return textStyles.variant.body2;
|
|
83
|
-
if (body2Bold) return textStyles.variant.body2Bold;
|
|
84
|
-
if (body3) return textStyles.variant.body3;
|
|
85
|
-
if (body3Bold) return textStyles.variant.body3Bold;
|
|
86
|
-
if (caption1) return textStyles.variant.caption1;
|
|
87
|
-
if (caption1Bold) return textStyles.variant.caption1Bold;
|
|
88
|
-
return textStyles.variant[variant];
|
|
89
|
-
}, [
|
|
76
|
+
const { styles } = useTextStyles({
|
|
77
|
+
variant,
|
|
78
|
+
fontWeight,
|
|
79
|
+
color,
|
|
80
|
+
lineHeight,
|
|
81
|
+
align,
|
|
90
82
|
h1,
|
|
91
83
|
h2,
|
|
92
84
|
h3,
|
|
@@ -97,27 +89,8 @@ const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
97
89
|
body3,
|
|
98
90
|
body3Bold,
|
|
99
91
|
caption1,
|
|
100
|
-
caption1Bold
|
|
101
|
-
|
|
102
|
-
]);
|
|
103
|
-
const textStyle = useMemo(()=>({
|
|
104
|
-
...variantStyle,
|
|
105
|
-
...fontWeight && {
|
|
106
|
-
fontWeight: textStyles.fontWeight[fontWeight]
|
|
107
|
-
},
|
|
108
|
-
...lineHeight && {
|
|
109
|
-
lineHeight: textStyles.lineHeight[lineHeight] * variantStyle.fontSize
|
|
110
|
-
},
|
|
111
|
-
textAlign: textStyles.align[align],
|
|
112
|
-
color: getColor(color)
|
|
113
|
-
}), [
|
|
114
|
-
variantStyle,
|
|
115
|
-
fontWeight,
|
|
116
|
-
lineHeight,
|
|
117
|
-
align,
|
|
118
|
-
color,
|
|
119
|
-
getColor
|
|
120
|
-
]);
|
|
92
|
+
caption1Bold
|
|
93
|
+
});
|
|
121
94
|
if ([
|
|
122
95
|
'dotted',
|
|
123
96
|
'dashed'
|
|
@@ -152,7 +125,7 @@ const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
152
125
|
/*#__PURE__*/ jsx(Text, {
|
|
153
126
|
style: [
|
|
154
127
|
boxStyle,
|
|
155
|
-
|
|
128
|
+
styles.text,
|
|
156
129
|
style
|
|
157
130
|
],
|
|
158
131
|
onLayout: (e)=>{
|
|
@@ -183,7 +156,7 @@ const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
183
156
|
ref: ref,
|
|
184
157
|
style: [
|
|
185
158
|
boxStyle,
|
|
186
|
-
|
|
159
|
+
styles.text,
|
|
187
160
|
underlineStyle && {
|
|
188
161
|
textDecorationLine: 'underline',
|
|
189
162
|
textDecorationStyle: underlineStyle
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type TextProps } from './text.types';
|
|
2
|
+
export declare const useTextStyles: ({ variant, fontWeight, color, lineHeight, align, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, }: TextProps) => {
|
|
3
|
+
styles: {
|
|
4
|
+
text: {
|
|
5
|
+
textAlign: ("right" | "left" | "center") | undefined;
|
|
6
|
+
color: string | undefined;
|
|
7
|
+
lineHeight: number;
|
|
8
|
+
fontWeight: "600" | "500" | "400" | "700" | "800";
|
|
9
|
+
fontSize: number;
|
|
10
|
+
} | {
|
|
11
|
+
textAlign: ("right" | "left" | "center") | undefined;
|
|
12
|
+
color: string | undefined;
|
|
13
|
+
lineHeight: number;
|
|
14
|
+
fontWeight: "600" | "500" | "400" | "700" | "800";
|
|
15
|
+
fontSize: number;
|
|
16
|
+
} | {
|
|
17
|
+
textAlign: ("right" | "left" | "center") | undefined;
|
|
18
|
+
color: string | undefined;
|
|
19
|
+
lineHeight: number;
|
|
20
|
+
fontWeight: "600" | "500" | "400" | "700" | "800";
|
|
21
|
+
fontSize: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { useColors, useMs } from "../../hooks/index.js";
|
|
4
|
+
const useTextStyles = ({ variant = 'body2Bold', fontWeight, color = 'default', lineHeight, align, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold })=>{
|
|
5
|
+
const { ms } = useMs();
|
|
6
|
+
const { getColor } = useColors();
|
|
7
|
+
const textStyles = useMemo(()=>({
|
|
8
|
+
variant: {
|
|
9
|
+
h1: {
|
|
10
|
+
fontSize: ms(24),
|
|
11
|
+
lineHeight: ms(28),
|
|
12
|
+
fontWeight: '600'
|
|
13
|
+
},
|
|
14
|
+
h2: {
|
|
15
|
+
fontSize: ms(20),
|
|
16
|
+
lineHeight: ms(24),
|
|
17
|
+
fontWeight: '600'
|
|
18
|
+
},
|
|
19
|
+
h3: {
|
|
20
|
+
fontSize: ms(16),
|
|
21
|
+
lineHeight: ms(20),
|
|
22
|
+
fontWeight: '600'
|
|
23
|
+
},
|
|
24
|
+
body1Bold: {
|
|
25
|
+
fontSize: ms(14),
|
|
26
|
+
lineHeight: ms(18),
|
|
27
|
+
fontWeight: '500'
|
|
28
|
+
},
|
|
29
|
+
body1: {
|
|
30
|
+
fontSize: ms(14),
|
|
31
|
+
lineHeight: ms(18),
|
|
32
|
+
fontWeight: '400'
|
|
33
|
+
},
|
|
34
|
+
body2Bold: {
|
|
35
|
+
fontSize: ms(12),
|
|
36
|
+
lineHeight: ms(16),
|
|
37
|
+
fontWeight: '500'
|
|
38
|
+
},
|
|
39
|
+
body2: {
|
|
40
|
+
fontSize: ms(12),
|
|
41
|
+
lineHeight: ms(16),
|
|
42
|
+
fontWeight: '400'
|
|
43
|
+
},
|
|
44
|
+
body3Bold: {
|
|
45
|
+
fontSize: ms(11),
|
|
46
|
+
lineHeight: ms(16),
|
|
47
|
+
fontWeight: '500'
|
|
48
|
+
},
|
|
49
|
+
body3: {
|
|
50
|
+
fontSize: ms(11),
|
|
51
|
+
lineHeight: ms(16),
|
|
52
|
+
fontWeight: '400'
|
|
53
|
+
},
|
|
54
|
+
caption1Bold: {
|
|
55
|
+
fontSize: ms(10),
|
|
56
|
+
lineHeight: ms(14),
|
|
57
|
+
fontWeight: '500'
|
|
58
|
+
},
|
|
59
|
+
caption1: {
|
|
60
|
+
fontSize: ms(10),
|
|
61
|
+
lineHeight: ms(14),
|
|
62
|
+
fontWeight: '400'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
fontWeight: {
|
|
66
|
+
normal: '400',
|
|
67
|
+
medium: '500',
|
|
68
|
+
semibold: '600',
|
|
69
|
+
bold: '700',
|
|
70
|
+
extrabold: '800'
|
|
71
|
+
},
|
|
72
|
+
lineHeight: {
|
|
73
|
+
1: 1,
|
|
74
|
+
'1.4': 1.4
|
|
75
|
+
}
|
|
76
|
+
}), [
|
|
77
|
+
ms
|
|
78
|
+
]);
|
|
79
|
+
const variantStyle = useMemo(()=>{
|
|
80
|
+
if (h1) return textStyles.variant.h1;
|
|
81
|
+
if (h2) return textStyles.variant.h2;
|
|
82
|
+
if (h3) return textStyles.variant.h3;
|
|
83
|
+
if (body1) return textStyles.variant.body1;
|
|
84
|
+
if (body1Bold) return textStyles.variant.body1Bold;
|
|
85
|
+
if (body2) return textStyles.variant.body2;
|
|
86
|
+
if (body2Bold) return textStyles.variant.body2Bold;
|
|
87
|
+
if (body3) return textStyles.variant.body3;
|
|
88
|
+
if (body3Bold) return textStyles.variant.body3Bold;
|
|
89
|
+
if (caption1) return textStyles.variant.caption1;
|
|
90
|
+
if (caption1Bold) return textStyles.variant.caption1Bold;
|
|
91
|
+
return textStyles.variant[variant];
|
|
92
|
+
}, [
|
|
93
|
+
h1,
|
|
94
|
+
h2,
|
|
95
|
+
h3,
|
|
96
|
+
body1,
|
|
97
|
+
body1Bold,
|
|
98
|
+
body2,
|
|
99
|
+
body2Bold,
|
|
100
|
+
body3,
|
|
101
|
+
body3Bold,
|
|
102
|
+
caption1,
|
|
103
|
+
caption1Bold,
|
|
104
|
+
variant,
|
|
105
|
+
textStyles
|
|
106
|
+
]);
|
|
107
|
+
const styles = StyleSheet.create({
|
|
108
|
+
text: {
|
|
109
|
+
...variantStyle,
|
|
110
|
+
...fontWeight && {
|
|
111
|
+
fontWeight: textStyles.fontWeight[fontWeight]
|
|
112
|
+
},
|
|
113
|
+
...lineHeight && {
|
|
114
|
+
lineHeight: textStyles.lineHeight[lineHeight] * variantStyle.fontSize
|
|
115
|
+
},
|
|
116
|
+
textAlign: align,
|
|
117
|
+
color: getColor(color)
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
styles
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
export { useTextStyles };
|
|
@@ -96,14 +96,4 @@ export interface TextProps extends RNTextProps, UseBoxProps {
|
|
|
96
96
|
align?: TextAlign;
|
|
97
97
|
underlineStyle?: TextStyle['textDecorationStyle'];
|
|
98
98
|
}
|
|
99
|
-
export declare const textStyles: {
|
|
100
|
-
variant: Record<TextVariant, {
|
|
101
|
-
fontSize: number;
|
|
102
|
-
lineHeight: number;
|
|
103
|
-
fontWeight: TextStyle['fontWeight'];
|
|
104
|
-
}>;
|
|
105
|
-
fontWeight: Record<TextWeight, TextStyle['fontWeight']>;
|
|
106
|
-
lineHeight: Record<TextLineHeight, number>;
|
|
107
|
-
align: Record<TextAlign, TextStyle['textAlign']>;
|
|
108
|
-
};
|
|
109
99
|
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { ms } from "react-native-size-matters";
|
|
2
|
-
const textStyles = {
|
|
3
|
-
variant: {
|
|
4
|
-
h1: {
|
|
5
|
-
fontSize: ms(24),
|
|
6
|
-
lineHeight: ms(28),
|
|
7
|
-
fontWeight: '600'
|
|
8
|
-
},
|
|
9
|
-
h2: {
|
|
10
|
-
fontSize: ms(20),
|
|
11
|
-
lineHeight: ms(24),
|
|
12
|
-
fontWeight: '600'
|
|
13
|
-
},
|
|
14
|
-
h3: {
|
|
15
|
-
fontSize: ms(16),
|
|
16
|
-
lineHeight: ms(20),
|
|
17
|
-
fontWeight: '600'
|
|
18
|
-
},
|
|
19
|
-
body1Bold: {
|
|
20
|
-
fontSize: ms(14),
|
|
21
|
-
lineHeight: ms(18),
|
|
22
|
-
fontWeight: '500'
|
|
23
|
-
},
|
|
24
|
-
body1: {
|
|
25
|
-
fontSize: ms(14),
|
|
26
|
-
lineHeight: ms(18),
|
|
27
|
-
fontWeight: '400'
|
|
28
|
-
},
|
|
29
|
-
body2Bold: {
|
|
30
|
-
fontSize: ms(12),
|
|
31
|
-
lineHeight: ms(16),
|
|
32
|
-
fontWeight: '500'
|
|
33
|
-
},
|
|
34
|
-
body2: {
|
|
35
|
-
fontSize: ms(12),
|
|
36
|
-
lineHeight: ms(16),
|
|
37
|
-
fontWeight: '400'
|
|
38
|
-
},
|
|
39
|
-
body3Bold: {
|
|
40
|
-
fontSize: ms(11),
|
|
41
|
-
lineHeight: ms(16),
|
|
42
|
-
fontWeight: '500'
|
|
43
|
-
},
|
|
44
|
-
body3: {
|
|
45
|
-
fontSize: ms(11),
|
|
46
|
-
lineHeight: ms(16),
|
|
47
|
-
fontWeight: '400'
|
|
48
|
-
},
|
|
49
|
-
caption1Bold: {
|
|
50
|
-
fontSize: ms(10),
|
|
51
|
-
lineHeight: ms(14),
|
|
52
|
-
fontWeight: '500'
|
|
53
|
-
},
|
|
54
|
-
caption1: {
|
|
55
|
-
fontSize: ms(10),
|
|
56
|
-
lineHeight: ms(14),
|
|
57
|
-
fontWeight: '400'
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
fontWeight: {
|
|
61
|
-
normal: '400',
|
|
62
|
-
medium: '500',
|
|
63
|
-
semibold: '600',
|
|
64
|
-
bold: '700',
|
|
65
|
-
extrabold: '800'
|
|
66
|
-
},
|
|
67
|
-
lineHeight: {
|
|
68
|
-
1: 1,
|
|
69
|
-
'1.4': 1.4
|
|
70
|
-
},
|
|
71
|
-
align: {
|
|
72
|
-
left: 'left',
|
|
73
|
-
center: 'center',
|
|
74
|
-
right: 'right'
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
export { textStyles };
|
|
@@ -6,7 +6,7 @@ import { Text } from "../Text/index.js";
|
|
|
6
6
|
import { UXPressable } from "../UXPressable/index.js";
|
|
7
7
|
import { useStyles } from "./button.styles.js";
|
|
8
8
|
const UXButton = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
9
|
-
const { style, size, radius, color, variant, onPress, isDisabled, isLoading, startContent, endContent, fullWidth,
|
|
9
|
+
const { style, size, radius, color, variant, onPress, isDisabled, isLoading, startContent, endContent, fullWidth, width, w, h, isIconOnly, children, ...restProps } = props;
|
|
10
10
|
const handlePress = (e)=>{
|
|
11
11
|
Keyboard.dismiss();
|
|
12
12
|
triggerHapticFeedback();
|
|
@@ -22,7 +22,8 @@ const UXButton = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
22
22
|
fullWidth,
|
|
23
23
|
isIconOnly,
|
|
24
24
|
width,
|
|
25
|
-
|
|
25
|
+
w,
|
|
26
|
+
h
|
|
26
27
|
});
|
|
27
28
|
const content = useMemo(()=>{
|
|
28
29
|
if ('string' == typeof children || 'number' == typeof children) return /*#__PURE__*/ jsx(Text, {
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import type { UXButtonProps } from './button.types';
|
|
2
|
-
export declare const
|
|
3
|
-
readonly sm: number;
|
|
4
|
-
readonly md: number;
|
|
5
|
-
readonly lg: number;
|
|
6
|
-
readonly auto: undefined;
|
|
7
|
-
};
|
|
8
|
-
export declare const fontSizeMap: {
|
|
9
|
-
readonly sm: number;
|
|
10
|
-
readonly md: number;
|
|
11
|
-
readonly lg: number;
|
|
12
|
-
readonly auto: number;
|
|
13
|
-
};
|
|
14
|
-
export declare const radiusMap: {
|
|
15
|
-
readonly sm: "sm";
|
|
16
|
-
readonly md: "sm";
|
|
17
|
-
readonly lg: "md";
|
|
18
|
-
readonly auto: "sm";
|
|
19
|
-
};
|
|
20
|
-
export declare const useStyles: ({ size, radius, color, variant, isDisabled, isLoading, width, fullWidth, fill, isIconOnly, }: UXButtonProps) => {
|
|
2
|
+
export declare const useStyles: (props: UXButtonProps) => {
|
|
21
3
|
styles: {
|
|
22
4
|
button: {
|
|
23
5
|
flexDirection: "row";
|
|
@@ -27,7 +9,6 @@ export declare const useStyles: ({ size, radius, color, variant, isDisabled, isL
|
|
|
27
9
|
paddingVertical: number;
|
|
28
10
|
height: number | undefined;
|
|
29
11
|
width: number | "100%" | undefined;
|
|
30
|
-
flexGrow: number | undefined;
|
|
31
12
|
paddingHorizontal: number;
|
|
32
13
|
backgroundColor: string | undefined;
|
|
33
14
|
borderRadius: number | undefined;
|
|
@@ -43,7 +24,7 @@ export declare const useStyles: ({ size, radius, color, variant, isDisabled, isL
|
|
|
43
24
|
}[];
|
|
44
25
|
};
|
|
45
26
|
title: {
|
|
46
|
-
fontWeight: "
|
|
27
|
+
fontWeight: "600" | "500";
|
|
47
28
|
fontSize: number;
|
|
48
29
|
lineHeight: number;
|
|
49
30
|
color: string | undefined;
|
|
@@ -1,57 +1,75 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import { useColors, useRadius } from "../../hooks/index.js";
|
|
3
|
+
import { useColors, useComponentConfig, useMs, useRadius, useSpacing } from "../../hooks/index.js";
|
|
5
4
|
import { disabledOpacity } from "../../theme/index.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
md
|
|
9
|
-
lg: ms(44),
|
|
10
|
-
auto: void 0
|
|
11
|
-
};
|
|
12
|
-
const fontSizeMap = {
|
|
13
|
-
sm: ms(10),
|
|
14
|
-
md: ms(12),
|
|
15
|
-
lg: ms(16),
|
|
16
|
-
auto: ms(12)
|
|
17
|
-
};
|
|
18
|
-
const radiusMap = {
|
|
19
|
-
sm: 'sm',
|
|
20
|
-
md: 'sm',
|
|
21
|
-
lg: 'md',
|
|
22
|
-
auto: 'sm'
|
|
23
|
-
};
|
|
24
|
-
const paddingMap = {
|
|
25
|
-
sm: ms(2),
|
|
26
|
-
md: ms(2),
|
|
27
|
-
lg: ms(4)
|
|
28
|
-
};
|
|
29
|
-
const useStyles = ({ size = 'md', radius, color = 'default', variant = 'solid', isDisabled, isLoading, width, fullWidth, fill, isIconOnly })=>{
|
|
5
|
+
const useStyles = (props)=>{
|
|
6
|
+
const { button: buttonConfig } = useComponentConfig();
|
|
7
|
+
const { size = 'md', radius = buttonConfig.defaultProps?.radius, color = 'default', variant = 'solid', isDisabled, isLoading, width, w, h, fullWidth, isIconOnly } = props;
|
|
30
8
|
const { getColor } = useColors();
|
|
31
9
|
const { getRadius } = useRadius();
|
|
10
|
+
const { getSpacing } = useSpacing();
|
|
11
|
+
const { ms } = useMs();
|
|
12
|
+
const sizeMap = useMemo(()=>({
|
|
13
|
+
sm: ms(buttonConfig.size.sm),
|
|
14
|
+
md: ms(buttonConfig.size.md),
|
|
15
|
+
lg: ms(buttonConfig.size.lg),
|
|
16
|
+
auto: void 0
|
|
17
|
+
}), [
|
|
18
|
+
buttonConfig?.size,
|
|
19
|
+
ms
|
|
20
|
+
]);
|
|
21
|
+
const fontSizeMap = useMemo(()=>({
|
|
22
|
+
sm: ms(buttonConfig.fontSize.sm),
|
|
23
|
+
md: ms(buttonConfig.fontSize.md),
|
|
24
|
+
lg: ms(buttonConfig.fontSize.lg),
|
|
25
|
+
auto: ms(buttonConfig.fontSize.md)
|
|
26
|
+
}), [
|
|
27
|
+
ms,
|
|
28
|
+
buttonConfig.fontSize
|
|
29
|
+
]);
|
|
30
|
+
const radiusMap = {
|
|
31
|
+
sm: 'sm',
|
|
32
|
+
md: 'sm',
|
|
33
|
+
lg: 'md',
|
|
34
|
+
auto: 'sm'
|
|
35
|
+
};
|
|
36
|
+
const paddingMap = useMemo(()=>({
|
|
37
|
+
sm: ms(2),
|
|
38
|
+
md: ms(2),
|
|
39
|
+
lg: ms(4)
|
|
40
|
+
}), [
|
|
41
|
+
ms
|
|
42
|
+
]);
|
|
32
43
|
const height = useMemo(()=>{
|
|
33
|
-
if ('text' === variant || 'auto' === size) return;
|
|
44
|
+
if ('text' === variant || 'auto' === size) return getSpacing(h);
|
|
34
45
|
return sizeMap[size];
|
|
35
46
|
}, [
|
|
36
47
|
size,
|
|
37
|
-
variant
|
|
48
|
+
variant,
|
|
49
|
+
sizeMap,
|
|
50
|
+
h,
|
|
51
|
+
getSpacing
|
|
38
52
|
]);
|
|
39
53
|
const widthStyle = useMemo(()=>{
|
|
40
54
|
if (isIconOnly) return height;
|
|
41
55
|
if (fullWidth) return '100%';
|
|
42
|
-
return width;
|
|
56
|
+
return getSpacing(width || w);
|
|
43
57
|
}, [
|
|
44
58
|
fullWidth,
|
|
45
59
|
height,
|
|
46
60
|
isIconOnly,
|
|
47
|
-
width
|
|
61
|
+
width,
|
|
62
|
+
w,
|
|
63
|
+
getSpacing
|
|
48
64
|
]);
|
|
49
65
|
const fontSize = useMemo(()=>fontSizeMap[size], [
|
|
50
|
-
size
|
|
66
|
+
size,
|
|
67
|
+
fontSizeMap
|
|
51
68
|
]);
|
|
52
69
|
const borderRadius = useMemo(()=>getRadius(radius ?? radiusMap[size]), [
|
|
53
70
|
radius,
|
|
54
|
-
size
|
|
71
|
+
size,
|
|
72
|
+
getRadius
|
|
55
73
|
]);
|
|
56
74
|
const paddingHorizontal = useMemo(()=>{
|
|
57
75
|
if (isIconOnly || 'auto' === size || 'text' === variant) return 0;
|
|
@@ -59,41 +77,50 @@ const useStyles = ({ size = 'md', radius, color = 'default', variant = 'solid',
|
|
|
59
77
|
}, [
|
|
60
78
|
size,
|
|
61
79
|
isIconOnly,
|
|
62
|
-
variant
|
|
80
|
+
variant,
|
|
81
|
+
paddingMap
|
|
63
82
|
]);
|
|
64
83
|
const textColor = useMemo(()=>{
|
|
65
|
-
|
|
66
|
-
if (
|
|
84
|
+
const customColorConfig = buttonConfig?.color?.[color];
|
|
85
|
+
if (customColorConfig) return getColor(customColorConfig.text);
|
|
67
86
|
if ('contrast' === color) return getColor('bg-default');
|
|
68
|
-
if ('solid' === variant
|
|
87
|
+
if ('solid' === variant && ![
|
|
88
|
+
'default',
|
|
89
|
+
'secondary'
|
|
90
|
+
].includes(color)) return getColor('white');
|
|
69
91
|
return getColor(color);
|
|
70
92
|
}, [
|
|
71
93
|
color,
|
|
72
94
|
getColor,
|
|
73
|
-
variant
|
|
95
|
+
variant,
|
|
96
|
+
buttonConfig?.color
|
|
74
97
|
]);
|
|
75
98
|
const backgroundColor = useMemo(()=>{
|
|
99
|
+
const customColorConfig = buttonConfig?.color?.[color];
|
|
76
100
|
if ('solid' === variant) {
|
|
77
|
-
if (
|
|
101
|
+
if (customColorConfig) return getColor(customColorConfig.background);
|
|
102
|
+
if ('contrast' === color) return getColor('foreground');
|
|
103
|
+
if (![
|
|
78
104
|
'default',
|
|
79
105
|
'secondary'
|
|
80
|
-
].includes(color)) return getColor(
|
|
81
|
-
|
|
82
|
-
return getColor(color);
|
|
106
|
+
].includes(color)) return getColor(color);
|
|
107
|
+
return getColor('bg-300');
|
|
83
108
|
}
|
|
84
109
|
if ('flat' === variant) {
|
|
110
|
+
if (customColorConfig) return `${getColor(customColorConfig.background)}40`;
|
|
111
|
+
if ('contrast' === color) return `${getColor('foreground')}40`;
|
|
85
112
|
if ([
|
|
86
113
|
'default',
|
|
87
114
|
'secondary'
|
|
88
115
|
].includes(color)) return `${getColor('bg-300')}40`;
|
|
89
|
-
if ('contrast' === color) return `${getColor('foreground')}40`;
|
|
90
116
|
return `${getColor(color)}20`;
|
|
91
117
|
}
|
|
92
118
|
return 'transparent';
|
|
93
119
|
}, [
|
|
94
120
|
color,
|
|
95
121
|
getColor,
|
|
96
|
-
variant
|
|
122
|
+
variant,
|
|
123
|
+
buttonConfig?.color
|
|
97
124
|
]);
|
|
98
125
|
const borderColor = useMemo(()=>{
|
|
99
126
|
if ('bordered' === variant) {
|
|
@@ -125,7 +152,6 @@ const useStyles = ({ size = 'md', radius, color = 'default', variant = 'solid',
|
|
|
125
152
|
paddingVertical: 0,
|
|
126
153
|
height,
|
|
127
154
|
width: widthStyle,
|
|
128
|
-
flexGrow: fill ? 1 : void 0,
|
|
129
155
|
paddingHorizontal,
|
|
130
156
|
backgroundColor,
|
|
131
157
|
borderRadius,
|
|
@@ -154,4 +180,4 @@ const useStyles = ({ size = 'md', radius, color = 'default', variant = 'solid',
|
|
|
154
180
|
textColor
|
|
155
181
|
};
|
|
156
182
|
};
|
|
157
|
-
export {
|
|
183
|
+
export { useStyles };
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import type { UXRadius } from '@particle-network/ui-shared';
|
|
4
|
-
|
|
4
|
+
import type { UXPressableProps } from '../UXPressable';
|
|
5
|
+
export interface UXButtonProps extends Omit<UXPressableProps, 'style'> {
|
|
5
6
|
style?: StyleProp<ViewStyle>;
|
|
6
|
-
color?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'bullish' | 'bearish' | 'contrast';
|
|
7
|
+
color?: 'default' | 'primary' | 'secondary' | 'success' | 'alert' | 'warning' | 'danger' | 'bullish' | 'bearish' | 'contrast';
|
|
8
|
+
/**
|
|
9
|
+
* 按钮尺寸
|
|
10
|
+
* @default 'md'
|
|
11
|
+
* | size | ux-pro | ux |
|
|
12
|
+
* | :----- | :----- | :----- |
|
|
13
|
+
* | sm | 24 | 40 |
|
|
14
|
+
* | md | 30 | 44 |
|
|
15
|
+
* | lg | 44 | 48 |
|
|
16
|
+
*/
|
|
7
17
|
size?: 'sm' | 'md' | 'lg' | 'auto';
|
|
8
|
-
variant?: 'solid' | 'bordered' | '
|
|
18
|
+
variant?: 'solid' | 'bordered' | 'flat' | 'text';
|
|
9
19
|
radius?: UXRadius;
|
|
10
20
|
isDisabled?: boolean;
|
|
11
21
|
isLoading?: boolean;
|
|
12
22
|
startContent?: React.ReactNode;
|
|
13
23
|
endContent?: React.ReactNode;
|
|
14
24
|
isIconOnly?: boolean;
|
|
15
|
-
fullWidth?: boolean;
|
|
16
25
|
width?: number;
|
|
17
|
-
|
|
26
|
+
w?: number;
|
|
18
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { useMs } from "../../hooks/index.js";
|
|
4
4
|
import CheckboxOffIcon from "../../icons/CheckboxOffIcon.js";
|
|
5
5
|
import CheckboxOnIcon from "../../icons/CheckboxOnIcon.js";
|
|
6
6
|
import { disabledOpacity } from "../../theme/index.js";
|
|
@@ -9,6 +9,7 @@ import { Text } from "../Text/index.js";
|
|
|
9
9
|
import { UXPressable } from "../UXPressable/index.js";
|
|
10
10
|
import { useCheckboxGroup } from "./context.js";
|
|
11
11
|
const UXCheckbox = ({ size, color, defaultSelected = false, isSelected, children, value, onValueChange, isDisabled, ...props })=>{
|
|
12
|
+
const { ms } = useMs();
|
|
12
13
|
const [internalSelected, setInternalSelected] = useState(defaultSelected ?? isSelected);
|
|
13
14
|
const groupContext = useCheckboxGroup();
|
|
14
15
|
const isInGroup = null !== groupContext;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import { useComponentConfig } from "../../hooks/index.js";
|
|
3
4
|
import { HStack } from "../layout/HStack.js";
|
|
4
5
|
import { Text } from "../Text/index.js";
|
|
5
6
|
import { useStyles } from "./styles.js";
|
|
6
7
|
const UXChip = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
7
|
-
const {
|
|
8
|
+
const { chip: chipConfig } = useComponentConfig();
|
|
9
|
+
const { style, size, gap = 2, radius = chipConfig.defaultProps?.radius, color, variant, isDisabled, startContent, endContent, children, ...restProps } = props;
|
|
8
10
|
const styles = useStyles({
|
|
9
11
|
size,
|
|
10
12
|
color,
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import type { UXChipProps } from './types';
|
|
2
|
-
export declare const sizeMap: {
|
|
3
|
-
readonly sm: number;
|
|
4
|
-
readonly md: number;
|
|
5
|
-
readonly lg: number;
|
|
6
|
-
};
|
|
7
|
-
export declare const fontSizeMap: {
|
|
8
|
-
readonly sm: number;
|
|
9
|
-
readonly md: number;
|
|
10
|
-
readonly lg: number;
|
|
11
|
-
};
|
|
12
2
|
export declare const useStyles: ({ size, color, variant, isDisabled }: UXChipProps) => {
|
|
13
3
|
button: {
|
|
14
4
|
height: number;
|