@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.
Files changed (130) hide show
  1. package/README.md +9 -0
  2. package/dist/components/Accordion/Accordion.js +9 -10
  3. package/dist/components/Avatar/Avatar.js +7 -9
  4. package/dist/components/Badge/Badge.js +28 -20
  5. package/dist/components/Button/BaseButton.d.ts +3 -3
  6. package/dist/components/Button/BaseButton.js +12 -41
  7. package/dist/components/Button/Button.js +6 -4
  8. package/dist/components/Button/ButtonBadge.js +13 -12
  9. package/dist/components/Button/ButtonSeverity.js +6 -4
  10. package/dist/components/Button/index.d.ts +1 -1
  11. package/dist/components/Button/types.d.ts +2 -25
  12. package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -3
  13. package/dist/components/Button/utils/ButtonActivityIndicator.js +16 -12
  14. package/dist/components/Button/utils/ButtonContainer.d.ts +15 -6
  15. package/dist/components/Button/utils/ButtonContainer.js +424 -4
  16. package/dist/components/Button/utils/ButtonIcon.d.ts +8 -4
  17. package/dist/components/Button/utils/ButtonIcon.js +147 -4
  18. package/dist/components/Button/utils/ButtonLabel.d.ts +9 -4
  19. package/dist/components/Button/utils/ButtonLabel.js +139 -4
  20. package/dist/components/Button/utils/ButtonLeftArea.d.ts +9 -4
  21. package/dist/components/Button/utils/ButtonLeftArea.js +3 -3
  22. package/dist/components/Button/utils/ButtonPressedContext.d.ts +1 -0
  23. package/dist/components/Button/utils/ButtonPressedContext.js +2 -0
  24. package/dist/components/Button/utils/ButtonRightArea.d.ts +9 -3
  25. package/dist/components/Button/utils/ButtonRightArea.js +3 -3
  26. package/dist/components/Button/utils/ButtonVariantContext.d.ts +6 -0
  27. package/dist/components/Button/utils/ButtonVariantContext.js +4 -0
  28. package/dist/components/Checkbox/Checkbox.d.ts +6 -7
  29. package/dist/components/Checkbox/Checkbox.js +74 -22
  30. package/dist/components/Chip/Chip.js +13 -7
  31. package/dist/components/Dialog/DialogComponent.js +2 -3
  32. package/dist/components/Dialog/DialogHeader.js +17 -13
  33. package/dist/components/Divider/Divider.js +6 -6
  34. package/dist/components/Input/InputGroup.js +6 -13
  35. package/dist/components/Input/InputGroupAddon.js +5 -5
  36. package/dist/components/Input/InputOtp/InputOtp.js +2 -3
  37. package/dist/components/Input/InputOtp/InputOtpItem.js +2 -3
  38. package/dist/components/Input/InputSwitch/InputSwitch.js +2 -2
  39. package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +13 -11
  40. package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +6 -5
  41. package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +36 -29
  42. package/dist/components/Input/InputTextBase/InputTextBase.d.ts +0 -5
  43. package/dist/components/Input/InputTextBase/InputTextBase.js +41 -26
  44. package/dist/components/Input/InputTextBase/useInputStyles.d.ts +6 -5
  45. package/dist/components/Input/InputTextBase/useInputStyles.js +6 -9
  46. package/dist/components/Input/index.d.ts +0 -1
  47. package/dist/components/Input/index.js +0 -1
  48. package/dist/components/List/Base/ListBase.js +9 -12
  49. package/dist/components/MenuItem/MenuItemAccessory.js +5 -5
  50. package/dist/components/MenuItem/MenuItemIcon.js +4 -5
  51. package/dist/components/MenuItem/Template/MenuItemTemplate.js +8 -5
  52. package/dist/components/Message/Message.js +54 -38
  53. package/dist/components/ProgressBar/ProgressBar.js +2 -3
  54. package/dist/components/ProgressSpinner/ProgressSpinner.js +3 -4
  55. package/dist/components/RadioButton/RadioButton.js +87 -104
  56. package/dist/components/Rating/Rating.js +2 -3
  57. package/dist/components/Rating/RatingClear.js +10 -11
  58. package/dist/components/Rating/RatingItem.js +23 -24
  59. package/dist/components/Rating/RatingItemContainer.js +2 -3
  60. package/dist/components/SelectButton/SelectButton.js +2 -3
  61. package/dist/components/SelectButton/SelectButtonItem.js +22 -49
  62. package/dist/components/Skeleton/Skeleton.js +2 -3
  63. package/dist/components/Slider/Slider.js +4 -6
  64. package/dist/components/Tabs/TabItem/TabItem.js +12 -21
  65. package/dist/components/Tabs/Tabs.js +2 -3
  66. package/dist/components/Tag/Tag.js +44 -29
  67. package/dist/components/Timer/Timer.js +2 -3
  68. package/dist/components/Timer/TimerFlip.js +2 -3
  69. package/dist/components/ToggleButton/ToggleButton.js +159 -35
  70. package/dist/components/Typography/Anchor.js +11 -7
  71. package/dist/components/Typography/Body.js +2 -3
  72. package/dist/components/Typography/Caption.js +9 -4
  73. package/dist/components/Typography/Service.js +13 -7
  74. package/dist/components/Typography/Subtitle.js +3 -6
  75. package/dist/components/Typography/Title.js +3 -6
  76. package/dist/hooks/useChangeTheme.d.ts +2 -1
  77. package/dist/hooks/useChangeTheme.js +10 -3
  78. package/dist/hooks/useFonts.d.ts +2 -1
  79. package/dist/hooks/useFonts.js +3 -3
  80. package/dist/hooks/useLoadingRotationAnimation.d.ts +2 -2
  81. package/dist/hooks/useTheme.d.ts +2 -1
  82. package/dist/hooks/useTheme.js +6 -4
  83. package/dist/index.d.ts +3 -2
  84. package/dist/index.js +2 -1
  85. package/dist/theme/ThemeContext.d.ts +9 -7
  86. package/dist/theme/ThemeContext.js +21 -14
  87. package/dist/theme/darkTheme.js +1 -0
  88. package/dist/theme/index.d.ts +1 -1
  89. package/dist/theme/index.js +1 -1
  90. package/dist/theme/lightTheme.js +1 -0
  91. package/dist/theme/types.d.ts +1 -0
  92. package/dist/utils/SvgUniversal.d.ts +9 -14
  93. package/dist/utils/SvgUniversal.js +10 -2
  94. package/dist/utils/index.d.ts +1 -0
  95. package/dist/utils/index.js +1 -0
  96. package/package.json +45 -34
  97. package/dist/components/Button/styles/index.d.ts +0 -2
  98. package/dist/components/Button/styles/index.js +0 -2
  99. package/dist/components/Button/styles/useBasicButtonStyles.d.ts +0 -98
  100. package/dist/components/Button/styles/useBasicButtonStyles.js +0 -81
  101. package/dist/components/Button/styles/useDangerButtonStyles.d.ts +0 -63
  102. package/dist/components/Button/styles/useDangerButtonStyles.js +0 -57
  103. package/dist/components/Button/styles/useInfoButtonStyles.d.ts +0 -63
  104. package/dist/components/Button/styles/useInfoButtonStyles.js +0 -56
  105. package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +0 -64
  106. package/dist/components/Button/styles/useSeverityButtonStyles.js +0 -29
  107. package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +0 -63
  108. package/dist/components/Button/styles/useSuccessButtonStyles.js +0 -61
  109. package/dist/components/Button/styles/useWarningButtonStyles.d.ts +0 -63
  110. package/dist/components/Button/styles/useWarningButtonStyles.js +0 -61
  111. package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +0 -3
  112. package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +0 -141
  113. package/dist/components/Button/utils/useButtonLabelStyle.d.ts +0 -3
  114. package/dist/components/Button/utils/useButtonLabelStyle.js +0 -40
  115. package/dist/components/Button/utils/useIconStyle.d.ts +0 -7
  116. package/dist/components/Button/utils/useIconStyle.js +0 -35
  117. package/dist/components/Button/utils/useTypeBasedStyle.d.ts +0 -2
  118. package/dist/components/Button/utils/useTypeBasedStyle.js +0 -4
  119. package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +0 -15
  120. package/dist/components/Checkbox/hooks/usePressableStyles.js +0 -91
  121. package/dist/components/Input/FloatLabel.d.ts +0 -22
  122. package/dist/components/Input/FloatLabel.js +0 -19
  123. package/dist/components/ToggleButton/hooks/useIconSize.d.ts +0 -14
  124. package/dist/components/ToggleButton/hooks/useIconSize.js +0 -26
  125. package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +0 -8
  126. package/dist/components/ToggleButton/hooks/useLabelSize.js +0 -19
  127. package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +0 -11
  128. package/dist/components/ToggleButton/hooks/useStateStyles.js +0 -92
  129. package/dist/utils/makeStyles.d.ts +0 -11
  130. package/dist/utils/makeStyles.js +0 -19
