@cdek-it/react-native-ui-kit 1.0.0-beta.6 → 1.0.0-beta.8
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.
|
@@ -74,7 +74,17 @@ export const InputTextBase = memo(
|
|
|
74
74
|
});
|
|
75
75
|
}, [isFocused, labelAnimation, value]);
|
|
76
76
|
const iconSize = useMemo(() => (floatLabel ? styles.iconSizeFloatLabel : styles.iconSize), [floatLabel, styles.iconSize, styles.iconSizeFloatLabel]);
|
|
77
|
-
|
|
77
|
+
const imperativeHandle = useMemo(() => new Proxy({}, {
|
|
78
|
+
get(_, prop) {
|
|
79
|
+
if (prop === 'clear') {
|
|
80
|
+
return clear;
|
|
81
|
+
}
|
|
82
|
+
const input = inputRef.current;
|
|
83
|
+
const value = input?.[prop];
|
|
84
|
+
return typeof value === 'function' ? value.bind(input) : value;
|
|
85
|
+
},
|
|
86
|
+
}), [clear]);
|
|
87
|
+
useImperativeHandle(propsInputRef, () => (inputRef.current ? imperativeHandle : null), [imperativeHandle]);
|
|
78
88
|
const { makeTestId } = useMakeTestId(otherProps.testID || InputTextBaseTestId.default);
|
|
79
89
|
const [userDefinedSecureTextEntry, setUserDefinedSecureTextEntry] = useState(true);
|
|
80
90
|
const secureTextEntry = useMemo(() => secureTextEntryProp === 'toggleable'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { memo, useCallback, useState } from 'react';
|
|
2
2
|
import { Pressable, View, } from 'react-native';
|
|
3
|
-
import Animated
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
5
6
|
export const RadioButton = memo(({ onPress, checked = false, disabled = false, state = 'default', testID, ...rest }) => {
|
|
6
7
|
const [pressed, setPressed] = useState(false);
|
|
7
8
|
radioStyles.useVariants({
|
|
@@ -13,49 +14,43 @@ export const RadioButton = memo(({ onPress, checked = false, disabled = false, s
|
|
|
13
14
|
const onPressIn = useCallback(() => setPressed(true), []);
|
|
14
15
|
const onPressOut = useCallback(() => setPressed(false), []);
|
|
15
16
|
return (<View>
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
<View style={radioStyles.center}/>
|
|
19
|
-
</
|
|
17
|
+
<Animated.View pointerEvents='none' style={radioStyles.outline}/>
|
|
18
|
+
<AnimatedPressable disabled={disabled} style={radioStyles.container} testID={testID || 'RadioButton_Pressable'} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut} {...rest}>
|
|
19
|
+
<Animated.View style={radioStyles.center}/>
|
|
20
|
+
</AnimatedPressable>
|
|
20
21
|
</View>);
|
|
21
22
|
});
|
|
22
|
-
const radioStyles = StyleSheet.create(({ theme }) => ({
|
|
23
|
+
const radioStyles = StyleSheet.create(({ theme, border }) => ({
|
|
23
24
|
container: {
|
|
24
25
|
width: theme.Form.RadioButton.radiobuttonWidth,
|
|
25
26
|
height: theme.Form.RadioButton.radiobuttonHeight,
|
|
26
|
-
borderRadius:
|
|
27
|
+
borderRadius: border.Radius['rounded-full'],
|
|
28
|
+
borderWidth: 1,
|
|
27
29
|
alignItems: 'center',
|
|
28
30
|
justifyContent: 'center',
|
|
29
|
-
|
|
31
|
+
transitionProperty: ['borderColor', 'backgroundColor'],
|
|
32
|
+
transitionDuration: 100,
|
|
30
33
|
variants: {
|
|
31
34
|
checked: {
|
|
32
35
|
true: {
|
|
33
36
|
borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
34
37
|
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
35
|
-
borderWidth: 5,
|
|
36
38
|
},
|
|
37
39
|
false: {
|
|
38
40
|
borderColor: theme.Form.InputText.inputBorderColor,
|
|
39
|
-
borderWidth: 1,
|
|
40
41
|
backgroundColor: theme.Form.InputText.inputBg,
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
|
-
pressed: {
|
|
44
|
-
true: { borderColor: theme.Form.InputText.inputHoverBorderColor },
|
|
45
|
-
false: {},
|
|
46
|
-
},
|
|
47
|
-
state: {
|
|
48
|
-
danger: { borderColor: theme.Form.InputText.inputErrorBorderColor },
|
|
49
|
-
},
|
|
44
|
+
pressed: { true: {}, false: {} },
|
|
50
45
|
disabled: {
|
|
51
46
|
true: {
|
|
52
47
|
borderColor: theme.Form.InputText.inputBorderColor,
|
|
53
48
|
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
54
49
|
opacity: 0.6,
|
|
55
|
-
borderWidth: 1,
|
|
56
50
|
},
|
|
57
51
|
false: {},
|
|
58
52
|
},
|
|
53
|
+
state: { danger: {}, default: {} },
|
|
59
54
|
},
|
|
60
55
|
compoundVariants: [
|
|
61
56
|
{
|
|
@@ -63,26 +58,28 @@ const radioStyles = StyleSheet.create(({ theme }) => ({
|
|
|
63
58
|
pressed: 'true',
|
|
64
59
|
styles: {
|
|
65
60
|
borderColor: theme.Form.RadioButton.radiobuttonActiveHoverBorderColor,
|
|
66
|
-
backgroundColor: theme.Form.RadioButton.
|
|
67
|
-
borderWidth: 5,
|
|
61
|
+
backgroundColor: theme.Form.RadioButton.radiobuttonActiveHoverBg,
|
|
68
62
|
},
|
|
69
63
|
},
|
|
70
64
|
{
|
|
71
|
-
state: 'danger',
|
|
72
65
|
checked: 'true',
|
|
66
|
+
disabled: 'true',
|
|
73
67
|
styles: {
|
|
74
|
-
borderColor: theme.Form.
|
|
68
|
+
borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
75
69
|
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
76
|
-
borderWidth: 1,
|
|
77
70
|
},
|
|
78
71
|
},
|
|
79
72
|
{
|
|
80
|
-
|
|
81
|
-
disabled: '
|
|
73
|
+
state: 'danger',
|
|
74
|
+
disabled: 'false',
|
|
75
|
+
checked: 'false',
|
|
76
|
+
styles: { borderColor: theme.Form.InputText.inputErrorBorderColor },
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
checked: 'false',
|
|
80
|
+
pressed: 'true',
|
|
82
81
|
styles: {
|
|
83
|
-
borderColor: theme.Form.RadioButton.
|
|
84
|
-
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
85
|
-
borderWidth: 5,
|
|
82
|
+
borderColor: theme.Form.RadioButton.radiobuttonActiveHoverBorderColor,
|
|
86
83
|
},
|
|
87
84
|
},
|
|
88
85
|
],
|
|
@@ -90,28 +87,27 @@ const radioStyles = StyleSheet.create(({ theme }) => ({
|
|
|
90
87
|
center: {
|
|
91
88
|
width: theme.Form.RadioButton.radiobuttonIconSize,
|
|
92
89
|
height: theme.Form.RadioButton.radiobuttonIconSize,
|
|
93
|
-
borderRadius:
|
|
90
|
+
borderRadius: border.Radius['rounded-full'],
|
|
94
91
|
backgroundColor: theme.Form.InputText.inputBg,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
compoundVariants: [
|
|
100
|
-
{
|
|
101
|
-
disabled: 'true',
|
|
102
|
-
checked: 'false',
|
|
103
|
-
styles: { backgroundColor: 'transparent' },
|
|
104
|
-
},
|
|
105
|
-
],
|
|
92
|
+
transitionProperty: ['opacity'],
|
|
93
|
+
transitionDuration: 100,
|
|
94
|
+
variants: { checked: { false: { opacity: 0 }, true: { opacity: 1 } } },
|
|
106
95
|
},
|
|
107
96
|
outline: {
|
|
108
97
|
position: 'absolute',
|
|
98
|
+
top: -theme.General.focusShadowWidth,
|
|
99
|
+
left: -theme.General.focusShadowWidth,
|
|
109
100
|
width: theme.Form.RadioButton.radiobuttonWidth +
|
|
110
101
|
theme.General.focusShadowWidth * 2,
|
|
111
102
|
height: theme.Form.RadioButton.radiobuttonHeight +
|
|
112
103
|
theme.General.focusShadowWidth * 2,
|
|
113
|
-
borderRadius:
|
|
114
|
-
theme.General.focusShadowWidth * 2,
|
|
104
|
+
borderRadius: border.Radius['rounded-full'],
|
|
115
105
|
backgroundColor: theme.General.focusOutlineErrorColor,
|
|
106
|
+
transitionProperty: 'opacity',
|
|
107
|
+
transitionDuration: 100,
|
|
108
|
+
variants: {
|
|
109
|
+
state: { danger: { opacity: 1 }, default: { opacity: 0 } },
|
|
110
|
+
disabled: { true: { opacity: 0 } },
|
|
111
|
+
},
|
|
116
112
|
},
|
|
117
113
|
}));
|
package/package.json
CHANGED