@xaui/native 0.0.21 → 0.0.24
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 +195 -2
- package/dist/alert/index.js +1 -2
- package/dist/app-bar/index.cjs +217 -0
- package/dist/app-bar/index.d.cts +52 -0
- package/dist/app-bar/index.d.ts +52 -0
- package/dist/app-bar/index.js +142 -0
- package/dist/autocomplete/index.js +48 -36
- package/dist/avatar/index.js +1 -2
- package/dist/badge/index.js +1 -2
- package/dist/bottom-sheet/index.js +1 -2
- package/dist/bottom-tab-bar/index.cjs +571 -0
- package/dist/bottom-tab-bar/index.d.cts +211 -0
- package/dist/bottom-tab-bar/index.d.ts +211 -0
- package/dist/bottom-tab-bar/index.js +497 -0
- package/dist/button/index.d.cts +102 -5
- package/dist/button/index.d.ts +102 -5
- package/dist/button/index.js +2 -3
- package/dist/button.type-j1ZdkkSl.d.cts +4 -0
- package/dist/button.type-j1ZdkkSl.d.ts +4 -0
- package/dist/card/index.cjs +2 -0
- package/dist/card/index.d.cts +6 -1
- package/dist/card/index.d.ts +6 -1
- package/dist/card/index.js +4 -2
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +1067 -0
- package/dist/chart/index.d.cts +218 -0
- package/dist/chart/index.d.ts +218 -0
- package/dist/chart/index.js +1026 -0
- package/dist/checkbox/index.js +1 -2
- package/dist/chip/index.js +1 -2
- package/dist/chunk-3XSXTM3G.js +661 -0
- package/dist/chunk-4KSZLONZ.js +79 -0
- package/dist/{chunk-DXXNBF5P.js → chunk-CZFDZPAS.js} +0 -5
- package/dist/{chunk-LTKYHG5V.js → chunk-GHCVNQET.js} +12 -5
- package/dist/chunk-I4V5Y5GD.js +76 -0
- package/dist/{chunk-F7WH4DMG.js → chunk-UI5L26KD.js} +1 -1
- package/dist/{chunk-LUBWRVI2.js → chunk-ULJSCNPE.js} +1 -1
- package/dist/chunk-URBEEDFX.js +79 -0
- package/dist/core/index.js +3 -5
- package/dist/datepicker/index.js +1 -2
- package/dist/divider/index.js +2 -3
- package/dist/drawer/index.cjs +310 -0
- package/dist/drawer/index.d.cts +58 -0
- package/dist/drawer/index.d.ts +58 -0
- package/dist/drawer/index.js +236 -0
- package/dist/{accordion → expansion-panel}/index.cjs +45 -45
- package/dist/{accordion → expansion-panel}/index.d.cts +30 -30
- package/dist/{accordion → expansion-panel}/index.d.ts +30 -30
- package/dist/{accordion → expansion-panel}/index.js +40 -41
- package/dist/fab/index.d.cts +3 -3
- package/dist/fab/index.d.ts +3 -3
- package/dist/fab/index.js +3 -4
- package/dist/fab-menu/index.d.cts +2 -2
- package/dist/fab-menu/index.d.ts +2 -2
- package/dist/fab-menu/index.js +3 -4
- package/dist/{fab.type-Ba0QMprb.d.ts → fab.type-CgIYqQlT.d.ts} +1 -1
- package/dist/{fab.type-U09H8B7D.d.cts → fab.type-l2vjG8-p.d.cts} +1 -1
- package/dist/feature-discovery/index.cjs +531 -0
- package/dist/feature-discovery/index.d.cts +82 -0
- package/dist/feature-discovery/index.d.ts +82 -0
- package/dist/feature-discovery/index.js +464 -0
- package/dist/indicator/index.js +2 -3
- package/dist/input/index.cjs +258 -164
- package/dist/input/index.d.cts +15 -1
- package/dist/input/index.d.ts +15 -1
- package/dist/input/index.js +219 -126
- package/dist/list/index.js +1 -2
- package/dist/menu/index.js +2 -2
- package/dist/menubox/index.cjs +369 -0
- package/dist/menubox/index.d.cts +98 -0
- package/dist/menubox/index.d.ts +98 -0
- package/dist/menubox/index.js +296 -0
- package/dist/pager/index.cjs +243 -0
- package/dist/pager/index.d.cts +93 -0
- package/dist/pager/index.d.ts +93 -0
- package/dist/pager/index.js +205 -0
- package/dist/progress/index.js +1 -2
- package/dist/radio/index.cjs +537 -0
- package/dist/radio/index.d.cts +145 -0
- package/dist/radio/index.d.ts +145 -0
- package/dist/radio/index.js +464 -0
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.js +22 -10
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +655 -0
- package/dist/slider/index.d.cts +171 -0
- package/dist/slider/index.d.ts +171 -0
- package/dist/slider/index.js +575 -0
- package/dist/stepper/index.cjs +624 -0
- package/dist/stepper/index.d.cts +137 -0
- package/dist/stepper/index.d.ts +137 -0
- package/dist/stepper/index.js +549 -0
- package/dist/switch/index.js +1 -2
- package/dist/tabs/index.cjs +523 -0
- package/dist/tabs/index.d.cts +176 -0
- package/dist/tabs/index.d.ts +176 -0
- package/dist/tabs/index.js +438 -0
- package/dist/timepicker/index.cjs +1280 -0
- package/dist/timepicker/index.d.cts +215 -0
- package/dist/timepicker/index.d.ts +215 -0
- package/dist/timepicker/index.js +1181 -0
- package/dist/toolbar/index.cjs +395 -0
- package/dist/toolbar/index.d.cts +100 -0
- package/dist/toolbar/index.d.ts +100 -0
- package/dist/toolbar/index.js +325 -0
- package/dist/typography/index.js +1 -2
- package/dist/view/index.cjs +16 -2
- package/dist/view/index.js +16 -2
- package/package.json +73 -8
- package/dist/button.type-D8tzEBo7.d.ts +0 -104
- package/dist/button.type-ikaWzhIg.d.cts +0 -104
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-JEGEPGVU.js +0 -287
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import { T as ThemeColor, S as Size, R as Radius } from '../index-BOw6tbkc.js';
|
|
4
|
+
|
|
5
|
+
type RadioVariant = 'filled' | 'light';
|
|
6
|
+
type RadioLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
7
|
+
type RadioOrientation = 'vertical' | 'horizontal';
|
|
8
|
+
type RadioProps = {
|
|
9
|
+
/**
|
|
10
|
+
* The label to display alongside the radio.
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Value associated to this option when used inside RadioGroup.
|
|
15
|
+
*/
|
|
16
|
+
value?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Alignment of the label relative to the radio.
|
|
19
|
+
* @default 'right'
|
|
20
|
+
*/
|
|
21
|
+
labelAlignment?: RadioLabelAlignment;
|
|
22
|
+
/**
|
|
23
|
+
* The theme color of the radio.
|
|
24
|
+
* @default 'primary'
|
|
25
|
+
*/
|
|
26
|
+
themeColor?: ThemeColor;
|
|
27
|
+
/**
|
|
28
|
+
* The variant of the radio.
|
|
29
|
+
* @default 'filled'
|
|
30
|
+
*/
|
|
31
|
+
variant?: RadioVariant;
|
|
32
|
+
/**
|
|
33
|
+
* The size of the radio.
|
|
34
|
+
* @default 'md'
|
|
35
|
+
*/
|
|
36
|
+
size?: Size;
|
|
37
|
+
/**
|
|
38
|
+
* The border radius of the radio.
|
|
39
|
+
* @default 'full'
|
|
40
|
+
*/
|
|
41
|
+
radius?: Radius;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the radio should take full width.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
fullWidth?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Controlled checked state when used outside RadioGroup.
|
|
49
|
+
*/
|
|
50
|
+
isChecked?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Uncontrolled checked state when used outside RadioGroup.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
defaultChecked?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the radio is disabled.
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
isDisabled?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Custom style for label text.
|
|
63
|
+
*/
|
|
64
|
+
labelStyle?: TextStyle;
|
|
65
|
+
/**
|
|
66
|
+
* Custom style for container.
|
|
67
|
+
*/
|
|
68
|
+
style?: ViewStyle;
|
|
69
|
+
/**
|
|
70
|
+
* Callback fired when the radio checked state changes.
|
|
71
|
+
*/
|
|
72
|
+
onValueChange?: (isChecked: boolean) => void;
|
|
73
|
+
};
|
|
74
|
+
type RadioGroupProps = {
|
|
75
|
+
/**
|
|
76
|
+
* Group options.
|
|
77
|
+
*/
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
/**
|
|
80
|
+
* Controlled selected value.
|
|
81
|
+
*/
|
|
82
|
+
value?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Uncontrolled default selected value.
|
|
85
|
+
*/
|
|
86
|
+
defaultValue?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Callback fired when selected value changes.
|
|
89
|
+
*/
|
|
90
|
+
onValueChange?: (value: string) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Whether all radios in group are disabled.
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
isDisabled?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Shared theme color for radios.
|
|
98
|
+
* @default 'primary'
|
|
99
|
+
*/
|
|
100
|
+
themeColor?: ThemeColor;
|
|
101
|
+
/**
|
|
102
|
+
* Shared variant for radios.
|
|
103
|
+
* @default 'filled'
|
|
104
|
+
*/
|
|
105
|
+
variant?: RadioVariant;
|
|
106
|
+
/**
|
|
107
|
+
* Shared size for radios.
|
|
108
|
+
* @default 'md'
|
|
109
|
+
*/
|
|
110
|
+
size?: Size;
|
|
111
|
+
/**
|
|
112
|
+
* Shared radius for radios.
|
|
113
|
+
* @default 'full'
|
|
114
|
+
*/
|
|
115
|
+
radius?: Radius;
|
|
116
|
+
/**
|
|
117
|
+
* Shared label alignment for radios.
|
|
118
|
+
* @default 'right'
|
|
119
|
+
*/
|
|
120
|
+
labelAlignment?: RadioLabelAlignment;
|
|
121
|
+
/**
|
|
122
|
+
* Shared full width behavior for radios.
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
fullWidth?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Group orientation.
|
|
128
|
+
* @default 'vertical'
|
|
129
|
+
*/
|
|
130
|
+
orientation?: RadioOrientation;
|
|
131
|
+
/**
|
|
132
|
+
* Space between options.
|
|
133
|
+
*/
|
|
134
|
+
gap?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Custom style for the group container.
|
|
137
|
+
*/
|
|
138
|
+
style?: ViewStyle;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
declare const Radio: React.FC<RadioProps>;
|
|
142
|
+
|
|
143
|
+
declare const RadioGroup: React.FC<RadioGroupProps>;
|
|
144
|
+
|
|
145
|
+
export { Radio, RadioGroup, type RadioGroupProps, type RadioLabelAlignment, type RadioOrientation, type RadioProps, type RadioVariant };
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useXUITheme
|
|
3
|
+
} from "../chunk-4KSZLONZ.js";
|
|
4
|
+
|
|
5
|
+
// src/components/radio/radio.tsx
|
|
6
|
+
import React2, { useContext, useEffect, useRef, useState } from "react";
|
|
7
|
+
import { Animated as Animated2, Pressable, Text } from "react-native";
|
|
8
|
+
import { getSafeThemeColor as getSafeThemeColor2 } from "@xaui/core";
|
|
9
|
+
|
|
10
|
+
// src/components/radio/radio-context.ts
|
|
11
|
+
import React from "react";
|
|
12
|
+
var RadioGroupContext = React.createContext(
|
|
13
|
+
null
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// src/components/radio/radio.hook.ts
|
|
17
|
+
import { useMemo } from "react";
|
|
18
|
+
import { getSafeThemeColor } from "@xaui/core";
|
|
19
|
+
function useSizeStyles(size, variant) {
|
|
20
|
+
const theme = useXUITheme();
|
|
21
|
+
const sizeStyles = useMemo(() => {
|
|
22
|
+
const sizes = {
|
|
23
|
+
xs: {
|
|
24
|
+
radioSize: 14,
|
|
25
|
+
fontSize: theme.fontSizes.xs,
|
|
26
|
+
dotSize: variant === "light" ? 5 : 4
|
|
27
|
+
},
|
|
28
|
+
sm: {
|
|
29
|
+
radioSize: 18,
|
|
30
|
+
fontSize: theme.fontSizes.sm,
|
|
31
|
+
dotSize: variant === "light" ? 7 : 6
|
|
32
|
+
},
|
|
33
|
+
md: {
|
|
34
|
+
radioSize: 22,
|
|
35
|
+
fontSize: theme.fontSizes.md,
|
|
36
|
+
dotSize: variant === "light" ? 9 : 8
|
|
37
|
+
},
|
|
38
|
+
lg: {
|
|
39
|
+
radioSize: 26,
|
|
40
|
+
fontSize: theme.fontSizes.lg,
|
|
41
|
+
dotSize: variant === "light" ? 11 : 10
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return sizes[size];
|
|
45
|
+
}, [size, theme, variant]);
|
|
46
|
+
return sizeStyles;
|
|
47
|
+
}
|
|
48
|
+
function useRadiusStyles(radius) {
|
|
49
|
+
const theme = useXUITheme();
|
|
50
|
+
const radiusStyles = useMemo(() => {
|
|
51
|
+
const radii = {
|
|
52
|
+
none: theme.borderRadius.none,
|
|
53
|
+
sm: theme.borderRadius.sm,
|
|
54
|
+
md: theme.borderRadius.md,
|
|
55
|
+
lg: theme.borderRadius.lg,
|
|
56
|
+
full: theme.borderRadius.full
|
|
57
|
+
};
|
|
58
|
+
return { borderRadius: radii[radius] };
|
|
59
|
+
}, [radius, theme]);
|
|
60
|
+
return radiusStyles;
|
|
61
|
+
}
|
|
62
|
+
function useDotColors(themeColor, variant, isActive) {
|
|
63
|
+
const theme = useXUITheme();
|
|
64
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
65
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
66
|
+
const dotColors = useMemo(() => {
|
|
67
|
+
if (!isActive) {
|
|
68
|
+
return {
|
|
69
|
+
checked: "transparent"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (variant === "filled") {
|
|
73
|
+
return {
|
|
74
|
+
checked: colorScheme.foreground
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
checked: colorScheme.main
|
|
79
|
+
};
|
|
80
|
+
}, [colorScheme, isActive, variant]);
|
|
81
|
+
return dotColors;
|
|
82
|
+
}
|
|
83
|
+
function useVariantStyles(themeColor, variant, isActive) {
|
|
84
|
+
const theme = useXUITheme();
|
|
85
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
86
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
87
|
+
const variantStyles = useMemo(() => {
|
|
88
|
+
if (variant === "filled") {
|
|
89
|
+
return {
|
|
90
|
+
backgroundColor: "transparent",
|
|
91
|
+
borderWidth: isActive ? 0 : theme.borderWidth.md,
|
|
92
|
+
borderColor: isActive ? "transparent" : colorScheme.main
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
backgroundColor: "transparent",
|
|
97
|
+
borderWidth: theme.borderWidth.md,
|
|
98
|
+
borderColor: colorScheme.main
|
|
99
|
+
};
|
|
100
|
+
}, [colorScheme.main, isActive, theme.borderWidth.md, variant]);
|
|
101
|
+
return variantStyles;
|
|
102
|
+
}
|
|
103
|
+
function useContainerStyles(labelAlignment) {
|
|
104
|
+
const containerStyles = useMemo(() => {
|
|
105
|
+
const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
|
|
106
|
+
return {
|
|
107
|
+
flexDirection: labelAlignment === "left" || labelAlignment === "justify-left" ? "row-reverse" : "row",
|
|
108
|
+
justifyContent: isJustified ? "space-between" : "flex-start"
|
|
109
|
+
};
|
|
110
|
+
}, [labelAlignment]);
|
|
111
|
+
return containerStyles;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/components/radio/radio.style.ts
|
|
115
|
+
import { StyleSheet } from "react-native";
|
|
116
|
+
var styles = StyleSheet.create({
|
|
117
|
+
group: {
|
|
118
|
+
width: "100%"
|
|
119
|
+
},
|
|
120
|
+
container: {
|
|
121
|
+
flexDirection: "row",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
gap: 10
|
|
124
|
+
},
|
|
125
|
+
fullWidth: {
|
|
126
|
+
flexShrink: 1,
|
|
127
|
+
flexBasis: "auto",
|
|
128
|
+
width: "100%"
|
|
129
|
+
},
|
|
130
|
+
radio: {
|
|
131
|
+
alignItems: "center",
|
|
132
|
+
justifyContent: "center",
|
|
133
|
+
overflow: "hidden",
|
|
134
|
+
position: "relative"
|
|
135
|
+
},
|
|
136
|
+
background: {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
width: "100%",
|
|
139
|
+
height: "100%"
|
|
140
|
+
},
|
|
141
|
+
dot: {
|
|
142
|
+
zIndex: 10
|
|
143
|
+
},
|
|
144
|
+
label: {
|
|
145
|
+
fontWeight: "400"
|
|
146
|
+
},
|
|
147
|
+
disabled: {
|
|
148
|
+
opacity: 0.5
|
|
149
|
+
},
|
|
150
|
+
disabledText: {
|
|
151
|
+
opacity: 0.7
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// src/components/radio/radio.animation.ts
|
|
156
|
+
import { Animated } from "react-native";
|
|
157
|
+
var runDotInAnimation = (dotScale, dotOpacity) => {
|
|
158
|
+
Animated.parallel([
|
|
159
|
+
Animated.spring(dotScale, {
|
|
160
|
+
toValue: 1,
|
|
161
|
+
useNativeDriver: true,
|
|
162
|
+
tension: 90,
|
|
163
|
+
friction: 9
|
|
164
|
+
}),
|
|
165
|
+
Animated.timing(dotOpacity, {
|
|
166
|
+
toValue: 1,
|
|
167
|
+
duration: 180,
|
|
168
|
+
useNativeDriver: true
|
|
169
|
+
})
|
|
170
|
+
]).start();
|
|
171
|
+
};
|
|
172
|
+
var runDotOutAnimation = (dotScale, dotOpacity) => {
|
|
173
|
+
Animated.parallel([
|
|
174
|
+
Animated.spring(dotScale, {
|
|
175
|
+
toValue: 0,
|
|
176
|
+
useNativeDriver: true,
|
|
177
|
+
tension: 90,
|
|
178
|
+
friction: 9
|
|
179
|
+
}),
|
|
180
|
+
Animated.timing(dotOpacity, {
|
|
181
|
+
toValue: 0,
|
|
182
|
+
duration: 140,
|
|
183
|
+
useNativeDriver: true
|
|
184
|
+
})
|
|
185
|
+
]).start();
|
|
186
|
+
};
|
|
187
|
+
var runBackgroundInAnimation = (backgroundScale, backgroundOpacity) => {
|
|
188
|
+
Animated.parallel([
|
|
189
|
+
Animated.timing(backgroundScale, {
|
|
190
|
+
toValue: 1,
|
|
191
|
+
duration: 200,
|
|
192
|
+
useNativeDriver: true
|
|
193
|
+
}),
|
|
194
|
+
Animated.timing(backgroundOpacity, {
|
|
195
|
+
toValue: 1,
|
|
196
|
+
duration: 200,
|
|
197
|
+
useNativeDriver: true
|
|
198
|
+
})
|
|
199
|
+
]).start();
|
|
200
|
+
};
|
|
201
|
+
var runBackgroundOutAnimation = (backgroundScale, backgroundOpacity) => {
|
|
202
|
+
Animated.parallel([
|
|
203
|
+
Animated.timing(backgroundScale, {
|
|
204
|
+
toValue: 0.5,
|
|
205
|
+
duration: 200,
|
|
206
|
+
useNativeDriver: true
|
|
207
|
+
}),
|
|
208
|
+
Animated.timing(backgroundOpacity, {
|
|
209
|
+
toValue: 0,
|
|
210
|
+
duration: 200,
|
|
211
|
+
useNativeDriver: true
|
|
212
|
+
})
|
|
213
|
+
]).start();
|
|
214
|
+
};
|
|
215
|
+
var runPressInAnimation = (scale) => {
|
|
216
|
+
Animated.spring(scale, {
|
|
217
|
+
toValue: 0.95,
|
|
218
|
+
useNativeDriver: true
|
|
219
|
+
}).start();
|
|
220
|
+
};
|
|
221
|
+
var runPressOutAnimation = (scale) => {
|
|
222
|
+
Animated.spring(scale, {
|
|
223
|
+
toValue: 1,
|
|
224
|
+
useNativeDriver: true
|
|
225
|
+
}).start();
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/components/radio/radio.tsx
|
|
229
|
+
var Radio = ({
|
|
230
|
+
label,
|
|
231
|
+
value,
|
|
232
|
+
labelAlignment,
|
|
233
|
+
themeColor,
|
|
234
|
+
variant,
|
|
235
|
+
size,
|
|
236
|
+
radius,
|
|
237
|
+
fullWidth,
|
|
238
|
+
isChecked: isCheckedProp,
|
|
239
|
+
defaultChecked = false,
|
|
240
|
+
isDisabled,
|
|
241
|
+
labelStyle,
|
|
242
|
+
style,
|
|
243
|
+
onValueChange
|
|
244
|
+
}) => {
|
|
245
|
+
const group = useContext(RadioGroupContext);
|
|
246
|
+
const theme = useXUITheme();
|
|
247
|
+
const resolvedLabelAlignment = labelAlignment ?? group?.labelAlignment ?? "right";
|
|
248
|
+
const resolvedThemeColor = themeColor ?? group?.themeColor ?? "primary";
|
|
249
|
+
const resolvedVariant = variant ?? group?.variant ?? "filled";
|
|
250
|
+
const resolvedSize = size ?? group?.size ?? "md";
|
|
251
|
+
const resolvedRadius = radius ?? group?.radius ?? "full";
|
|
252
|
+
const resolvedFullWidth = fullWidth ?? group?.fullWidth ?? false;
|
|
253
|
+
const resolvedDisabled = !!(isDisabled || group?.isDisabled);
|
|
254
|
+
const isInGroup = !!group && typeof value === "string";
|
|
255
|
+
const isControlledStandalone = typeof isCheckedProp === "boolean";
|
|
256
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
257
|
+
const groupChecked = isInGroup ? group.selectedValue === value : false;
|
|
258
|
+
const isChecked = isInGroup ? groupChecked : isControlledStandalone ? isCheckedProp : internalChecked;
|
|
259
|
+
const colorScheme = theme.colors[getSafeThemeColor2(resolvedThemeColor)];
|
|
260
|
+
const scale = useRef(new Animated2.Value(1)).current;
|
|
261
|
+
const backgroundScale = useRef(new Animated2.Value(0.5)).current;
|
|
262
|
+
const backgroundOpacity = useRef(new Animated2.Value(0)).current;
|
|
263
|
+
const dotScale = useRef(new Animated2.Value(isChecked ? 1 : 0)).current;
|
|
264
|
+
const dotOpacity = useRef(new Animated2.Value(isChecked ? 1 : 0)).current;
|
|
265
|
+
const sizeStyles = useSizeStyles(resolvedSize, resolvedVariant);
|
|
266
|
+
const radiusStyles = useRadiusStyles(resolvedRadius);
|
|
267
|
+
const dotColors = useDotColors(resolvedThemeColor, resolvedVariant, isChecked);
|
|
268
|
+
const variantStyles = useVariantStyles(
|
|
269
|
+
resolvedThemeColor,
|
|
270
|
+
resolvedVariant,
|
|
271
|
+
isChecked
|
|
272
|
+
);
|
|
273
|
+
const containerStyles = useContainerStyles(resolvedLabelAlignment);
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
if (resolvedVariant !== "filled") return;
|
|
276
|
+
if (isChecked) {
|
|
277
|
+
runBackgroundInAnimation(backgroundScale, backgroundOpacity);
|
|
278
|
+
} else {
|
|
279
|
+
runBackgroundOutAnimation(backgroundScale, backgroundOpacity);
|
|
280
|
+
}
|
|
281
|
+
}, [backgroundOpacity, backgroundScale, isChecked, resolvedVariant]);
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
if (isChecked) {
|
|
284
|
+
runDotInAnimation(dotScale, dotOpacity);
|
|
285
|
+
} else {
|
|
286
|
+
runDotOutAnimation(dotScale, dotOpacity);
|
|
287
|
+
}
|
|
288
|
+
}, [dotOpacity, dotScale, isChecked]);
|
|
289
|
+
const handlePress = () => {
|
|
290
|
+
if (resolvedDisabled || isChecked) return;
|
|
291
|
+
if (isInGroup && value) {
|
|
292
|
+
group.onValueChange?.(value);
|
|
293
|
+
onValueChange?.(true);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (!isControlledStandalone) {
|
|
297
|
+
setInternalChecked(true);
|
|
298
|
+
}
|
|
299
|
+
onValueChange?.(true);
|
|
300
|
+
};
|
|
301
|
+
const handlePressIn = () => {
|
|
302
|
+
if (resolvedDisabled) return;
|
|
303
|
+
runPressInAnimation(scale);
|
|
304
|
+
};
|
|
305
|
+
const handlePressOut = () => {
|
|
306
|
+
if (resolvedDisabled) return;
|
|
307
|
+
runPressOutAnimation(scale);
|
|
308
|
+
};
|
|
309
|
+
return /* @__PURE__ */ React2.createElement(
|
|
310
|
+
Pressable,
|
|
311
|
+
{
|
|
312
|
+
onPress: handlePress,
|
|
313
|
+
onPressIn: handlePressIn,
|
|
314
|
+
onPressOut: handlePressOut,
|
|
315
|
+
disabled: resolvedDisabled,
|
|
316
|
+
accessible: true,
|
|
317
|
+
accessibilityRole: "radio",
|
|
318
|
+
accessibilityLabel: label,
|
|
319
|
+
accessibilityState: {
|
|
320
|
+
disabled: resolvedDisabled,
|
|
321
|
+
checked: !!isChecked
|
|
322
|
+
},
|
|
323
|
+
style: [
|
|
324
|
+
styles.container,
|
|
325
|
+
containerStyles,
|
|
326
|
+
resolvedFullWidth && styles.fullWidth,
|
|
327
|
+
resolvedDisabled && styles.disabled,
|
|
328
|
+
style
|
|
329
|
+
]
|
|
330
|
+
},
|
|
331
|
+
/* @__PURE__ */ React2.createElement(
|
|
332
|
+
Animated2.View,
|
|
333
|
+
{
|
|
334
|
+
style: [
|
|
335
|
+
styles.radio,
|
|
336
|
+
{
|
|
337
|
+
width: sizeStyles.radioSize,
|
|
338
|
+
height: sizeStyles.radioSize,
|
|
339
|
+
...radiusStyles,
|
|
340
|
+
...variantStyles
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
transform: [{ scale }]
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
},
|
|
347
|
+
resolvedVariant === "filled" && /* @__PURE__ */ React2.createElement(
|
|
348
|
+
Animated2.View,
|
|
349
|
+
{
|
|
350
|
+
style: [
|
|
351
|
+
styles.background,
|
|
352
|
+
radiusStyles,
|
|
353
|
+
{
|
|
354
|
+
backgroundColor: colorScheme.main,
|
|
355
|
+
transform: [{ scale: backgroundScale }],
|
|
356
|
+
opacity: backgroundOpacity
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
),
|
|
361
|
+
/* @__PURE__ */ React2.createElement(
|
|
362
|
+
Animated2.View,
|
|
363
|
+
{
|
|
364
|
+
style: [
|
|
365
|
+
styles.dot,
|
|
366
|
+
{
|
|
367
|
+
width: sizeStyles.dotSize,
|
|
368
|
+
height: sizeStyles.dotSize,
|
|
369
|
+
borderRadius: sizeStyles.dotSize / 2,
|
|
370
|
+
backgroundColor: dotColors.checked,
|
|
371
|
+
opacity: dotOpacity,
|
|
372
|
+
transform: [{ scale: dotScale }]
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
),
|
|
378
|
+
label && /* @__PURE__ */ React2.createElement(
|
|
379
|
+
Text,
|
|
380
|
+
{
|
|
381
|
+
style: [
|
|
382
|
+
styles.label,
|
|
383
|
+
{ fontSize: sizeStyles.fontSize, color: theme.colors.foreground },
|
|
384
|
+
resolvedDisabled && styles.disabledText,
|
|
385
|
+
labelStyle
|
|
386
|
+
]
|
|
387
|
+
},
|
|
388
|
+
label
|
|
389
|
+
)
|
|
390
|
+
);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/components/radio/radio-group.tsx
|
|
394
|
+
import React3, { useMemo as useMemo2, useState as useState2 } from "react";
|
|
395
|
+
import { View } from "react-native";
|
|
396
|
+
var RadioGroup = ({
|
|
397
|
+
children,
|
|
398
|
+
value,
|
|
399
|
+
defaultValue,
|
|
400
|
+
onValueChange,
|
|
401
|
+
isDisabled = false,
|
|
402
|
+
themeColor = "primary",
|
|
403
|
+
variant = "filled",
|
|
404
|
+
size = "md",
|
|
405
|
+
radius = "full",
|
|
406
|
+
labelAlignment = "right",
|
|
407
|
+
fullWidth = false,
|
|
408
|
+
orientation = "vertical",
|
|
409
|
+
gap,
|
|
410
|
+
style
|
|
411
|
+
}) => {
|
|
412
|
+
const theme = useXUITheme();
|
|
413
|
+
const isControlled = typeof value === "string";
|
|
414
|
+
const [internalValue, setInternalValue] = useState2(defaultValue);
|
|
415
|
+
const selectedValue = isControlled ? value : internalValue;
|
|
416
|
+
const handleValueChange = (nextValue) => {
|
|
417
|
+
if (nextValue === selectedValue) return;
|
|
418
|
+
if (!isControlled) {
|
|
419
|
+
setInternalValue(nextValue);
|
|
420
|
+
}
|
|
421
|
+
onValueChange?.(nextValue);
|
|
422
|
+
};
|
|
423
|
+
const contextValue = useMemo2(
|
|
424
|
+
() => ({
|
|
425
|
+
selectedValue,
|
|
426
|
+
isDisabled,
|
|
427
|
+
themeColor,
|
|
428
|
+
variant,
|
|
429
|
+
size,
|
|
430
|
+
radius,
|
|
431
|
+
labelAlignment,
|
|
432
|
+
fullWidth,
|
|
433
|
+
onValueChange: handleValueChange
|
|
434
|
+
}),
|
|
435
|
+
[
|
|
436
|
+
fullWidth,
|
|
437
|
+
isDisabled,
|
|
438
|
+
labelAlignment,
|
|
439
|
+
radius,
|
|
440
|
+
selectedValue,
|
|
441
|
+
size,
|
|
442
|
+
themeColor,
|
|
443
|
+
variant
|
|
444
|
+
]
|
|
445
|
+
);
|
|
446
|
+
return /* @__PURE__ */ React3.createElement(RadioGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ React3.createElement(
|
|
447
|
+
View,
|
|
448
|
+
{
|
|
449
|
+
style: [
|
|
450
|
+
styles.group,
|
|
451
|
+
{
|
|
452
|
+
flexDirection: orientation === "horizontal" ? "row" : "column",
|
|
453
|
+
gap: gap ?? theme.spacing.sm
|
|
454
|
+
},
|
|
455
|
+
style
|
|
456
|
+
]
|
|
457
|
+
},
|
|
458
|
+
children
|
|
459
|
+
));
|
|
460
|
+
};
|
|
461
|
+
export {
|
|
462
|
+
Radio,
|
|
463
|
+
RadioGroup
|
|
464
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-CZFDZPAS.js";
|
|
2
2
|
import {
|
|
3
3
|
useBorderRadiusStyles,
|
|
4
4
|
useXUITheme
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-I4V5Y5GD.js";
|
|
6
6
|
|
|
7
7
|
// src/components/segment-button/segment-button.tsx
|
|
8
8
|
import React, { useCallback, useMemo as useMemo2, useState } from "react";
|
package/dist/select/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CheckmarkIcon
|
|
3
|
-
} from "../chunk-GBHQCAKW.js";
|
|
4
|
-
import "../chunk-DXXNBF5P.js";
|
|
5
1
|
import {
|
|
6
2
|
useXUITheme
|
|
7
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-GHCVNQET.js";
|
|
8
4
|
|
|
9
5
|
// src/components/select/select.tsx
|
|
10
6
|
import React3, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
@@ -717,9 +713,25 @@ var Select = ({
|
|
|
717
713
|
};
|
|
718
714
|
|
|
719
715
|
// src/components/select/select-item.tsx
|
|
720
|
-
import
|
|
716
|
+
import React5, { useContext } from "react";
|
|
721
717
|
import { Pressable as Pressable3, Text as Text3, View as View3 } from "react-native";
|
|
722
718
|
|
|
719
|
+
// src/components/select/checkmark-icon.tsx
|
|
720
|
+
import React4 from "react";
|
|
721
|
+
import Svg2, { Polyline } from "react-native-svg";
|
|
722
|
+
function CheckmarkIcon({ color, size }) {
|
|
723
|
+
return /* @__PURE__ */ React4.createElement(Svg2, { width: size, height: size, viewBox: "0 0 17 18", fill: "none" }, /* @__PURE__ */ React4.createElement(
|
|
724
|
+
Polyline,
|
|
725
|
+
{
|
|
726
|
+
points: "1 9 7 14 15 4",
|
|
727
|
+
stroke: color,
|
|
728
|
+
strokeWidth: 2,
|
|
729
|
+
strokeLinecap: "round",
|
|
730
|
+
strokeLinejoin: "round"
|
|
731
|
+
}
|
|
732
|
+
));
|
|
733
|
+
}
|
|
734
|
+
|
|
723
735
|
// src/components/select/select-item.hook.ts
|
|
724
736
|
import { useMemo as useMemo3 } from "react";
|
|
725
737
|
import { getSafeThemeColor as getSafeThemeColor2 } from "@xaui/core";
|
|
@@ -839,7 +851,7 @@ var SelectItem = ({
|
|
|
839
851
|
}
|
|
840
852
|
onSelected?.();
|
|
841
853
|
};
|
|
842
|
-
return /* @__PURE__ */
|
|
854
|
+
return /* @__PURE__ */ React5.createElement(
|
|
843
855
|
Pressable3,
|
|
844
856
|
{
|
|
845
857
|
onPress: handlePress,
|
|
@@ -856,7 +868,7 @@ var SelectItem = ({
|
|
|
856
868
|
]
|
|
857
869
|
},
|
|
858
870
|
startContent,
|
|
859
|
-
/* @__PURE__ */
|
|
871
|
+
/* @__PURE__ */ React5.createElement(View3, { style: styles2.content }, /* @__PURE__ */ React5.createElement(
|
|
860
872
|
Text3,
|
|
861
873
|
{
|
|
862
874
|
style: [
|
|
@@ -866,7 +878,7 @@ var SelectItem = ({
|
|
|
866
878
|
]
|
|
867
879
|
},
|
|
868
880
|
label
|
|
869
|
-
), description && /* @__PURE__ */
|
|
881
|
+
), description && /* @__PURE__ */ React5.createElement(
|
|
870
882
|
Text3,
|
|
871
883
|
{
|
|
872
884
|
style: [
|
|
@@ -876,7 +888,7 @@ var SelectItem = ({
|
|
|
876
888
|
},
|
|
877
889
|
description
|
|
878
890
|
)),
|
|
879
|
-
isSelected && (selectedIcon || /* @__PURE__ */
|
|
891
|
+
isSelected && (selectedIcon || /* @__PURE__ */ React5.createElement(CheckmarkIcon, { color: checkmarkColor, size: 16 })),
|
|
880
892
|
endContent
|
|
881
893
|
);
|
|
882
894
|
};
|
package/dist/skeleton/index.js
CHANGED