@cdek-it/react-native-ui-kit 0.6.9 → 1.0.0-beta.1
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 +9 -0
- package/dist/components/Accordion/Accordion.js +9 -10
- package/dist/components/Avatar/Avatar.js +7 -9
- package/dist/components/Badge/Badge.js +28 -20
- package/dist/components/Button/BaseButton.d.ts +3 -3
- package/dist/components/Button/BaseButton.js +12 -41
- package/dist/components/Button/Button.js +6 -4
- package/dist/components/Button/ButtonBadge.js +13 -12
- package/dist/components/Button/ButtonSeverity.js +6 -4
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/types.d.ts +2 -25
- package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -3
- package/dist/components/Button/utils/ButtonActivityIndicator.js +16 -12
- package/dist/components/Button/utils/ButtonContainer.d.ts +15 -6
- package/dist/components/Button/utils/ButtonContainer.js +424 -4
- package/dist/components/Button/utils/ButtonIcon.d.ts +8 -4
- package/dist/components/Button/utils/ButtonIcon.js +147 -4
- package/dist/components/Button/utils/ButtonLabel.d.ts +9 -4
- package/dist/components/Button/utils/ButtonLabel.js +139 -4
- package/dist/components/Button/utils/ButtonLeftArea.d.ts +9 -4
- package/dist/components/Button/utils/ButtonLeftArea.js +3 -3
- package/dist/components/Button/utils/ButtonPressedContext.d.ts +1 -0
- package/dist/components/Button/utils/ButtonPressedContext.js +2 -0
- package/dist/components/Button/utils/ButtonRightArea.d.ts +9 -3
- package/dist/components/Button/utils/ButtonRightArea.js +3 -3
- package/dist/components/Button/utils/ButtonVariantContext.d.ts +6 -0
- package/dist/components/Button/utils/ButtonVariantContext.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +6 -7
- package/dist/components/Checkbox/Checkbox.js +74 -22
- package/dist/components/Chip/Chip.js +13 -7
- package/dist/components/Dialog/DialogComponent.js +2 -3
- package/dist/components/Dialog/DialogHeader.js +17 -13
- package/dist/components/Divider/Divider.js +6 -6
- package/dist/components/Input/InputGroup.js +6 -13
- package/dist/components/Input/InputGroupAddon.js +5 -5
- package/dist/components/Input/InputOtp/InputOtp.js +2 -3
- package/dist/components/Input/InputOtp/InputOtpItem.js +2 -3
- package/dist/components/Input/InputSwitch/InputSwitch.js +2 -2
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +13 -11
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +6 -5
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +36 -29
- package/dist/components/Input/InputTextBase/InputTextBase.d.ts +0 -5
- package/dist/components/Input/InputTextBase/InputTextBase.js +41 -26
- package/dist/components/Input/InputTextBase/useInputStyles.d.ts +6 -5
- package/dist/components/Input/InputTextBase/useInputStyles.js +6 -9
- package/dist/components/Input/index.d.ts +0 -1
- package/dist/components/Input/index.js +0 -1
- package/dist/components/List/Base/ListBase.js +9 -12
- package/dist/components/MenuItem/MenuItemAccessory.js +5 -5
- package/dist/components/MenuItem/MenuItemIcon.js +4 -5
- package/dist/components/MenuItem/Template/MenuItemTemplate.js +8 -5
- package/dist/components/Message/Message.js +54 -38
- package/dist/components/ProgressBar/ProgressBar.js +2 -3
- package/dist/components/ProgressSpinner/ProgressSpinner.js +3 -4
- package/dist/components/RadioButton/RadioButton.js +87 -104
- package/dist/components/Rating/Rating.js +2 -3
- package/dist/components/Rating/RatingClear.js +10 -11
- package/dist/components/Rating/RatingItem.js +23 -24
- package/dist/components/Rating/RatingItemContainer.js +2 -3
- package/dist/components/SelectButton/SelectButton.js +2 -3
- package/dist/components/SelectButton/SelectButtonItem.js +22 -49
- package/dist/components/Skeleton/Skeleton.js +2 -3
- package/dist/components/Slider/Slider.js +4 -6
- package/dist/components/Tabs/TabItem/TabItem.js +12 -21
- package/dist/components/Tabs/Tabs.js +2 -3
- package/dist/components/Tag/Tag.js +44 -29
- package/dist/components/Timer/Timer.js +2 -3
- package/dist/components/Timer/TimerFlip.js +2 -3
- package/dist/components/ToggleButton/ToggleButton.js +159 -35
- package/dist/components/Typography/Anchor.js +11 -7
- package/dist/components/Typography/Body.js +2 -3
- package/dist/components/Typography/Caption.js +9 -4
- package/dist/components/Typography/Service.js +13 -7
- package/dist/components/Typography/Subtitle.js +3 -6
- package/dist/components/Typography/Title.js +3 -6
- package/dist/hooks/useChangeTheme.d.ts +2 -1
- package/dist/hooks/useChangeTheme.js +10 -3
- package/dist/hooks/useFonts.d.ts +2 -1
- package/dist/hooks/useFonts.js +3 -3
- package/dist/hooks/useLoadingRotationAnimation.d.ts +2 -2
- package/dist/hooks/useTheme.d.ts +2 -1
- package/dist/hooks/useTheme.js +6 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/theme/ThemeContext.d.ts +9 -7
- package/dist/theme/ThemeContext.js +21 -14
- package/dist/theme/darkTheme.js +1 -0
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/lightTheme.js +1 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/utils/SvgUniversal.d.ts +9 -14
- package/dist/utils/SvgUniversal.js +10 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +45 -34
- package/dist/components/Button/styles/index.d.ts +0 -2
- package/dist/components/Button/styles/index.js +0 -2
- package/dist/components/Button/styles/useBasicButtonStyles.d.ts +0 -98
- package/dist/components/Button/styles/useBasicButtonStyles.js +0 -81
- package/dist/components/Button/styles/useDangerButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useDangerButtonStyles.js +0 -57
- package/dist/components/Button/styles/useInfoButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useInfoButtonStyles.js +0 -56
- package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +0 -64
- package/dist/components/Button/styles/useSeverityButtonStyles.js +0 -29
- package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useSuccessButtonStyles.js +0 -61
- package/dist/components/Button/styles/useWarningButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useWarningButtonStyles.js +0 -61
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +0 -3
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +0 -141
- package/dist/components/Button/utils/useButtonLabelStyle.d.ts +0 -3
- package/dist/components/Button/utils/useButtonLabelStyle.js +0 -40
- package/dist/components/Button/utils/useIconStyle.d.ts +0 -7
- package/dist/components/Button/utils/useIconStyle.js +0 -35
- package/dist/components/Button/utils/useTypeBasedStyle.d.ts +0 -2
- package/dist/components/Button/utils/useTypeBasedStyle.js +0 -4
- package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +0 -15
- package/dist/components/Checkbox/hooks/usePressableStyles.js +0 -91
- package/dist/components/Input/FloatLabel.d.ts +0 -22
- package/dist/components/Input/FloatLabel.js +0 -19
- package/dist/components/ToggleButton/hooks/useIconSize.d.ts +0 -14
- package/dist/components/ToggleButton/hooks/useIconSize.js +0 -26
- package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +0 -8
- package/dist/components/ToggleButton/hooks/useLabelSize.js +0 -19
- package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +0 -11
- package/dist/components/ToggleButton/hooks/useStateStyles.js +0 -92
- package/dist/utils/makeStyles.d.ts +0 -11
- package/dist/utils/makeStyles.js +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, useCallback, useMemo } from 'react';
|
|
2
2
|
import { View, Pressable, } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { Body, Caption } from '../../Typography';
|
|
5
5
|
import { MenuItemAccessory } from '../MenuItemAccessory';
|
|
6
6
|
import { MenuItemIcon } from '../MenuItemIcon';
|
|
@@ -10,14 +10,17 @@ import { MenuItemIcon } from '../MenuItemIcon';
|
|
|
10
10
|
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=937-6724&m=dev
|
|
11
11
|
*/
|
|
12
12
|
export const MenuItemTemplate = memo(({ title, caption, Icon, iconColor, badgeSeverity, PrefixIcon, SuffixIcon, extra, separator, testID, onPress, disabled, style, ...rest }) => {
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const iconStyle = useMemo(() => ({
|
|
14
|
+
width: styles.icon.width,
|
|
15
|
+
height: styles.icon.height,
|
|
16
|
+
color: iconColor || styles.icon.color,
|
|
17
|
+
}), [iconColor]);
|
|
15
18
|
const pressableStyle = useCallback(({ pressed }) => [
|
|
16
19
|
styles.container,
|
|
17
20
|
pressed && styles.containerPressed,
|
|
18
21
|
style,
|
|
19
22
|
disabled && styles.containerDisabled,
|
|
20
|
-
], [disabled,
|
|
23
|
+
], [disabled, style]);
|
|
21
24
|
return (<View style={separator ? styles.separator : null}>
|
|
22
25
|
<Pressable accessibilityLabel={title} accessibilityRole='button' accessibilityValue={{ text: caption }} disabled={disabled} style={pressableStyle} testID={testID || 'menuItemButton'} onPress={onPress} {...rest}>
|
|
23
26
|
<View style={styles.contentContainer}>
|
|
@@ -35,7 +38,7 @@ export const MenuItemTemplate = memo(({ title, caption, Icon, iconColor, badgeSe
|
|
|
35
38
|
</Pressable>
|
|
36
39
|
</View>);
|
|
37
40
|
});
|
|
38
|
-
const
|
|
41
|
+
const styles = StyleSheet.create(({ theme, spacing, typography, border }) => ({
|
|
39
42
|
container: {
|
|
40
43
|
borderColor: theme.Menu.Item.menuitemBorderColor,
|
|
41
44
|
borderWidth: border.Width.border,
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { IconAlertCircle, IconAlertTriangle, IconCircleCheck, IconInfoCircle, IconX, } from '@tabler/icons-react-native';
|
|
2
2
|
import { memo, useMemo } from 'react';
|
|
3
3
|
import { View, } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
5
|
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
5
|
-
import { makeStyles } from '../../utils/makeStyles';
|
|
6
6
|
import { ButtonSeverity } from '../Button/ButtonSeverity';
|
|
7
7
|
import { Timer } from '../Timer/Timer';
|
|
8
8
|
import { Body, Caption } from '../Typography';
|
|
9
|
+
const messageIconColor = {
|
|
10
|
+
info: (t) => t.Message.Severities.Info.infoMessageIconColor,
|
|
11
|
+
success: (t) => t.Message.Severities.Success.successMessageIconColor,
|
|
12
|
+
warning: (t) => t.Message.Severities.Warning.warningMessageIconColor,
|
|
13
|
+
danger: (t) => t.Message.Severities.Danger.dangerMessageIconColor,
|
|
14
|
+
};
|
|
9
15
|
/**
|
|
10
16
|
* Унифицированный компонент, который используется для отображения информационных сообщений
|
|
11
17
|
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=562-2947
|
|
12
18
|
*/
|
|
13
19
|
export const Message = memo(({ title, body, caption, footer, onClose, closeLabel, onTimerFinish, severity = 'info', hiddenIcon = false, style, testID, timerValue, Icon: IconProp, ...rest }) => {
|
|
14
|
-
|
|
20
|
+
messageStyles.useVariants({ severity });
|
|
15
21
|
const Icon = useMemo(() => {
|
|
16
22
|
if (IconProp) {
|
|
17
23
|
return IconProp;
|
|
@@ -36,21 +42,23 @@ export const Message = memo(({ title, body, caption, footer, onClose, closeLabel
|
|
|
36
42
|
return (<ButtonSeverity label={closeLabel} {...buttonCommonProps} testID={TestId.CloseButton}/>);
|
|
37
43
|
}
|
|
38
44
|
return (<ButtonSeverity iconOnly Icon={IconX} {...buttonCommonProps} testID={TestId.CloseButton}/>);
|
|
39
|
-
}, [closeLabel,
|
|
45
|
+
}, [closeLabel, onClose, severity]);
|
|
40
46
|
const LeftContent = useMemo(() => {
|
|
41
47
|
if (timerValue) {
|
|
42
48
|
return <Timer countFrom={timerValue} onFinish={onTimerFinish}/>;
|
|
43
49
|
}
|
|
44
50
|
if (!hiddenIcon) {
|
|
45
|
-
return (<SvgUniversal
|
|
51
|
+
return (<SvgUniversal {...messageStyles.iconSize} source={Icon} testID={TestId.Icon} uniProps={({ theme }) => ({
|
|
52
|
+
color: messageIconColor[severity](theme),
|
|
53
|
+
})}/>);
|
|
46
54
|
}
|
|
47
55
|
return undefined;
|
|
48
|
-
}, [
|
|
49
|
-
return (<View accessible style={[
|
|
50
|
-
<View style={
|
|
51
|
-
<View style={
|
|
56
|
+
}, [hiddenIcon, Icon, onTimerFinish, severity, timerValue]);
|
|
57
|
+
return (<View accessible style={[messageStyles.container, style]} testID={testID || TestId.Container} {...rest}>
|
|
58
|
+
<View style={messageStyles.content}>
|
|
59
|
+
<View style={messageStyles.titleRow}>
|
|
52
60
|
{LeftContent}
|
|
53
|
-
<View style={
|
|
61
|
+
<View style={messageStyles.titleTextContainer}>
|
|
54
62
|
<Body base testID={TestId.Title} weight='bold'>
|
|
55
63
|
{title}
|
|
56
64
|
</Body>
|
|
@@ -63,11 +71,31 @@ export const Message = memo(({ title, body, caption, footer, onClose, closeLabel
|
|
|
63
71
|
</View>
|
|
64
72
|
</View>);
|
|
65
73
|
});
|
|
66
|
-
const
|
|
74
|
+
const messageStyles = StyleSheet.create(({ theme, typography, spacing, border }) => ({
|
|
67
75
|
container: {
|
|
68
76
|
borderRadius: theme.General.borderRadiusXL,
|
|
69
77
|
borderWidth: border.Width.border,
|
|
70
78
|
overflow: 'hidden',
|
|
79
|
+
variants: {
|
|
80
|
+
severity: {
|
|
81
|
+
info: {
|
|
82
|
+
borderColor: theme.Message.Severities.Info.infoMessageBorderColor,
|
|
83
|
+
backgroundColor: theme.Message.Severities.Info.infoMessageBg,
|
|
84
|
+
},
|
|
85
|
+
success: {
|
|
86
|
+
borderColor: theme.Message.Severities.Success.successMessageBorderColor,
|
|
87
|
+
backgroundColor: theme.Message.Severities.Success.successMessageBg,
|
|
88
|
+
},
|
|
89
|
+
warning: {
|
|
90
|
+
borderColor: theme.Message.Severities.Warning.warningMessageBorderColor,
|
|
91
|
+
backgroundColor: theme.Message.Severities.Warning.warningMessageBg,
|
|
92
|
+
},
|
|
93
|
+
danger: {
|
|
94
|
+
borderColor: theme.Message.Severities.Danger.dangerMessageBorderColor,
|
|
95
|
+
backgroundColor: theme.Message.Severities.Danger.dangerMessageBg,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
71
99
|
},
|
|
72
100
|
content: {
|
|
73
101
|
flexGrow: 1,
|
|
@@ -75,34 +103,22 @@ const useStyles = makeStyles(({ theme, typography, spacing, border }) => ({
|
|
|
75
103
|
padding: spacing.Padding['p-4'],
|
|
76
104
|
paddingLeft: spacing.Padding['p-5'],
|
|
77
105
|
gap: spacing.Gap['gap-4'],
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
borderColor: theme.Message.Severities.Warning.warningMessageBorderColor,
|
|
95
|
-
backgroundColor: theme.Message.Severities.Warning.warningMessageBg,
|
|
96
|
-
},
|
|
97
|
-
contentwarning: {
|
|
98
|
-
borderColor: theme.Message.Severities.Warning.warningMessageIconColor,
|
|
99
|
-
},
|
|
100
|
-
danger: {
|
|
101
|
-
borderColor: theme.Message.Severities.Danger.dangerMessageBorderColor,
|
|
102
|
-
backgroundColor: theme.Message.Severities.Danger.dangerMessageBg,
|
|
103
|
-
},
|
|
104
|
-
contentdanger: {
|
|
105
|
-
borderColor: theme.Message.Severities.Danger.dangerMessageIconColor,
|
|
106
|
+
variants: {
|
|
107
|
+
severity: {
|
|
108
|
+
info: {
|
|
109
|
+
borderColor: theme.Message.Severities.Info.infoMessageIconColor,
|
|
110
|
+
},
|
|
111
|
+
success: {
|
|
112
|
+
borderColor: theme.Message.Severities.Success.successMessageIconColor,
|
|
113
|
+
},
|
|
114
|
+
warning: {
|
|
115
|
+
borderColor: theme.Message.Severities.Warning.warningMessageIconColor,
|
|
116
|
+
},
|
|
117
|
+
danger: {
|
|
118
|
+
borderColor: theme.Message.Severities.Danger.dangerMessageIconColor,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
106
122
|
},
|
|
107
123
|
titleRow: { flexDirection: 'row', gap: spacing.Gap['gap-4'] },
|
|
108
124
|
titleTextContainer: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { View, Text, } from 'react-native';
|
|
3
3
|
import Animated, { useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
-
import {
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
/**
|
|
6
6
|
* Компонент ProgressBar
|
|
7
7
|
* @param value - значение прогресса от 0 до 100
|
|
@@ -11,7 +11,6 @@ import { makeStyles } from '../../utils/makeStyles';
|
|
|
11
11
|
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5024&m=dev
|
|
12
12
|
*/
|
|
13
13
|
export const ProgressBar = memo(({ value: propsValue, showValue = false, style }) => {
|
|
14
|
-
const styles = useStyles();
|
|
15
14
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
16
15
|
const indicatorWidth = useSharedValue(0);
|
|
17
16
|
const onLayout = useCallback(({ nativeEvent: { layout: { width }, }, }) => {
|
|
@@ -39,7 +38,7 @@ export const ProgressBar = memo(({ value: propsValue, showValue = false, style }
|
|
|
39
38
|
</Animated.View>
|
|
40
39
|
</View>);
|
|
41
40
|
});
|
|
42
|
-
const
|
|
41
|
+
const styles = StyleSheet.create(({ theme, typography, border, fonts }) => ({
|
|
43
42
|
container: {
|
|
44
43
|
borderRadius: border.Radius['rounded-full'],
|
|
45
44
|
backgroundColor: theme.Misc.ProgressBar.progressBarBg,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memo, useEffect, useMemo } from 'react';
|
|
2
2
|
import Animated, { Easing, interpolate, useAnimatedProps, useAnimatedStyle, useSharedValue, withRepeat, withTiming, } from 'react-native-reanimated';
|
|
3
3
|
import Svg, { Circle } from 'react-native-svg';
|
|
4
|
-
import {
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
const AnimatedSvg = Animated.createAnimatedComponent(Svg);
|
|
6
6
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
7
7
|
const STROKE_WIDTH = 2;
|
|
@@ -10,7 +10,6 @@ const STROKE_WIDTH = 2;
|
|
|
10
10
|
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=1219-3086
|
|
11
11
|
*/
|
|
12
12
|
export const ProgressSpinner = memo(({ size = 'md', fill = 'primary' }) => {
|
|
13
|
-
const styles = useStyles();
|
|
14
13
|
const circleAnimation = useSharedValue(0);
|
|
15
14
|
const containerAnimation = useSharedValue(0);
|
|
16
15
|
const sizeInDp = useMemo(() => {
|
|
@@ -32,7 +31,7 @@ export const ProgressSpinner = memo(({ size = 'md', fill = 'primary' }) => {
|
|
|
32
31
|
case 'white':
|
|
33
32
|
return styles.white.color;
|
|
34
33
|
}
|
|
35
|
-
}, [fill
|
|
34
|
+
}, [fill]);
|
|
36
35
|
const center = useMemo(() => sizeInDp / 2, [sizeInDp]);
|
|
37
36
|
const radius = useMemo(() => center - STROKE_WIDTH / 2, [center]);
|
|
38
37
|
const circleLength = useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
@@ -56,7 +55,7 @@ export const ProgressSpinner = memo(({ size = 'md', fill = 'primary' }) => {
|
|
|
56
55
|
<AnimatedCircle animatedProps={circleAnimatedProps} cx={center} cy={center} fill='none' r={radius} stroke={color} strokeLinecap='round' strokeWidth={STROKE_WIDTH}/>
|
|
57
56
|
</AnimatedSvg>);
|
|
58
57
|
});
|
|
59
|
-
const
|
|
58
|
+
const styles = StyleSheet.create(({ theme, global }) => ({
|
|
60
59
|
primary: { color: theme.General.primaryColor },
|
|
61
60
|
white: { color: global.Neutrals.White['white-100'] },
|
|
62
61
|
}));
|
|
@@ -1,60 +1,25 @@
|
|
|
1
|
-
import { memo, useCallback,
|
|
2
|
-
import { Pressable,
|
|
1
|
+
import { memo, useCallback, useState } from 'react';
|
|
2
|
+
import { Pressable, View, } from 'react-native';
|
|
3
3
|
import Animated, { LinearTransition } from 'react-native-reanimated';
|
|
4
|
-
import {
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
export const RadioButton = memo(({ onPress, checked = false, disabled = false, state = 'default', testID, ...rest }) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (checked) {
|
|
16
|
-
result.push(styles.checkedPressed);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (state === 'danger') {
|
|
20
|
-
result.push(styles.danger);
|
|
21
|
-
if (checked) {
|
|
22
|
-
result.push(styles.dangerChecked);
|
|
23
|
-
if (pressed) {
|
|
24
|
-
result.push(styles.dangerCheckedPressed);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (disabled) {
|
|
29
|
-
result.push(styles.disabled);
|
|
30
|
-
if (checked) {
|
|
31
|
-
result.push(styles.disabledChecked);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return StyleSheet.flatten(result);
|
|
35
|
-
}, [
|
|
36
|
-
checked,
|
|
37
|
-
disabled,
|
|
38
|
-
state,
|
|
39
|
-
styles.container,
|
|
40
|
-
styles.default,
|
|
41
|
-
styles.pressed,
|
|
42
|
-
styles.checked,
|
|
43
|
-
styles.checkedPressed,
|
|
44
|
-
styles.danger,
|
|
45
|
-
styles.dangerChecked,
|
|
46
|
-
styles.dangerCheckedPressed,
|
|
47
|
-
styles.disabled,
|
|
48
|
-
styles.disabledChecked,
|
|
49
|
-
]);
|
|
6
|
+
const [pressed, setPressed] = useState(false);
|
|
7
|
+
radioStyles.useVariants({
|
|
8
|
+
checked: checked ? 'true' : 'false',
|
|
9
|
+
pressed: pressed ? 'true' : 'false',
|
|
10
|
+
state: state === 'danger' ? 'danger' : undefined,
|
|
11
|
+
disabled: disabled ? 'true' : 'false',
|
|
12
|
+
});
|
|
13
|
+
const onPressIn = useCallback(() => setPressed(true), []);
|
|
14
|
+
const onPressOut = useCallback(() => setPressed(false), []);
|
|
50
15
|
return (<View>
|
|
51
|
-
{!disabled && state === 'danger' && (<Animated.View layout={LinearTransition.duration(100)} style={
|
|
52
|
-
<Pressable disabled={disabled} style={
|
|
53
|
-
<View style={
|
|
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}/>
|
|
54
19
|
</Pressable>
|
|
55
20
|
</View>);
|
|
56
21
|
});
|
|
57
|
-
const
|
|
22
|
+
const radioStyles = StyleSheet.create(({ theme }) => ({
|
|
58
23
|
container: {
|
|
59
24
|
width: theme.Form.RadioButton.radiobuttonWidth,
|
|
60
25
|
height: theme.Form.RadioButton.radiobuttonHeight,
|
|
@@ -62,11 +27,82 @@ const useStyles = makeStyles(({ theme }) => ({
|
|
|
62
27
|
alignItems: 'center',
|
|
63
28
|
justifyContent: 'center',
|
|
64
29
|
margin: theme.General.focusShadowWidth,
|
|
30
|
+
variants: {
|
|
31
|
+
checked: {
|
|
32
|
+
true: {
|
|
33
|
+
borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
34
|
+
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
35
|
+
borderWidth: 5,
|
|
36
|
+
},
|
|
37
|
+
false: {
|
|
38
|
+
borderColor: theme.Form.InputText.inputBorderColor,
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
backgroundColor: theme.Form.InputText.inputBg,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
pressed: {
|
|
44
|
+
true: { borderColor: theme.Form.InputText.inputHoverBorderColor },
|
|
45
|
+
false: {},
|
|
46
|
+
},
|
|
47
|
+
state: {
|
|
48
|
+
danger: { borderColor: theme.Form.InputText.inputErrorBorderColor },
|
|
49
|
+
},
|
|
50
|
+
disabled: {
|
|
51
|
+
true: {
|
|
52
|
+
borderColor: theme.Form.InputText.inputBorderColor,
|
|
53
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
54
|
+
opacity: 0.6,
|
|
55
|
+
borderWidth: 1,
|
|
56
|
+
},
|
|
57
|
+
false: {},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
compoundVariants: [
|
|
61
|
+
{
|
|
62
|
+
checked: 'true',
|
|
63
|
+
pressed: 'true',
|
|
64
|
+
styles: {
|
|
65
|
+
borderColor: theme.Form.RadioButton.radiobuttonActiveHoverBorderColor,
|
|
66
|
+
backgroundColor: theme.Form.RadioButton.radiobuttonActiveHoverBorderColor,
|
|
67
|
+
borderWidth: 5,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
state: 'danger',
|
|
72
|
+
checked: 'true',
|
|
73
|
+
styles: {
|
|
74
|
+
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
75
|
+
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
76
|
+
borderWidth: 1,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
checked: 'true',
|
|
81
|
+
disabled: 'true',
|
|
82
|
+
styles: {
|
|
83
|
+
borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
84
|
+
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
85
|
+
borderWidth: 5,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
65
89
|
},
|
|
66
90
|
center: {
|
|
67
91
|
width: theme.Form.RadioButton.radiobuttonIconSize,
|
|
68
92
|
height: theme.Form.RadioButton.radiobuttonIconSize,
|
|
69
93
|
borderRadius: theme.Form.RadioButton.radiobuttonIconSize,
|
|
94
|
+
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
|
+
],
|
|
70
106
|
},
|
|
71
107
|
outline: {
|
|
72
108
|
position: 'absolute',
|
|
@@ -78,57 +114,4 @@ const useStyles = makeStyles(({ theme }) => ({
|
|
|
78
114
|
theme.General.focusShadowWidth * 2,
|
|
79
115
|
backgroundColor: theme.General.focusOutlineErrorColor,
|
|
80
116
|
},
|
|
81
|
-
// centerView
|
|
82
|
-
defaultView: { backgroundColor: theme.Form.InputText.inputBg },
|
|
83
|
-
disabledView: { backgroundColor: 'transparent' },
|
|
84
|
-
// container viewState
|
|
85
|
-
default: {
|
|
86
|
-
borderColor: theme.Form.InputText.inputBorderColor,
|
|
87
|
-
borderWidth: 1,
|
|
88
|
-
backgroundColor: theme.Form.InputText.inputBg,
|
|
89
|
-
},
|
|
90
|
-
pressed: {
|
|
91
|
-
borderColor: theme.Form.InputText.inputHoverBorderColor,
|
|
92
|
-
backgroundColor: theme.Form.InputText.inputBg,
|
|
93
|
-
borderWidth: 1,
|
|
94
|
-
},
|
|
95
|
-
checked: {
|
|
96
|
-
borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
97
|
-
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
98
|
-
borderWidth: 5,
|
|
99
|
-
},
|
|
100
|
-
checkedPressed: {
|
|
101
|
-
borderColor: theme.Form.RadioButton.radiobuttonActiveHoverBorderColor,
|
|
102
|
-
backgroundColor: theme.Form.RadioButton.radiobuttonActiveHoverBorderColor,
|
|
103
|
-
borderWidth: 5,
|
|
104
|
-
},
|
|
105
|
-
// danger viewState
|
|
106
|
-
danger: {
|
|
107
|
-
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
108
|
-
backgroundColor: theme.Form.InputText.inputBg,
|
|
109
|
-
borderWidth: 1,
|
|
110
|
-
},
|
|
111
|
-
dangerChecked: {
|
|
112
|
-
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
113
|
-
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
114
|
-
borderWidth: 1,
|
|
115
|
-
},
|
|
116
|
-
dangerCheckedPressed: {
|
|
117
|
-
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
118
|
-
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
119
|
-
borderWidth: 1,
|
|
120
|
-
},
|
|
121
|
-
// disabled viewState
|
|
122
|
-
disabled: {
|
|
123
|
-
borderColor: theme.Form.InputText.inputBorderColor,
|
|
124
|
-
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
125
|
-
opacity: 0.6,
|
|
126
|
-
borderWidth: 1,
|
|
127
|
-
mixBlendMode: 'luminosity',
|
|
128
|
-
},
|
|
129
|
-
disabledChecked: {
|
|
130
|
-
borderColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
131
|
-
backgroundColor: theme.Form.RadioButton.radiobuttonActiveBorderColor,
|
|
132
|
-
borderWidth: 5,
|
|
133
|
-
},
|
|
134
117
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, useCallback, useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { RatingClear } from './RatingClear';
|
|
5
5
|
import { RatingItem } from './RatingItem';
|
|
6
6
|
/**
|
|
@@ -16,7 +16,6 @@ import { RatingItem } from './RatingItem';
|
|
|
16
16
|
* @see RatingClear - элемент рейтинга для очистки
|
|
17
17
|
*/
|
|
18
18
|
export const Rating = memo(({ disabled = false, paddings = false, maxRating = 5, rating, onChange, onClear, testID, ...rest }) => {
|
|
19
|
-
const styles = useStyles();
|
|
20
19
|
const handleItemPress = useCallback((index) => () => {
|
|
21
20
|
onChange(index + 1);
|
|
22
21
|
}, [onChange]);
|
|
@@ -26,7 +25,7 @@ export const Rating = memo(({ disabled = false, paddings = false, maxRating = 5,
|
|
|
26
25
|
{renderArray.map((key, index) => (<RatingItem checked={index < rating} key={key} paddings={paddings} testID={`RatingItem-${index + 1}`} onPress={handleItemPress(index)}/>))}
|
|
27
26
|
</View>);
|
|
28
27
|
});
|
|
29
|
-
const
|
|
28
|
+
const styles = StyleSheet.create(({ theme }) => ({
|
|
30
29
|
container: {
|
|
31
30
|
flexDirection: 'row',
|
|
32
31
|
gap: theme.General.inlineSpacing,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IconBan } from '@tabler/icons-react-native';
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { SvgUniversal } from '../../utils';
|
|
4
5
|
import { RatingItemContainer, } from './RatingItemContainer';
|
|
5
6
|
/**
|
|
6
7
|
* Компонент элемента рейтинга для очистки рейтинга
|
|
@@ -8,21 +9,19 @@ import { RatingItemContainer, } from './RatingItemContainer';
|
|
|
8
9
|
* @see RatingItemContainer - компонент контейнер для элемента
|
|
9
10
|
*/
|
|
10
11
|
export const RatingClear = memo(({ ...rest }) => {
|
|
11
|
-
const styles = useStyles();
|
|
12
12
|
return (<RatingItemContainer {...rest}>
|
|
13
|
-
{({ disabled, pressed }) => (<IconBan
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
{({ disabled, pressed }) => (<SvgUniversal {...styles.icon} source={IconBan} uniProps={({ theme }) => ({
|
|
14
|
+
color: disabled
|
|
15
|
+
? theme.custom.rating.ratingCancelIconDisabledColor
|
|
16
|
+
: pressed
|
|
17
|
+
? theme.Form.Rating.ratingCancelIconHoverColor
|
|
18
|
+
: theme.Form.Rating.ratingCancelIconColor,
|
|
19
|
+
})}/>)}
|
|
18
20
|
</RatingItemContainer>);
|
|
19
21
|
});
|
|
20
|
-
const
|
|
22
|
+
const styles = StyleSheet.create(({ theme }) => ({
|
|
21
23
|
icon: {
|
|
22
24
|
height: theme.Form.Rating.ratingIconFontSize,
|
|
23
25
|
width: theme.Form.Rating.ratingIconFontSize,
|
|
24
|
-
color: theme.Form.Rating.ratingCancelIconColor,
|
|
25
26
|
},
|
|
26
|
-
iconPressed: { color: theme.Form.Rating.ratingCancelIconHoverColor },
|
|
27
|
-
iconDisabled: { color: theme.custom.rating.ratingCancelIconDisabledColor },
|
|
28
27
|
}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IconStar, IconStarFilled } from '@tabler/icons-react-native';
|
|
2
2
|
import { memo, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { SvgUniversal } from '../../utils';
|
|
4
5
|
import { RatingItemContainer, } from './RatingItemContainer';
|
|
5
6
|
/**
|
|
6
7
|
* Компонент элемента рейтинга с иконкой звёздочки
|
|
@@ -9,36 +10,34 @@ import { RatingItemContainer, } from './RatingItemContainer';
|
|
|
9
10
|
* @see RatingItemContainer - компонент контейнер для элемента
|
|
10
11
|
*/
|
|
11
12
|
export const RatingItem = memo(({ checked, ...rest }) => {
|
|
12
|
-
const styles = useStyles();
|
|
13
13
|
const Icon = useMemo(() => (checked ? IconStarFilled : IconStar), [checked]);
|
|
14
14
|
return (<RatingItemContainer {...rest}>
|
|
15
|
-
{({ pressed, disabled }) => (<Icon
|
|
16
|
-
|
|
17
|
-
?
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
? styles.iconPressed.color
|
|
21
|
-
: checked
|
|
22
|
-
? styles.iconChecked.color
|
|
23
|
-
: styles.icon.color} fill={checked
|
|
24
|
-
? disabled
|
|
25
|
-
? styles.iconCheckedDisabled.color
|
|
15
|
+
{({ pressed, disabled }) => (<SvgUniversal {...styles.icon} fillOpacity={checked ? 1 : 0} source={Icon} uniProps={({ theme }) => {
|
|
16
|
+
const color = disabled
|
|
17
|
+
? checked
|
|
18
|
+
? theme.custom.rating.ratingStarIconOnDisabledColor
|
|
19
|
+
: theme.custom.rating.ratingStarIconOffDisabledColor
|
|
26
20
|
: pressed
|
|
27
|
-
?
|
|
28
|
-
:
|
|
29
|
-
|
|
21
|
+
? theme.Form.Rating.ratingStarIconHoverColor
|
|
22
|
+
: checked
|
|
23
|
+
? theme.Form.Rating.ratingStarIconOnColor
|
|
24
|
+
: theme.Form.Rating.ratingStarIconOffColor;
|
|
25
|
+
return {
|
|
26
|
+
color,
|
|
27
|
+
fill: checked
|
|
28
|
+
? disabled
|
|
29
|
+
? theme.custom.rating.ratingStarIconOnDisabledColor
|
|
30
|
+
: pressed
|
|
31
|
+
? theme.Form.Rating.ratingStarIconHoverColor
|
|
32
|
+
: theme.Form.Rating.ratingStarIconOnColor
|
|
33
|
+
: undefined,
|
|
34
|
+
};
|
|
35
|
+
}}/>)}
|
|
30
36
|
</RatingItemContainer>);
|
|
31
37
|
});
|
|
32
|
-
const
|
|
38
|
+
const styles = StyleSheet.create(({ theme }) => ({
|
|
33
39
|
icon: {
|
|
34
40
|
height: theme.Form.Rating.ratingIconFontSize,
|
|
35
41
|
width: theme.Form.Rating.ratingIconFontSize,
|
|
36
|
-
color: theme.Form.Rating.ratingStarIconOffColor,
|
|
37
|
-
},
|
|
38
|
-
iconPressed: { color: theme.Form.Rating.ratingStarIconHoverColor },
|
|
39
|
-
iconChecked: { color: theme.Form.Rating.ratingStarIconOnColor },
|
|
40
|
-
iconDisabled: { color: theme.custom.rating.ratingStarIconOffDisabledColor },
|
|
41
|
-
iconCheckedDisabled: {
|
|
42
|
-
color: theme.custom.rating.ratingStarIconOnDisabledColor,
|
|
43
42
|
},
|
|
44
43
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { Pressable } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
/**
|
|
5
5
|
* Компонент контейнера для элемента в компоненте рейтинга
|
|
6
6
|
* @param disabled - управление состоянием включённости компонента для нажатий пользователем
|
|
@@ -11,12 +11,11 @@ import { makeStyles } from '../../utils/makeStyles';
|
|
|
11
11
|
* @see RatingClear - вариация компонента элемента рейтинга с иконкой очистки
|
|
12
12
|
*/
|
|
13
13
|
export const RatingItemContainer = memo(({ disabled = false, paddings = false, children, ...rest }) => {
|
|
14
|
-
const styles = useStyles();
|
|
15
14
|
return (<Pressable disabled={disabled} style={[styles.container, paddings && styles.containerWithPaddings]} {...rest}>
|
|
16
15
|
{({ pressed }) => children({ disabled, pressed })}
|
|
17
16
|
</Pressable>);
|
|
18
17
|
});
|
|
19
|
-
const
|
|
18
|
+
const styles = StyleSheet.create(({ theme, sizing }) => ({
|
|
20
19
|
container: {
|
|
21
20
|
alignItems: 'center',
|
|
22
21
|
justifyContent: 'center',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { View, } from 'react-native';
|
|
3
3
|
import Animated, { Easing, interpolate, useAnimatedReaction, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
5
|
import { scheduleOnRN } from 'react-native-worklets';
|
|
5
|
-
import { makeStyles } from '../../utils/makeStyles';
|
|
6
6
|
import { SelectButtonItem, } from './SelectButtonItem';
|
|
7
7
|
const DEFAULT_ANIMATION_DURATION = 200; // ms
|
|
8
8
|
/**
|
|
@@ -10,7 +10,6 @@ const DEFAULT_ANIMATION_DURATION = 200; // ms
|
|
|
10
10
|
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4921
|
|
11
11
|
*/
|
|
12
12
|
export const SelectButton = memo(({ buttons, disabled, initialIndex: initialIndexProp, onPress: onPressProp, size, style, testID, position: positionProp, ...rest }) => {
|
|
13
|
-
const styles = useStyles();
|
|
14
13
|
const buttonsLayoutListRef = useRef([]);
|
|
15
14
|
const buttonsLayoutList = useSharedValue([]);
|
|
16
15
|
const [frameKey, setFrameKey] = useState(Date.now());
|
|
@@ -52,7 +51,7 @@ export const SelectButton = memo(({ buttons, disabled, initialIndex: initialInde
|
|
|
52
51
|
{!disabled && (<Animated.View key={frameKey} style={[styles.frame, framePositionStyle]} testID='SelectButton_AnimatedFrame'/>)}
|
|
53
52
|
</View>);
|
|
54
53
|
});
|
|
55
|
-
const
|
|
54
|
+
const styles = StyleSheet.create(({ theme }) => ({
|
|
56
55
|
container: {
|
|
57
56
|
flexDirection: 'row',
|
|
58
57
|
padding: theme.Form.SelectButton.selectButtonGroupPadding,
|