@@ -1,58 +1,29 @@
1
1
  import { memo, useMemo, useState } from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import Animated, { interpolateColor, useAnimatedReaction, useAnimatedStyle, } from 'react-native-reanimated';
4
+ import { StyleSheet } from 'react-native-unistyles';
4
5
  import { scheduleOnRN } from 'react-native-worklets';
5
6
  import { SvgUniversal } from '../../utils/SvgUniversal';
6
- import { makeStyles } from '../../utils/makeStyles';
7
7
  /**
8
8
  * Дочерний элемент компонента SelectButton. Не используется отдельно от SelectButton.
9
9
  * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=481-4393
10
10
  */
11
11
  export const SelectButtonItem = memo(({ index, position, onPress, disabled, label, onLayout, size = 'base', showIcon = true, Icon, }) => {
12
- const styles = useStyles();
13
- const iconSize = useMemo(() => {
14
- switch (size) {
15
- case 'small':
16
- return styles.iconSmall;
17
- case 'base':
18
- return styles.iconBase;
19
- case 'large':
20
- return styles.iconLarge;
21
- case 'xlarge':
22
- return styles.iconXLarge;
23
- }
24
- }, [
25
- size,
26
- styles.iconBase,
27
- styles.iconLarge,
28
- styles.iconSmall,
29
- styles.iconXLarge,
30
- ]);
31
- const labelFontSize = useMemo(() => {
32
- switch (size) {
33
- case 'small':
34
- return styles.labelSmall;
35
- case 'base':
36
- return styles.labelBase;
37
- case 'large':
38
- return styles.labelLarge;
39
- case 'xlarge':
40
- return styles.labelXLarge;
41
- }
42
- }, [
43
- size,
44
- styles.labelBase,
45
- styles.labelLarge,
46
- styles.labelSmall,
47
- styles.labelXLarge,
48
- ]);
12
+ const sizeMap = useMemo(() => ({
13
+ small: { icon: styles.iconSmall, label: styles.labelSmall },
14
+ base: { icon: styles.iconBase, label: styles.labelBase },
15
+ large: { icon: styles.iconLarge, label: styles.labelLarge },
16
+ xlarge: { icon: styles.iconXLarge, label: styles.labelXLarge },
17
+ }), []);
18
+ const iconSize = sizeMap[size].icon;
19
+ const labelFontSize = sizeMap[size].label;
20
+ // Extract primitive color values before the worklet closure to avoid
21
+ // capturing the unistyles HostObject (non-serializable) in the worklet.
22
+ const textColor = styles.textColor.color;
23
+ const checkedTextColor = styles.checkedTextColor.color;
49
24
  const animatedColorStyle = useAnimatedStyle(() => {
50
25
  return {
51
- color: interpolateColor(position.value, [index - 1, index, index + 1], [
52
- styles.textColor.color,
53
- styles.checkedTextColor.color,
54
- styles.textColor.color,
55
- ]),
26
+ color: interpolateColor(position.value, [index - 1, index, index + 1], [textColor, checkedTextColor, textColor]),
56
27
  };
57
28
  });
58
29
  const [isSelected, setIsSelected] = useState(false);
@@ -66,11 +37,13 @@ export const SelectButtonItem = memo(({ index, position, onPress, disabled, labe
66
37
  styles[size],
67
38
  disabled && styles.disabledContainer,
68
39
  ]} testID='SelectButtonItem_TouchableOpacity' onLayout={onLayout} onPress={onPress}>
69
- {Icon && showIcon ? (<SvgUniversal height={iconSize.height} source={Icon} style={[
70
- styles.textColor,
71
- isSelected && styles.checkedTextColor,
72
- disabled && styles.disabledTextColor,
73
- ]} testID='SelectButtonItem_Icon' width={iconSize.width}/>) : null}
40
+ {Icon && showIcon ? (<SvgUniversal {...iconSize} source={Icon} testID='SelectButtonItem_Icon' uniProps={({ theme }) => ({
41
+ color: disabled
42
+ ? theme.Button.Disabled.disabledButtonBorderColor
43
+ : isSelected
44
+ ? theme.Form.SelectButton.selectButtonIconActiveColor
45
+ : theme.Form.SelectButton.selectButtonTextColor,
46
+ })}/>) : null}
74
47
  <Animated.Text numberOfLines={1} style={[
75
48
  styles.label,
76
49
  labelFontSize,
@@ -81,7 +54,7 @@ export const SelectButtonItem = memo(({ index, position, onPress, disabled, labe
81
54
  </Animated.Text>
82
55
  </TouchableOpacity>);
83
56
  });
84
- const useStyles = makeStyles(({ theme, typography, border, spacing, fonts }) => ({
57
+ const styles = StyleSheet.create(({ theme, typography, border, spacing, fonts }) => ({
85
58
  container: {
86
59
  flex: 1,
87
60
  flexDirection: 'row',
@@ -2,14 +2,13 @@ import { memo, useCallback, useContext, useEffect, useRef } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import Animated, { useAnimatedStyle, useSharedValue, } from 'react-native-reanimated';
4
4
  import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg';
5
+ import { StyleSheet } from 'react-native-unistyles';
5
6
  import { SkeletonContext } from '../../utils/SkeletonContext';
6
- import { makeStyles } from '../../utils/makeStyles';
7
7
  /**
8
8
  * Используется для отображения контента в момент загрузки
9
9
  * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=5241-3731
10
10
  */
11
11
  export const Skeleton = memo(({ style, testID, ...rest }) => {
12
- const styles = useStyles();
13
12
  const { globalTranslateX, registerSkeleton, unregisterSkeleton, skeletonWidth, } = useContext(SkeletonContext);
14
13
  const skeletonRef = useRef(null);
15
14
  const skeletonX = useSharedValue(0);
@@ -44,7 +43,7 @@ export const Skeleton = memo(({ style, testID, ...rest }) => {
44
43
  </Animated.View>
45
44
  </View>);
46
45
  });
47
- const useStyles = makeStyles(({ border, theme }) => ({
46
+ const styles = StyleSheet.create(({ border, theme }) => ({
48
47
  container: {
49
48
  borderRadius: border.Radius['rounded-lg'],
50
49
  overflow: 'hidden',
@@ -2,8 +2,8 @@ import { memo, useCallback, useMemo, useState } from 'react';
2
2
  import { View, } from 'react-native';
3
3
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
4
  import Animated, { useSharedValue, useAnimatedStyle, interpolate, Extrapolation, } from 'react-native-reanimated';
5
+ import { StyleSheet } from 'react-native-unistyles';
5
6
  import { scheduleOnRN } from 'react-native-worklets';
6
- import { makeStyles } from '../../utils/makeStyles';
7
7
  const MIN_TRACK_SCALE = 0;
8
8
  const MAX_TRACK_SCALE = 100;
9
9
  const clamp = (val, min, max) => {
@@ -16,9 +16,7 @@ const clamp = (val, min, max) => {
16
16
  */
17
17
  export const Slider = memo(
18
18
  // TODO: refactor component to fix max-statements
19
- // eslint-disable-next-line max-statements
20
19
  ({ disabled = false, range = false, minPointerValueInit = 0, maxPointerValueInit = 100, onMinPointerValueChange, onMaxPointerValueChange, testID, ...rest }) => {
21
- const styles = useStyles();
22
20
  const minPointX = useSharedValue(0);
23
21
  const maxPointX = useSharedValue(0);
24
22
  const trackWidth = useSharedValue(0);
@@ -26,8 +24,8 @@ export const Slider = memo(
26
24
  const [isPressed, setIsPressed] = useState(false);
27
25
  const prevMinPointX = useSharedValue(0);
28
26
  const prevMaxPointX = useSharedValue(0);
29
- const pointerStyle = useMemo(() => [styles.point, isPressed && styles.hovered], [styles.point, isPressed, styles.hovered]);
30
- const lineStyle = useMemo(() => [styles.line, isPressed && styles.hovered], [styles.line, isPressed, styles.hovered]);
27
+ const pointerStyle = useMemo(() => [styles.point, isPressed && styles.hovered], [isPressed]);
28
+ const lineStyle = useMemo(() => [styles.line, isPressed && styles.hovered], [isPressed]);
31
29
  const interpolateInitVal = useCallback((value, width) => {
32
30
  return interpolate(value, [MIN_TRACK_SCALE, MAX_TRACK_SCALE], [0, width - pointerWidth], Extrapolation.CLAMP);
33
31
  }, [pointerWidth]);
@@ -118,7 +116,7 @@ export const Slider = memo(
118
116
  </View>
119
117
  </View>);
120
118
  });
121
- const useStyles = makeStyles(({ theme, border }) => {
119
+ const styles = StyleSheet.create(({ theme, border }) => {
122
120
  return {
123
121
  container: {
124
122
  width: '100%',
@@ -1,24 +1,11 @@
1
- import { memo, useCallback } from 'react';
1
+ import { memo } from 'react';
2
2
  import { Text, Pressable, View } from 'react-native';
3
+ import { StyleSheet } from 'react-native-unistyles';
3
4
  import { SvgUniversal } from '../../../utils/SvgUniversal';
4
- import { makeStyles } from '../../../utils/makeStyles';
5
5
  // Часть навигационного компонента Tabs
6
6
  // @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=888-13076&t=hIQjdrqPKK8BWYev-4
7
7
  //
8
8
  export const TabItem = memo(({ Icon, label, badge, index, onPress, disabled, active, onLayout }) => {
9
- const styles = useStyles();
10
- const getIconColor = useCallback((pressed) => {
11
- if (disabled) {
12
- return styles.disabledIcon.color;
13
- }
14
- if (pressed) {
15
- return styles.pressedIcon.color;
16
- }
17
- if (active) {
18
- return styles.activeIcon.color;
19
- }
20
- return styles.icon.color;
21
- }, [disabled, active, styles]);
22
9
  return (<Pressable accessibilityRole='button' disabled={disabled} testID={TestId.Container + index} onLayout={onLayout} onPress={() => onPress(index)}>
23
10
  {({ pressed }) => (<View style={[
24
11
  styles.container,
@@ -26,7 +13,15 @@ export const TabItem = memo(({ Icon, label, badge, index, onPress, disabled, act
26
13
  active && styles.activeContainer,
27
14
  disabled && styles.disabledContainer,
28
15
  ]}>
29
- {Icon ? (<SvgUniversal color={getIconColor(pressed)} height={styles.icon.height} source={Icon} width={styles.icon.width}/>) : null}
16
+ {Icon ? (<SvgUniversal {...styles.icon} source={Icon} uniProps={({ theme }) => ({
17
+ color: disabled
18
+ ? theme.Button.Disabled.disabledButtonTextColor
19
+ : pressed
20
+ ? theme.Panel.TabView.tabviewHeaderHoverTextColor
21
+ : active
22
+ ? theme.Panel.TabView.tabviewHeaderActiveTextColor
23
+ : theme.Panel.TabView.tabviewHeaderTextColor,
24
+ })}/>) : null}
30
25
  <Text numberOfLines={1} style={[
31
26
  styles.text,
32
27
  active && styles.activeText,
@@ -39,7 +34,7 @@ export const TabItem = memo(({ Icon, label, badge, index, onPress, disabled, act
39
34
  </View>)}
40
35
  </Pressable>);
41
36
  });
42
- const useStyles = makeStyles(({ theme, typography, fonts }) => ({
37
+ const styles = StyleSheet.create(({ theme, typography, fonts }) => ({
43
38
  container: {
44
39
  alignItems: 'center',
45
40
  flexDirection: 'row',
@@ -60,11 +55,7 @@ const useStyles = makeStyles(({ theme, typography, fonts }) => ({
60
55
  icon: {
61
56
  width: theme.Menu.Item.menuitemSubmenuIconFontSize,
62
57
  height: theme.Menu.Item.menuitemSubmenuIconFontSize,
63
- color: theme.Panel.TabView.tabviewHeaderTextColor,
64
58
  },
65
- pressedIcon: { color: theme.Panel.TabView.tabviewHeaderHoverTextColor },
66
- activeIcon: { color: theme.Panel.TabView.tabviewHeaderActiveTextColor },
67
- disabledIcon: { color: theme.Button.Disabled.disabledButtonTextColor },
68
59
  text: {
69
60
  fontFamily: fonts.primary,
70
61
  fontSize: typography.Size['text-base'],
@@ -1,13 +1,12 @@
1
1
  import { memo, useEffect, useState } from 'react';
2
2
  import { View, } from 'react-native';
3
3
  import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
4
- import { makeStyles } from '../../utils/makeStyles';
4
+ import { StyleSheet } from 'react-native-unistyles';
5
5
  import { TabItem } from './TabItem/TabItem';
6
6
  // Навигационный компонент Tabs
7
7
  // @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=888-13076&t=hIQjdrqPKK8BWYev-4
8
8
  //
9
9
  export const Tabs = memo(({ items, disabled = false, activeIndex, onChange, testID, ...rest }) => {
10
- const styles = useStyles();
11
10
  const [tabsLayouts, setTabsLayouts] = useState({});
12
11
  const lineSharedValue = useSharedValue(activeIndex);
13
12
  const animatedStyles = useAnimatedStyle(() => {
@@ -32,7 +31,7 @@ export const Tabs = memo(({ items, disabled = false, activeIndex, onChange, test
32
31
  <Animated.View style={[styles.line, animatedStyles]}/>
33
32
  </View>);
34
33
  });
35
- const useStyles = makeStyles(({ theme, border }) => ({
34
+ const styles = StyleSheet.create(({ theme, border }) => ({
36
35
  container: {
37
36
  flexDirection: 'row',
38
37
  gap: theme.Panel.TabView.tabviewHeaderSpacing,
@@ -1,27 +1,33 @@
1
1
  import { memo } from 'react';
2
2
  import { View, Text, } from 'react-native';
3
+ import { StyleSheet } from 'react-native-unistyles';
3
4
  import { SvgUniversal } from '../../utils/SvgUniversal';
4
- import { makeStyles } from '../../utils/makeStyles';
5
+ const tagIconColor = {
6
+ basic: (t) => t.Misc.Badge.badgeTextColor,
7
+ info: (t) => t.Misc.Badge.badgeInfoTextColor,
8
+ success: (t) => t.Misc.Badge.badgeSuccessTextColor,
9
+ warning: (t) => t.Misc.Badge.badgeWarningTextColor,
10
+ danger: (t) => t.Misc.Badge.badgeDangerTextColor,
11
+ secondary: (t) => t.Misc.Badge.badgeTextColor,
12
+ };
5
13
  /**
6
14
  * Используется для маркировки элементов интерфейса
7
15
  * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4921
8
16
  */
9
17
  export const Tag = memo(({ text, rounded, severity = 'basic', showIcon = true, style, Icon, testID, ...rest }) => {
10
- const styles = useStyles();
18
+ tagStyles.useVariants({ severity });
11
19
  return (<View style={style} testID={testID || TagTestId.root} {...rest}>
12
- <View style={[
13
- styles.container,
14
- styles[severity],
15
- rounded && styles.roundedContainer,
16
- ]} testID={TagTestId.innerContainer}>
17
- {showIcon && Icon ? (<SvgUniversal color={styles[`text${severity}`].color} height={styles.icon.height} source={Icon} testID={TagTestId.icon} width={styles.icon.width}/>) : null}
18
- <Text numberOfLines={1} style={[styles.text, styles[`text${severity}`]]} testID={TagTestId.text}>
20
+ <View style={[tagStyles.container, rounded && tagStyles.roundedContainer]} testID={TagTestId.innerContainer}>
21
+ {showIcon && Icon ? (<SvgUniversal {...tagStyles.icon} source={Icon} testID={TagTestId.icon} uniProps={({ theme }) => ({
22
+ color: tagIconColor[severity](theme),
23
+ })}/>) : null}
24
+ <Text numberOfLines={1} style={tagStyles.text} testID={TagTestId.text}>
19
25
  {text}
20
26
  </Text>
21
27
  </View>
22
28
  </View>);
23
29
  });
24
- const useStyles = makeStyles(({ theme, border, spacing, typography, fonts }) => ({
30
+ const tagStyles = StyleSheet.create(({ theme, border, spacing, typography, fonts }) => ({
25
31
  container: {
26
32
  alignSelf: 'flex-start',
27
33
  flexDirection: 'row',
@@ -30,12 +36,29 @@ const useStyles = makeStyles(({ theme, border, spacing, typography, fonts }) =>
30
36
  paddingHorizontal: theme.Misc.Tag.tagPadding,
31
37
  height: theme.Misc.Tag.tagHeight,
32
38
  borderRadius: border.Radius['rounded-lg'],
39
+ variants: {
40
+ severity: {
41
+ basic: { backgroundColor: theme.Misc.Badge.badgeBg },
42
+ info: {
43
+ backgroundColor: theme.Button.Severity.Info.Basic.infoButtonBg,
44
+ },
45
+ success: {
46
+ backgroundColor: theme.Button.Severity.Success.Basic.successButtonBg,
47
+ },
48
+ warning: {
49
+ backgroundColor: theme.Button.Severity.Warning.Basic.warningButtonBg,
50
+ },
51
+ danger: {
52
+ backgroundColor: theme.Button.Severity.Danger.Basic.dangerButtonBg,
53
+ },
54
+ secondary: { backgroundColor: theme.Surface['surface-border'] },
55
+ },
56
+ },
33
57
  },
34
58
  roundedContainer: { borderRadius: border.Radius['rounded-full'] },
35
59
  icon: {
36
60
  width: theme.Misc.Tag.tagFontSize,
37
61
  height: theme.Misc.Tag.tagFontSize,
38
- color: theme.Misc.Badge.badgeTextColor,
39
62
  },
40
63
  text: {
41
64
  flexShrink: 1,
@@ -43,25 +66,17 @@ const useStyles = makeStyles(({ theme, border, spacing, typography, fonts }) =>
43
66
  includeFontPadding: false,
44
67
  verticalAlign: 'middle',
45
68
  fontFamily: fonts.primary,
69
+ variants: {
70
+ severity: {
71
+ basic: { color: theme.Misc.Badge.badgeTextColor },
72
+ info: { color: theme.Misc.Badge.badgeInfoTextColor },
73
+ success: { color: theme.Misc.Badge.badgeSuccessTextColor },
74
+ warning: { color: theme.Misc.Badge.badgeWarningTextColor },
75
+ danger: { color: theme.Misc.Badge.badgeDangerTextColor },
76
+ secondary: { color: theme.Misc.Badge.badgeTextColor },
77
+ },
78
+ },
46
79
  },
47
- textbasic: { color: theme.Misc.Badge.badgeTextColor },
48
- textinfo: { color: theme.Misc.Badge.badgeInfoTextColor },
49
- textwarning: { color: theme.Misc.Badge.badgeWarningTextColor },
50
- textsuccess: { color: theme.Misc.Badge.badgeSuccessTextColor },
51
- textdanger: { color: theme.Misc.Badge.badgeDangerTextColor },
52
- textsecondary: { color: theme.Misc.Badge.badgeTextColor },
53
- basic: { backgroundColor: theme.Misc.Badge.badgeBg },
54
- info: { backgroundColor: theme.Button.Severity.Info.Basic.infoButtonBg },
55
- success: {
56
- backgroundColor: theme.Button.Severity.Success.Basic.successButtonBg,
57
- },
58
- warning: {
59
- backgroundColor: theme.Button.Severity.Warning.Basic.warningButtonBg,
60
- },
61
- danger: {
62
- backgroundColor: theme.Button.Severity.Danger.Basic.dangerButtonBg,
63
- },
64
- secondary: { backgroundColor: theme.Surface['surface-border'] },
65
80
  }));
66
81
  export const TagTestId = {
67
82
  root: 'Tag',
@@ -2,7 +2,7 @@ import { memo, useEffect, useState } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import Animated, { cancelAnimation, Easing, useAnimatedProps, useSharedValue, withTiming, } from 'react-native-reanimated';
4
4
  import Svg, { Circle } from 'react-native-svg';
5
- import { makeStyles } from '../../utils/makeStyles';
5
+ import { StyleSheet } from 'react-native-unistyles';
6
6
  import { TimerFlip } from './TimerFlip';
7
7
  import { COUNTER_SIZE } from './constants';
8
8
  const AnimatedCircle = Animated.createAnimatedComponent(Circle);
@@ -12,7 +12,6 @@ const BORDER_WIDTH = 2;
12
12
  * @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=270-1514
13
13
  */
14
14
  export const Timer = memo(({ countFrom, onFinish }) => {
15
- const styles = useStyles();
16
15
  const circleAnimation = useSharedValue(0);
17
16
  const [currentTimerValue, setCurrentTimerValue] = useState(countFrom);
18
17
  const circumferenceRadius = COUNTER_SIZE / 2 - BORDER_WIDTH;
@@ -52,7 +51,7 @@ export const Timer = memo(({ countFrom, onFinish }) => {
52
51
  <TimerFlip value={currentTimerValue}/>
53
52
  </View>);
54
53
  });
55
- const useStyles = makeStyles(({ typography }) => ({
54
+ const styles = StyleSheet.create(({ typography }) => ({
56
55
  container: {
57
56
  overflow: 'hidden',
58
57
  width: COUNTER_SIZE,
@@ -1,11 +1,10 @@
1
1
  import React, { memo, useEffect, useState } from 'react';
2
2
  import { View, Text } from 'react-native';
3
3
  import Animated, { useSharedValue, useAnimatedStyle, 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 { COUNTER_SIZE } from './constants';
7
7
  export const TimerFlip = memo(({ value, duration = 300 }) => {
8
- const styles = useStyles();
9
8
  const [currentValue, setCurrentValue] = useState(value);
10
9
  const [nextValue, setNextValue] = useState(value);
11
10
  const progress = useSharedValue(0);
@@ -43,7 +42,7 @@ export const TimerFlip = memo(({ value, duration = 300 }) => {
43
42
  </Animated.View>
44
43
  </View>);
45
44
  });
46
- const useStyles = makeStyles(({ typography, fonts }) => ({
45
+ const styles = StyleSheet.create(({ typography, fonts }) => ({
47
46
  container: {
48
47
  overflow: 'hidden',
49
48
  width: COUNTER_SIZE,
@@ -1,39 +1,26 @@
1
1
  import { memo, useCallback, useMemo, useState } from 'react';
2
2
  import { Pressable, Text, View, } from 'react-native';
3
+ import { StyleSheet } from 'react-native-unistyles';
3
4
  import { SvgUniversal } from '../../utils/SvgUniversal';
4
- import { makeStyles } from '../../utils/makeStyles';
5
- import { useIconSize } from './hooks/useIconSize';
6
- import { useLabelSize } from './hooks/useLabelSize';
7
- import { useStateStyles } from './hooks/useStateStyles';
8
5
  /**
9
6
  * Используется для выбора нескольких значений с помощью кнопки
10
7
  * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4821
11
8
  */
12
- export const ToggleButton = memo(({ onPress, checked, disabled, iconOnly: iconOnlyProp, iconPos = 'left', label, size = 'base', style, Icon, testID, ...rest }) => {
13
- const styles = useStyles();
14
- const labelSize = useLabelSize(size);
15
- const iconSize = useIconSize(size);
9
+ export const ToggleButton = memo(({ onPress, checked = false, disabled = false, iconOnly: iconOnlyProp, iconPos = 'left', label, size = 'base', style, Icon, testID, ...rest }) => {
16
10
  const [pressed, setPressed] = useState(false);
17
- const stateStyles = useStateStyles(checked, disabled, pressed);
11
+ toggleStyles.useVariants({ size, checked, pressed, disabled });
18
12
  const iconOnly = useMemo(() => iconOnlyProp || !label, [iconOnlyProp, label]);
19
- const icon = useMemo(() => {
20
- if (!Icon) {
21
- return null;
22
- }
23
- return (<SvgUniversal height={iconSize.height} source={Icon} style={stateStyles.label} testID={ToggleButtonTestId.icon} width={iconSize.width}/>);
24
- }, [Icon, iconSize.height, iconSize.width, stateStyles.label]);
13
+ const icon = Icon ? (<SvgUniversal {...toggleStyles.icon} source={Icon} testID={ToggleButtonTestId.icon}/>) : null;
25
14
  const onPressIn = useCallback(() => setPressed(true), []);
26
15
  const onPressOut = useCallback(() => setPressed(false), []);
27
- return (<Pressable disabled={disabled} style={[styles.container, style, stateStyles.borderContainer]} testID={testID || ToggleButtonTestId.root} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut} {...rest}>
16
+ return (<Pressable disabled={disabled} style={[toggleStyles.container, style]} testID={testID || ToggleButtonTestId.root} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut} {...rest}>
28
17
  <View style={[
29
- styles.contentContainer,
30
- styles[size],
31
- iconOnly && styles.iconOnly,
32
- stateStyles.contentContainer,
18
+ toggleStyles.contentContainer,
19
+ iconOnly && toggleStyles.iconOnly,
33
20
  ]} testID={ToggleButtonTestId.container}>
34
21
  {iconOnly ? (icon) : (<>
35
22
  {iconPos === 'left' && icon}
36
- <Text style={[styles.label, labelSize, stateStyles.label]} testID={ToggleButtonTestId.text}>
23
+ <Text style={toggleStyles.label} testID={ToggleButtonTestId.text}>
37
24
  {label}
38
25
  </Text>
39
26
  {Icon && iconPos === 'right' ? icon : null}
@@ -41,12 +28,42 @@ export const ToggleButton = memo(({ onPress, checked, disabled, iconOnly: iconOn
41
28
  </View>
42
29
  </Pressable>);
43
30
  });
44
- const useStyles = makeStyles(({ theme, spacing, border, fonts }) => ({
31
+ const toggleStyles = StyleSheet.create(({ theme, spacing, border, fonts, typography }) => ({
45
32
  container: {
46
33
  alignSelf: 'flex-start',
47
34
  borderRadius: border.Radius['rounded-full'],
48
35
  borderWidth: border.Width.border,
49
36
  overflow: 'hidden',
37
+ variants: {
38
+ checked: {
39
+ true: {
40
+ borderColor: theme.Form.ToggleButton.toggleButtonActiveBorderColor,
41
+ },
42
+ false: {
43
+ borderColor: theme.Form.ToggleButton.toggleButtonBorderColor,
44
+ },
45
+ },
46
+ pressed: {
47
+ true: { borderColor: theme.Form.ToggleButton.toggleButtonHoverBg },
48
+ false: {},
49
+ },
50
+ disabled: {
51
+ true: {
52
+ borderColor: theme.Button.Disabled.disabledButtonBorderColor,
53
+ opacity: 0.6,
54
+ },
55
+ false: {},
56
+ },
57
+ },
58
+ compoundVariants: [
59
+ {
60
+ checked: 'true',
61
+ pressed: 'true',
62
+ styles: {
63
+ borderColor: theme.Form.ToggleButton.toggleButtonActiveHoverBorderColor,
64
+ },
65
+ },
66
+ ],
50
67
  },
51
68
  contentContainer: {
52
69
  flexDirection: 'row',
@@ -56,18 +73,47 @@ const useStyles = makeStyles(({ theme, spacing, border, fonts }) => ({
56
73
  paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
57
74
  paddingHorizontal: spacing.Padding['p-6'],
58
75
  gap: spacing.Gap['gap-3'],
59
- },
60
- xlarge: { minHeight: theme.Button.Common.buttonHeightXL },
61
- large: { minHeight: theme.Button.Common.buttonHeightLG },
62
- base: {
63
- minHeight: theme.Button.Common.buttonHeight,
64
- paddingHorizontal: theme.Button.Common.buttonPaddingLeftRight,
65
- gap: theme.General.inlineSpacing,
66
- },
67
- small: {
68
- minHeight: theme.Button.Common.buttonHeightSM,
69
- paddingHorizontal: spacing.Padding['p-3'],
70
- gap: theme.General.inlineSpacing,
76
+ variants: {
77
+ size: {
78
+ xlarge: { minHeight: theme.Button.Common.buttonHeightXL },
79
+ large: { minHeight: theme.Button.Common.buttonHeightLG },
80
+ base: {
81
+ minHeight: theme.Button.Common.buttonHeight,
82
+ paddingHorizontal: theme.Button.Common.buttonPaddingLeftRight,
83
+ gap: theme.General.inlineSpacing,
84
+ },
85
+ small: {
86
+ minHeight: theme.Button.Common.buttonHeightSM,
87
+ paddingHorizontal: spacing.Padding['p-3'],
88
+ gap: theme.General.inlineSpacing,
89
+ },
90
+ },
91
+ checked: {
92
+ true: {
93
+ backgroundColor: theme.Form.ToggleButton.toggleButtonActiveBg,
94
+ },
95
+ false: { backgroundColor: theme.Form.ToggleButton.toggleButtonBg },
96
+ },
97
+ pressed: {
98
+ true: {
99
+ backgroundColor: theme.Form.ToggleButton.toggleButtonHoverBg,
100
+ },
101
+ false: {},
102
+ },
103
+ disabled: {
104
+ true: { backgroundColor: theme.Button.Disabled.disabledButtonBg },
105
+ false: {},
106
+ },
107
+ },
108
+ compoundVariants: [
109
+ {
110
+ checked: 'true',
111
+ pressed: 'true',
112
+ styles: {
113
+ backgroundColor: theme.Form.ToggleButton.toggleButtonActiveHoverBg,
114
+ },
115
+ },
116
+ ],
71
117
  },
72
118
  iconOnly: {
73
119
  aspectRatio: 1,
@@ -75,7 +121,85 @@ const useStyles = makeStyles(({ theme, spacing, border, fonts }) => ({
75
121
  paddingVertical: 0,
76
122
  justifyContent: 'center',
77
123
  },
78
- label: { flexShrink: 1, fontFamily: fonts.primary },
124
+ icon: {
125
+ variants: {
126
+ size: {
127
+ xlarge: {
128
+ width: typography.Size['text-4xl'],
129
+ height: typography.Size['text-4xl'],
130
+ },
131
+ large: {
132
+ width: typography.Size['text-2xl'],
133
+ height: typography.Size['text-2xl'],
134
+ },
135
+ base: {
136
+ width: typography.Size['text-xl'],
137
+ height: typography.Size['text-xl'],
138
+ },
139
+ small: {
140
+ width: typography.Size['text-base'],
141
+ height: typography.Size['text-base'],
142
+ },
143
+ },
144
+ checked: {
145
+ true: { color: theme.Form.ToggleButton.toggleButtonActiveTextColor },
146
+ false: { color: theme.Form.ToggleButton.toggleButtonTextColor },
147
+ },
148
+ pressed: {
149
+ true: { color: theme.Form.ToggleButton.toggleButtonHoverTextColor },
150
+ false: {},
151
+ },
152
+ disabled: {
153
+ true: { color: theme.Button.Disabled.disabledButtonTextColor },
154
+ false: {},
155
+ },
156
+ },
157
+ compoundVariants: [
158
+ {
159
+ checked: 'true',
160
+ pressed: 'true',
161
+ styles: {
162
+ color: theme.Form.ToggleButton.toggleButtonTextActiveHoverColor,
163
+ },
164
+ },
165
+ ],
166
+ },
167
+ label: {
168
+ flexShrink: 1,
169
+ fontFamily: fonts.primary,
170
+ fontWeight: '600',
171
+ includeFontPadding: false,
172
+ verticalAlign: 'middle',
173
+ variants: {
174
+ size: {
175
+ xlarge: { fontSize: typography.Size['text-2xl'] },
176
+ large: { fontSize: typography.Size['text-xl'] },
177
+ base: { fontSize: typography.Size['text-base'] },
178
+ small: { fontSize: typography.Size['text-sm'] },
179
+ },
180
+ checked: {
181
+ true: { color: theme.Form.ToggleButton.toggleButtonActiveTextColor },
182
+ false: { color: theme.Form.ToggleButton.toggleButtonTextColor },
183
+ },
184
+ pressed: {
185
+ true: { color: theme.Form.ToggleButton.toggleButtonHoverTextColor },
186
+ false: {},
187
+ },
188
+ disabled: {
189
+ true: { color: theme.Button.Disabled.disabledButtonTextColor },
190
+ false: {},
191
+ },
192
+ },
193
+ compoundVariants: [
194
+ {
195
+ checked: 'true',
196
+ pressed: 'true',
197
+ styles: {
198
+ color: theme.Form.ToggleButton.toggleButtonTextActiveHoverColor,
199
+ },
200
+ },
201
+ ],
202
+ },
79
203
  }));
80
204
  export const ToggleButtonTestId = {
81
205
  root: 'ToggleButton',