@cdek-it/react-native-ui-kit 1.0.0-beta.7 → 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.
@@ -1,7 +1,8 @@
1
1
  import { memo, useCallback, useState } from 'react';
2
2
  import { Pressable, View, } from 'react-native';
3
- import Animated, { LinearTransition } from 'react-native-reanimated';
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
- {!disabled && state === 'danger' && (<Animated.View layout={LinearTransition.duration(100)} style={radioStyles.outline}/>)}
17
- <Pressable disabled={disabled} style={radioStyles.container} testID={testID || 'RadioButton_Pressable'} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut} {...rest}>
18
- <View style={radioStyles.center}/>
19
- </Pressable>
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: theme.Form.RadioButton.radiobuttonWidth,
27
+ borderRadius: border.Radius['rounded-full'],
28
+ borderWidth: 1,
27
29
  alignItems: 'center',
28
30
  justifyContent: 'center',
29
- margin: theme.General.focusShadowWidth,
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.radiobuttonActiveHoverBorderColor,
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.InputText.inputErrorBorderColor,
68
+ borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
75
69
  backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
76
- borderWidth: 1,
77
70
  },
78
71
  },
79
72
  {
80
- checked: 'true',
81
- disabled: 'true',
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.radiobuttonActiveBorderColor,
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: theme.Form.RadioButton.radiobuttonIconSize,
90
+ borderRadius: border.Radius['rounded-full'],
94
91
  backgroundColor: theme.Form.InputText.inputBg,
95
- variants: {
96
- checked: { true: {}, false: {} },
97
- disabled: { true: {}, false: {} },
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: theme.Form.RadioButton.radiobuttonHeight +
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdek-it/react-native-ui-kit",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "UI kit на основе Prime Faces, Prime Flex для React Native",
5
5
  "license": "MIT",
6
6
  "homepage": "https://developer.cdek.ru/design-system",