@cdek-it/react-native-ui-kit 0.2.0

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 (261) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -0
  3. package/dist/components/Accordion/Accordion.d.ts +39 -0
  4. package/dist/components/Accordion/Accordion.js +103 -0
  5. package/dist/components/Accordion/index.d.ts +1 -0
  6. package/dist/components/Accordion/index.js +1 -0
  7. package/dist/components/Avatar/Avatar.d.ts +96 -0
  8. package/dist/components/Avatar/Avatar.js +121 -0
  9. package/dist/components/Avatar/index.d.ts +1 -0
  10. package/dist/components/Avatar/index.js +1 -0
  11. package/dist/components/Badge/Badge.d.ts +35 -0
  12. package/dist/components/Badge/Badge.js +74 -0
  13. package/dist/components/Badge/index.d.ts +1 -0
  14. package/dist/components/Badge/index.js +1 -0
  15. package/dist/components/Button/BaseButton.d.ts +5 -0
  16. package/dist/components/Button/BaseButton.js +62 -0
  17. package/dist/components/Button/Button.d.ts +16 -0
  18. package/dist/components/Button/Button.js +21 -0
  19. package/dist/components/Button/ButtonBadge.d.ts +21 -0
  20. package/dist/components/Button/ButtonBadge.js +53 -0
  21. package/dist/components/Button/ButtonSeverity.d.ts +17 -0
  22. package/dist/components/Button/ButtonSeverity.js +22 -0
  23. package/dist/components/Button/index.d.ts +4 -0
  24. package/dist/components/Button/index.js +3 -0
  25. package/dist/components/Button/styles/index.d.ts +2 -0
  26. package/dist/components/Button/styles/index.js +2 -0
  27. package/dist/components/Button/styles/useBasicButtonStyles.d.ts +98 -0
  28. package/dist/components/Button/styles/useBasicButtonStyles.js +81 -0
  29. package/dist/components/Button/styles/useDangerButtonStyles.d.ts +63 -0
  30. package/dist/components/Button/styles/useDangerButtonStyles.js +57 -0
  31. package/dist/components/Button/styles/useInfoButtonStyles.d.ts +63 -0
  32. package/dist/components/Button/styles/useInfoButtonStyles.js +56 -0
  33. package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +64 -0
  34. package/dist/components/Button/styles/useSeverityButtonStyles.js +29 -0
  35. package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +63 -0
  36. package/dist/components/Button/styles/useSuccessButtonStyles.js +61 -0
  37. package/dist/components/Button/styles/useWarningButtonStyles.d.ts +63 -0
  38. package/dist/components/Button/styles/useWarningButtonStyles.js +61 -0
  39. package/dist/components/Button/types.d.ts +107 -0
  40. package/dist/components/Button/types.js +0 -0
  41. package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -0
  42. package/dist/components/Button/utils/ButtonActivityIndicator.js +17 -0
  43. package/dist/components/Button/utils/ButtonContainer.d.ts +7 -0
  44. package/dist/components/Button/utils/ButtonContainer.js +10 -0
  45. package/dist/components/Button/utils/ButtonIcon.d.ts +4 -0
  46. package/dist/components/Button/utils/ButtonIcon.js +11 -0
  47. package/dist/components/Button/utils/ButtonLabel.d.ts +4 -0
  48. package/dist/components/Button/utils/ButtonLabel.js +13 -0
  49. package/dist/components/Button/utils/ButtonLeftArea.d.ts +4 -0
  50. package/dist/components/Button/utils/ButtonLeftArea.js +13 -0
  51. package/dist/components/Button/utils/ButtonRightArea.d.ts +3 -0
  52. package/dist/components/Button/utils/ButtonRightArea.js +13 -0
  53. package/dist/components/Button/utils/index.d.ts +4 -0
  54. package/dist/components/Button/utils/index.js +4 -0
  55. package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +3 -0
  56. package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +141 -0
  57. package/dist/components/Button/utils/useButtonLabelStyle.d.ts +3 -0
  58. package/dist/components/Button/utils/useButtonLabelStyle.js +40 -0
  59. package/dist/components/Button/utils/useIconStyle.d.ts +7 -0
  60. package/dist/components/Button/utils/useIconStyle.js +35 -0
  61. package/dist/components/Button/utils/useTypeBasedStyle.d.ts +2 -0
  62. package/dist/components/Button/utils/useTypeBasedStyle.js +4 -0
  63. package/dist/components/Checkbox/Checkbox.d.ts +31 -0
  64. package/dist/components/Checkbox/Checkbox.js +55 -0
  65. package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +15 -0
  66. package/dist/components/Checkbox/hooks/usePressableStyles.js +91 -0
  67. package/dist/components/Checkbox/index.d.ts +1 -0
  68. package/dist/components/Checkbox/index.js +1 -0
  69. package/dist/components/Chip/Chip.d.ts +30 -0
  70. package/dist/components/Chip/Chip.js +70 -0
  71. package/dist/components/Chip/index.d.ts +1 -0
  72. package/dist/components/Chip/index.js +1 -0
  73. package/dist/components/Dialog/Dialog.d.ts +14 -0
  74. package/dist/components/Dialog/Dialog.js +96 -0
  75. package/dist/components/Dialog/DialogComponent.d.ts +7 -0
  76. package/dist/components/Dialog/DialogComponent.js +34 -0
  77. package/dist/components/Dialog/DialogHeader.d.ts +12 -0
  78. package/dist/components/Dialog/DialogHeader.js +68 -0
  79. package/dist/components/Dialog/index.d.ts +3 -0
  80. package/dist/components/Dialog/index.js +3 -0
  81. package/dist/components/Divider/Divider.d.ts +42 -0
  82. package/dist/components/Divider/Divider.js +95 -0
  83. package/dist/components/Divider/index.d.ts +1 -0
  84. package/dist/components/Divider/index.js +1 -0
  85. package/dist/components/Input/FloatLabel.d.ts +22 -0
  86. package/dist/components/Input/FloatLabel.js +19 -0
  87. package/dist/components/Input/InputGroup.d.ts +21 -0
  88. package/dist/components/Input/InputGroup.js +52 -0
  89. package/dist/components/Input/InputGroupAddon.d.ts +17 -0
  90. package/dist/components/Input/InputGroupAddon.js +57 -0
  91. package/dist/components/Input/InputSwitch/InputSwitch.d.ts +8 -0
  92. package/dist/components/Input/InputSwitch/InputSwitch.js +16 -0
  93. package/dist/components/Input/InputSwitch/index.d.ts +1 -0
  94. package/dist/components/Input/InputSwitch/index.js +1 -0
  95. package/dist/components/Input/InputSwitch/styles/index.d.ts +2 -0
  96. package/dist/components/Input/InputSwitch/styles/index.js +2 -0
  97. package/dist/components/Input/InputSwitch/styles/useHandleStyles.d.ts +13 -0
  98. package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +47 -0
  99. package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +17 -0
  100. package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +95 -0
  101. package/dist/components/Input/InputText.d.ts +13 -0
  102. package/dist/components/Input/InputText.js +14 -0
  103. package/dist/components/Input/InputTextBase/InputTextBase.d.ts +13 -0
  104. package/dist/components/Input/InputTextBase/InputTextBase.js +124 -0
  105. package/dist/components/Input/InputTextBase/testIds.d.ts +11 -0
  106. package/dist/components/Input/InputTextBase/testIds.js +11 -0
  107. package/dist/components/Input/InputTextBase/types.d.ts +41 -0
  108. package/dist/components/Input/InputTextBase/types.js +0 -0
  109. package/dist/components/Input/InputTextBase/useStyles.d.ts +86 -0
  110. package/dist/components/Input/InputTextBase/useStyles.js +78 -0
  111. package/dist/components/Input/index.d.ts +5 -0
  112. package/dist/components/Input/index.js +4 -0
  113. package/dist/components/List/Base/ListBase.d.ts +32 -0
  114. package/dist/components/List/Base/ListBase.js +88 -0
  115. package/dist/components/List/Base/index.d.ts +1 -0
  116. package/dist/components/List/Base/index.js +1 -0
  117. package/dist/components/MenuItem/MenuItemAccessory.d.ts +11 -0
  118. package/dist/components/MenuItem/MenuItemAccessory.js +23 -0
  119. package/dist/components/MenuItem/MenuItemIcon.d.ts +36 -0
  120. package/dist/components/MenuItem/MenuItemIcon.js +33 -0
  121. package/dist/components/MenuItem/Template/MenuItemTemplate.d.ts +42 -0
  122. package/dist/components/MenuItem/Template/MenuItemTemplate.js +79 -0
  123. package/dist/components/MenuItem/index.d.ts +1 -0
  124. package/dist/components/MenuItem/index.js +1 -0
  125. package/dist/components/Message/Message.d.ts +65 -0
  126. package/dist/components/Message/Message.js +126 -0
  127. package/dist/components/Message/index.d.ts +1 -0
  128. package/dist/components/Message/index.js +1 -0
  129. package/dist/components/ProgressBar/ProgressBar.d.ts +33 -0
  130. package/dist/components/ProgressBar/ProgressBar.js +62 -0
  131. package/dist/components/ProgressBar/index.d.ts +1 -0
  132. package/dist/components/ProgressBar/index.js +1 -0
  133. package/dist/components/ProgressSpinner/ProgressSpinner.d.ts +17 -0
  134. package/dist/components/ProgressSpinner/ProgressSpinner.js +68 -0
  135. package/dist/components/ProgressSpinner/index.d.ts +1 -0
  136. package/dist/components/ProgressSpinner/index.js +1 -0
  137. package/dist/components/RadioButton/RadioButton.d.ts +18 -0
  138. package/dist/components/RadioButton/RadioButton.js +134 -0
  139. package/dist/components/RadioButton/index.d.ts +1 -0
  140. package/dist/components/RadioButton/index.js +1 -0
  141. package/dist/components/Rating/Rating.d.ts +48 -0
  142. package/dist/components/Rating/Rating.js +37 -0
  143. package/dist/components/Rating/RatingClear.d.ts +14 -0
  144. package/dist/components/Rating/RatingClear.js +28 -0
  145. package/dist/components/Rating/RatingItem.d.ts +19 -0
  146. package/dist/components/Rating/RatingItem.js +44 -0
  147. package/dist/components/Rating/RatingItemContainer.d.ts +37 -0
  148. package/dist/components/Rating/RatingItemContainer.js +30 -0
  149. package/dist/components/Rating/index.d.ts +1 -0
  150. package/dist/components/Rating/index.js +1 -0
  151. package/dist/components/SelectButton/SelectButton.d.ts +32 -0
  152. package/dist/components/SelectButton/SelectButton.js +75 -0
  153. package/dist/components/SelectButton/SelectButtonItem.d.ts +35 -0
  154. package/dist/components/SelectButton/SelectButtonItem.js +133 -0
  155. package/dist/components/SelectButton/index.d.ts +1 -0
  156. package/dist/components/SelectButton/index.js +1 -0
  157. package/dist/components/Skeleton/Skeleton.d.ts +15 -0
  158. package/dist/components/Skeleton/Skeleton.js +53 -0
  159. package/dist/components/Skeleton/index.d.ts +1 -0
  160. package/dist/components/Skeleton/index.js +1 -0
  161. package/dist/components/Slider/Slider.d.ts +36 -0
  162. package/dist/components/Slider/Slider.js +153 -0
  163. package/dist/components/Slider/index.d.ts +1 -0
  164. package/dist/components/Slider/index.js +1 -0
  165. package/dist/components/Tabs/TabItem/TabItem.d.ts +24 -0
  166. package/dist/components/Tabs/TabItem/TabItem.js +82 -0
  167. package/dist/components/Tabs/TabItem/index.d.ts +1 -0
  168. package/dist/components/Tabs/TabItem/index.js +1 -0
  169. package/dist/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
  170. package/dist/components/Tabs/TabPanel/TabPanel.js +11 -0
  171. package/dist/components/Tabs/TabPanel/index.d.ts +1 -0
  172. package/dist/components/Tabs/TabPanel/index.js +1 -0
  173. package/dist/components/Tabs/Tabs.d.ts +15 -0
  174. package/dist/components/Tabs/Tabs.js +48 -0
  175. package/dist/components/Tabs/index.d.ts +2 -0
  176. package/dist/components/Tabs/index.js +2 -0
  177. package/dist/components/Tag/Tag.d.ts +33 -0
  178. package/dist/components/Tag/Tag.js +71 -0
  179. package/dist/components/Tag/index.d.ts +1 -0
  180. package/dist/components/Tag/index.js +1 -0
  181. package/dist/components/Timer/Timer.d.ts +18 -0
  182. package/dist/components/Timer/Timer.js +74 -0
  183. package/dist/components/Timer/TimerFlip.d.ts +7 -0
  184. package/dist/components/Timer/TimerFlip.js +69 -0
  185. package/dist/components/Timer/constants.d.ts +1 -0
  186. package/dist/components/Timer/constants.js +1 -0
  187. package/dist/components/ToggleButton/ToggleButton.d.ts +45 -0
  188. package/dist/components/ToggleButton/ToggleButton.js +85 -0
  189. package/dist/components/ToggleButton/hooks/useIconSize.d.ts +14 -0
  190. package/dist/components/ToggleButton/hooks/useIconSize.js +26 -0
  191. package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +8 -0
  192. package/dist/components/ToggleButton/hooks/useLabelSize.js +19 -0
  193. package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +11 -0
  194. package/dist/components/ToggleButton/hooks/useStateStyles.js +92 -0
  195. package/dist/components/ToggleButton/index.d.ts +1 -0
  196. package/dist/components/ToggleButton/index.js +1 -0
  197. package/dist/components/Typography/Anchor.d.ts +31 -0
  198. package/dist/components/Typography/Anchor.js +75 -0
  199. package/dist/components/Typography/Body.d.ts +9 -0
  200. package/dist/components/Typography/Body.js +32 -0
  201. package/dist/components/Typography/Caption.d.ts +9 -0
  202. package/dist/components/Typography/Caption.js +38 -0
  203. package/dist/components/Typography/Service.d.ts +25 -0
  204. package/dist/components/Typography/Service.js +63 -0
  205. package/dist/components/Typography/Subtitle.d.ts +18 -0
  206. package/dist/components/Typography/Subtitle.js +23 -0
  207. package/dist/components/Typography/Title.d.ts +5 -0
  208. package/dist/components/Typography/Title.js +24 -0
  209. package/dist/components/Typography/index.d.ts +6 -0
  210. package/dist/components/Typography/index.js +6 -0
  211. package/dist/components/index.d.ts +23 -0
  212. package/dist/components/index.js +23 -0
  213. package/dist/hooks/useChangeTheme.d.ts +1 -0
  214. package/dist/hooks/useChangeTheme.js +5 -0
  215. package/dist/hooks/useFonts.d.ts +1 -0
  216. package/dist/hooks/useFonts.js +5 -0
  217. package/dist/hooks/useLoadingRotationAnimation.d.ts +5 -0
  218. package/dist/hooks/useLoadingRotationAnimation.js +19 -0
  219. package/dist/hooks/useMakeTestId.d.ts +3 -0
  220. package/dist/hooks/useMakeTestId.js +7 -0
  221. package/dist/hooks/useTheme.d.ts +1 -0
  222. package/dist/hooks/useTheme.js +5 -0
  223. package/dist/index.d.ts +6 -0
  224. package/dist/index.js +6 -0
  225. package/dist/theme/ThemeContext.d.ts +15 -0
  226. package/dist/theme/ThemeContext.js +20 -0
  227. package/dist/theme/assets/background.json +149 -0
  228. package/dist/theme/assets/border.json +103 -0
  229. package/dist/theme/assets/customCommon.d.ts +4 -0
  230. package/dist/theme/assets/customCommon.js +4 -0
  231. package/dist/theme/assets/customDark.d.ts +5 -0
  232. package/dist/theme/assets/customDark.js +15 -0
  233. package/dist/theme/assets/customLight.d.ts +15 -0
  234. package/dist/theme/assets/customLight.js +15 -0
  235. package/dist/theme/assets/effects.json +15 -0
  236. package/dist/theme/assets/global.json +114 -0
  237. package/dist/theme/assets/primaryColors.json +14 -0
  238. package/dist/theme/assets/shadow.d.ts +6 -0
  239. package/dist/theme/assets/shadow.js +6 -0
  240. package/dist/theme/assets/sizing.json +78 -0
  241. package/dist/theme/assets/spacing.json +48 -0
  242. package/dist/theme/assets/themeDark.json +1141 -0
  243. package/dist/theme/assets/themeLight.json +1141 -0
  244. package/dist/theme/assets/typography.json +45 -0
  245. package/dist/theme/commonTheme.d.ts +582 -0
  246. package/dist/theme/commonTheme.js +22 -0
  247. package/dist/theme/darkTheme.d.ts +2 -0
  248. package/dist/theme/darkTheme.js +7 -0
  249. package/dist/theme/index.d.ts +4 -0
  250. package/dist/theme/index.js +4 -0
  251. package/dist/theme/lightTheme.d.ts +2 -0
  252. package/dist/theme/lightTheme.js +7 -0
  253. package/dist/theme/types.d.ts +40 -0
  254. package/dist/theme/types.js +5 -0
  255. package/dist/utils/SvgUniversal.d.ts +29 -0
  256. package/dist/utils/SvgUniversal.js +28 -0
  257. package/dist/utils/genericMemo.d.ts +1 -0
  258. package/dist/utils/genericMemo.js +2 -0
  259. package/dist/utils/makeStyles.d.ts +11 -0
  260. package/dist/utils/makeStyles.js +19 -0
  261. package/package.json +159 -0
@@ -0,0 +1,134 @@
1
+ import { memo, useCallback, useMemo } from 'react';
2
+ import { Pressable, StyleSheet, View, } from 'react-native';
3
+ import Animated, { LinearTransition } from 'react-native-reanimated';
4
+ import { makeStyles } from '../../utils/makeStyles';
5
+ export const RadioButton = memo(({ onPress, checked = false, disabled = false, state = 'default', testID, ...rest }) => {
6
+ const styles = useStyles();
7
+ const centerViewBackground = useMemo(() => [styles.defaultView, disabled && !checked && styles.disabledView], [disabled, checked, styles.defaultView, styles.disabledView]);
8
+ const pressableStyles = useCallback(({ pressed }) => {
9
+ const result = [styles.container, styles.default];
10
+ if (checked) {
11
+ result.push(styles.checked);
12
+ }
13
+ if (pressed) {
14
+ result.push(styles.pressed);
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
+ ]);
50
+ return (<View>
51
+ {!disabled && state === 'danger' && (<Animated.View layout={LinearTransition.duration(100)} style={styles.outline}/>)}
52
+ <Pressable disabled={disabled} style={pressableStyles} testID={testID || 'RadioButton_Pressable'} onPress={onPress} {...rest}>
53
+ <View style={[styles.center, centerViewBackground]}/>
54
+ </Pressable>
55
+ </View>);
56
+ });
57
+ const useStyles = makeStyles(({ theme }) => ({
58
+ container: {
59
+ width: theme.Form.RadioButton.radiobuttonWidth,
60
+ height: theme.Form.RadioButton.radiobuttonHeight,
61
+ borderRadius: theme.Form.RadioButton.radiobuttonWidth,
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ margin: theme.General.focusShadowWidth,
65
+ },
66
+ center: {
67
+ width: theme.Form.RadioButton.radiobuttonIconSize,
68
+ height: theme.Form.RadioButton.radiobuttonIconSize,
69
+ borderRadius: theme.Form.RadioButton.radiobuttonIconSize,
70
+ },
71
+ outline: {
72
+ position: 'absolute',
73
+ width: theme.Form.RadioButton.radiobuttonWidth +
74
+ theme.General.focusShadowWidth * 2,
75
+ height: theme.Form.RadioButton.radiobuttonHeight +
76
+ theme.General.focusShadowWidth * 2,
77
+ borderRadius: theme.Form.RadioButton.radiobuttonHeight +
78
+ theme.General.focusShadowWidth * 2,
79
+ backgroundColor: theme.General.focusOutlineErrorColor,
80
+ },
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
+ }));
@@ -0,0 +1 @@
1
+ export { RadioButton, type RadioButtonProps } from './RadioButton';
@@ -0,0 +1 @@
1
+ export { RadioButton } from './RadioButton';
@@ -0,0 +1,48 @@
1
+ import { type AccessibilityProps, type ViewProps } from 'react-native';
2
+ /**
3
+ * Свойства компонента рейтинга
4
+ * @see Rating - компонент рейтинга
5
+ */
6
+ export interface RatingProps extends AccessibilityProps, Pick<ViewProps, 'testID'> {
7
+ /**
8
+ * Управление состоянием включённости компонента для нажатий пользователем
9
+ * @default false
10
+ */
11
+ disabled?: boolean;
12
+ /**
13
+ * Отображение элемента с паддингами
14
+ * @default false
15
+ */
16
+ paddings?: boolean;
17
+ /**
18
+ * Максимальный рейтинг(количество звёздочек)
19
+ * @default 5
20
+ */
21
+ maxRating?: number;
22
+ /**
23
+ * Текущий рейтинг
24
+ */
25
+ rating: number;
26
+ /**
27
+ * Обработчик изменения рейтинга
28
+ * @param rating - новый рейтинг
29
+ */
30
+ onChange: (rating: number) => void;
31
+ /**
32
+ * Обработчик очистки рейтинга
33
+ */
34
+ onClear: () => void;
35
+ }
36
+ /**
37
+ * Компонент рейтинга
38
+ * @param disabled - управление состоянием включённости компонента для нажатий пользователем
39
+ * @param paddings - отображение элемента с паддингами
40
+ * @param maxRating - максимальный рейтинг(количество звёздочек)
41
+ * @param rating - текущий рейтинг
42
+ * @param onChange - обработчик изменения рейтинга
43
+ * @param onClear - обработчик изменения рейтинга
44
+ * @see RatingProps - тип свойств компонента рейтинга
45
+ * @see RatingItem - элемент рейтинга с иконкой звёздочки
46
+ * @see RatingClear - элемент рейтинга для очистки
47
+ */
48
+ export declare const Rating: import("react").NamedExoticComponent<RatingProps>;
@@ -0,0 +1,37 @@
1
+ import { memo, useCallback } from 'react';
2
+ import { View } from 'react-native';
3
+ import { makeStyles } from '../../utils/makeStyles';
4
+ import { RatingClear } from './RatingClear';
5
+ import { RatingItem } from './RatingItem';
6
+ /**
7
+ * Компонент рейтинга
8
+ * @param disabled - управление состоянием включённости компонента для нажатий пользователем
9
+ * @param paddings - отображение элемента с паддингами
10
+ * @param maxRating - максимальный рейтинг(количество звёздочек)
11
+ * @param rating - текущий рейтинг
12
+ * @param onChange - обработчик изменения рейтинга
13
+ * @param onClear - обработчик изменения рейтинга
14
+ * @see RatingProps - тип свойств компонента рейтинга
15
+ * @see RatingItem - элемент рейтинга с иконкой звёздочки
16
+ * @see RatingClear - элемент рейтинга для очистки
17
+ */
18
+ export const Rating = memo(({ disabled = false, paddings = false, maxRating = 5, rating, onChange, onClear, testID, ...rest }) => {
19
+ const styles = useStyles();
20
+ const handleItemPress = useCallback((index) => () => {
21
+ onChange(index + 1);
22
+ }, [onChange]);
23
+ return (<View style={styles.container}>
24
+ <RatingClear disabled={disabled} paddings={paddings} testID={testID || 'RatingClear'} onPress={onClear} {...rest}/>
25
+ {new Array(maxRating).fill(null).map((_, index) => (<RatingItem checked={index < rating}
26
+ // Использовать индекс массива в качестве ключа - единственно возможное и правильное решение
27
+ // eslint-disable-next-line react/no-array-index-key
28
+ key={`RatingItem-${index}`} paddings={paddings} testID={`RatingItem-${index + 1}`} onPress={handleItemPress(index)}/>))}
29
+ </View>);
30
+ });
31
+ const useStyles = makeStyles(({ theme }) => ({
32
+ container: {
33
+ flexDirection: 'row',
34
+ gap: theme.General.inlineSpacing,
35
+ alignItems: 'center',
36
+ },
37
+ }));
@@ -0,0 +1,14 @@
1
+ import { type RatingItemContainerProps } from './RatingItemContainer';
2
+ /**
3
+ * Свойства компонента элемента рейтинга для очистки рейтинга
4
+ * @see RatingItemContainerProps - тип свойств компонента контейнера элемента от которого наследуется данный тип свойств
5
+ * @see RatingClear = компонент элемента рейтинга для очистки рейтинга
6
+ */
7
+ export interface RatingClearProps extends Omit<RatingItemContainerProps, 'children'> {
8
+ }
9
+ /**
10
+ * Компонент элемента рейтинга для очистки рейтинга
11
+ * @see RatingClearProps - cвойства компонента элемента рейтинга для очистки рейтинга
12
+ * @see RatingItemContainer - компонент контейнер для элемента
13
+ */
14
+ export declare const RatingClear: import("react").NamedExoticComponent<RatingClearProps>;
@@ -0,0 +1,28 @@
1
+ import { IconBan } from '@tabler/icons-react-native';
2
+ import { memo } from 'react';
3
+ import { makeStyles } from '../../utils/makeStyles';
4
+ import { RatingItemContainer, } from './RatingItemContainer';
5
+ /**
6
+ * Компонент элемента рейтинга для очистки рейтинга
7
+ * @see RatingClearProps - cвойства компонента элемента рейтинга для очистки рейтинга
8
+ * @see RatingItemContainer - компонент контейнер для элемента
9
+ */
10
+ export const RatingClear = memo(({ ...rest }) => {
11
+ const styles = useStyles();
12
+ return (<RatingItemContainer {...rest}>
13
+ {({ disabled, pressed }) => (<IconBan color={disabled
14
+ ? styles.iconDisabled.color
15
+ : pressed
16
+ ? styles.iconPressed.color
17
+ : styles.icon.color} height={styles.icon.height} width={styles.icon.width}/>)}
18
+ </RatingItemContainer>);
19
+ });
20
+ const useStyles = makeStyles(({ theme }) => ({
21
+ icon: {
22
+ height: theme.Form.Rating.ratingIconFontSize,
23
+ width: theme.Form.Rating.ratingIconFontSize,
24
+ color: theme.Form.Rating.ratingCancelIconColor,
25
+ },
26
+ iconPressed: { color: theme.Form.Rating.ratingCancelIconHoverColor },
27
+ iconDisabled: { color: theme.custom.rating.ratingCancelIconDisabledColor },
28
+ }));
@@ -0,0 +1,19 @@
1
+ import { type RatingItemContainerProps } from './RatingItemContainer';
2
+ /**
3
+ * Свойства компонента элемента рейтинга с иконкой звёздочки
4
+ * @see RatingItemContainerProps - тип свойств компонента контейнера элемента от которого наследуется данный тип свойств
5
+ * @see RatingItem - компонент элемента рейтинга с иконкой звёздочки
6
+ */
7
+ export interface RatingItemProps extends Omit<RatingItemContainerProps, 'children'> {
8
+ /**
9
+ * Управление состоянием активности элемента
10
+ */
11
+ checked: boolean;
12
+ }
13
+ /**
14
+ * Компонент элемента рейтинга с иконкой звёздочки
15
+ * @param checked - Управление состоянием активности элемента
16
+ * @see RatingItemProps - тип свойств компонента
17
+ * @see RatingItemContainer - компонент контейнер для элемента
18
+ */
19
+ export declare const RatingItem: import("react").NamedExoticComponent<RatingItemProps>;
@@ -0,0 +1,44 @@
1
+ import { IconStar, IconStarFilled } from '@tabler/icons-react-native';
2
+ import { memo, useMemo } from 'react';
3
+ import { makeStyles } from '../../utils/makeStyles';
4
+ import { RatingItemContainer, } from './RatingItemContainer';
5
+ /**
6
+ * Компонент элемента рейтинга с иконкой звёздочки
7
+ * @param checked - Управление состоянием активности элемента
8
+ * @see RatingItemProps - тип свойств компонента
9
+ * @see RatingItemContainer - компонент контейнер для элемента
10
+ */
11
+ export const RatingItem = memo(({ checked, ...rest }) => {
12
+ const styles = useStyles();
13
+ const Icon = useMemo(() => (checked ? IconStarFilled : IconStar), [checked]);
14
+ return (<RatingItemContainer {...rest}>
15
+ {({ pressed, disabled }) => (<Icon color={disabled
16
+ ? checked
17
+ ? styles.iconCheckedDisabled.color
18
+ : styles.iconDisabled.color
19
+ : pressed
20
+ ? styles.iconPressed.color
21
+ : checked
22
+ ? styles.iconChecked.color
23
+ : styles.icon.color} fill={checked
24
+ ? disabled
25
+ ? styles.iconCheckedDisabled.color
26
+ : pressed
27
+ ? styles.iconPressed.color
28
+ : styles.iconChecked.color
29
+ : undefined} fillOpacity={checked ? 1 : 0} height={styles.icon.height} width={styles.icon.width}/>)}
30
+ </RatingItemContainer>);
31
+ });
32
+ const useStyles = makeStyles(({ theme }) => ({
33
+ icon: {
34
+ height: theme.Form.Rating.ratingIconFontSize,
35
+ 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
+ },
44
+ }));
@@ -0,0 +1,37 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type PressableProps } from 'react-native';
3
+ /**
4
+ * Свойста компонента контейнера для элемента в компоненте рейтинга
5
+ * @see RatingItemContainer
6
+ */
7
+ export interface RatingItemContainerProps extends Omit<PressableProps, 'style' | 'onPress' | 'children'> {
8
+ /**
9
+ * Отображение элемента с паддингами
10
+ * @default false
11
+ */
12
+ paddings?: boolean;
13
+ /**
14
+ * Обработчик нажатия элемента
15
+ * @default undefined
16
+ */
17
+ onPress?: () => void;
18
+ /**
19
+ * Функция отображения дочернего компонента в контейнере
20
+ * @param renderProps - свойства состояния контейнера для изменения отображения дочернего компонента
21
+ * @returns отрендеренный компонент
22
+ */
23
+ children: (renderProps: {
24
+ disabled: boolean | null;
25
+ pressed: boolean;
26
+ }) => ReactNode;
27
+ }
28
+ /**
29
+ * Компонент контейнера для элемента в компоненте рейтинга
30
+ * @param disabled - управление состоянием включённости компонента для нажатий пользователем
31
+ * @param paddings - отображение элемента с паддингами
32
+ * @param children - функция отображения дочернего компонента в контейнере
33
+ * @see RatingItemContainerProps - тип свойств компонента
34
+ * @see RatingItem - вариация компонента элемента рейтинга с иконкой звёздочки
35
+ * @see RatingClear - вариация компонента элемента рейтинга с иконкой очистки
36
+ */
37
+ export declare const RatingItemContainer: import("react").NamedExoticComponent<RatingItemContainerProps>;
@@ -0,0 +1,30 @@
1
+ import { memo } from 'react';
2
+ import { Pressable } from 'react-native';
3
+ import { makeStyles } from '../../utils/makeStyles';
4
+ /**
5
+ * Компонент контейнера для элемента в компоненте рейтинга
6
+ * @param disabled - управление состоянием включённости компонента для нажатий пользователем
7
+ * @param paddings - отображение элемента с паддингами
8
+ * @param children - функция отображения дочернего компонента в контейнере
9
+ * @see RatingItemContainerProps - тип свойств компонента
10
+ * @see RatingItem - вариация компонента элемента рейтинга с иконкой звёздочки
11
+ * @see RatingClear - вариация компонента элемента рейтинга с иконкой очистки
12
+ */
13
+ export const RatingItemContainer = memo(({ disabled = false, paddings = false, children, ...rest }) => {
14
+ const styles = useStyles();
15
+ return (<Pressable disabled={disabled} style={[styles.container, paddings && styles.containerWithPaddings]} {...rest}>
16
+ {({ pressed }) => children({ disabled, pressed })}
17
+ </Pressable>);
18
+ });
19
+ const useStyles = makeStyles(({ theme, sizing }) => ({
20
+ container: {
21
+ alignItems: 'center',
22
+ justifyContent: 'center',
23
+ width: theme.Form.Rating.ratingIconFontSize,
24
+ height: theme.Form.Rating.ratingIconFontSize,
25
+ },
26
+ containerWithPaddings: {
27
+ width: sizing.Width['w-3'],
28
+ height: sizing.Height['h-3'],
29
+ },
30
+ }));
@@ -0,0 +1 @@
1
+ export { Rating, type RatingProps } from './Rating';
@@ -0,0 +1 @@
1
+ export { Rating } from './Rating';
@@ -0,0 +1,32 @@
1
+ import { type AccessibilityProps, type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
2
+ import { type SharedValue } from 'react-native-reanimated';
3
+ import { type SelectButtonItemProps } from './SelectButtonItem';
4
+ export interface SelectButtonProps extends AccessibilityProps, Pick<ViewProps, 'testID'> {
5
+ /** Массив кнопок. Должен содержать как минимум 2 кнопки. */
6
+ buttons: Array<Pick<SelectButtonItemProps, 'label' | 'showIcon' | 'Icon'> & {
7
+ key: string;
8
+ }>;
9
+ /** true - если кнопки недоступны для нажатия */
10
+ disabled?: boolean;
11
+ /** Индекс выбранной кнопки при первом рендере */
12
+ initialIndex?: number;
13
+ /** Вызывается при нажатии на кнопку */
14
+ onPress?: (index: number) => void;
15
+ /**
16
+ * Анимированное значение 0...n-1, где n - это количество кнопок.
17
+ * Используется для контроля элемента извне. Если передано, то компонент становится управляемым.
18
+ */
19
+ position?: SharedValue<number>;
20
+ /**
21
+ * Выбор размера элемента
22
+ * @default 'base'
23
+ */
24
+ size?: 'small' | 'base' | 'large' | 'xlarge';
25
+ /** Дополнительная стилизация для контейнера компонента */
26
+ style?: StyleProp<ViewStyle>;
27
+ }
28
+ /**
29
+ * Используется для маркировки элементов интерфейса
30
+ * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4921
31
+ */
32
+ export declare const SelectButton: import("react").NamedExoticComponent<SelectButtonProps>;
@@ -0,0 +1,75 @@
1
+ import { memo, useCallback, useMemo, useRef, useState } from 'react';
2
+ import { View, } from 'react-native';
3
+ import Animated, { Easing, interpolate, runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
4
+ import { makeStyles } from '../../utils/makeStyles';
5
+ import { SelectButtonItem, } from './SelectButtonItem';
6
+ const DEFAULT_ANIMATION_DURATION = 200; // ms
7
+ /**
8
+ * Используется для маркировки элементов интерфейса
9
+ * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-4921
10
+ */
11
+ export const SelectButton = memo(({ buttons, disabled, initialIndex: initialIndexProp, onPress: onPressProp, size, style, testID, position: positionProp, ...rest }) => {
12
+ const styles = useStyles();
13
+ const buttonsLayoutListRef = useRef([]);
14
+ const buttonsLayoutList = useSharedValue([]);
15
+ const [frameKey, setFrameKey] = useState(Date.now());
16
+ const initialIndex = useMemo(() => initialIndexProp && initialIndexProp < buttons.length
17
+ ? initialIndexProp
18
+ : 0, [buttons.length, initialIndexProp]);
19
+ const onButtonLayout = useCallback((index, event) => {
20
+ buttonsLayoutListRef.current[index] = event.nativeEvent.layout;
21
+ if (buttonsLayoutListRef.current.length === buttons.length) {
22
+ buttonsLayoutList.value = [...buttonsLayoutListRef.current];
23
+ }
24
+ }, [buttons.length, buttonsLayoutList]);
25
+ useAnimatedReaction(() => buttonsLayoutList.value, (layoutList, previous) => {
26
+ if (layoutList !== previous) {
27
+ runOnJS(setFrameKey)(Date.now());
28
+ }
29
+ });
30
+ const positionInner = useSharedValue(initialIndex);
31
+ const position = useMemo(() => positionProp || positionInner, [positionInner, positionProp]);
32
+ const animationInputRange = useMemo(() => buttons.map((_, index) => index), [buttons]);
33
+ const framePositionStyle = useAnimatedStyle(() => {
34
+ const left = interpolate(position.value, animationInputRange, animationInputRange.map((index) => buttonsLayoutList.value[index]?.x ?? 0));
35
+ const width = interpolate(position.value, animationInputRange, animationInputRange.map((index) => buttonsLayoutList.value[index]?.width ?? 0));
36
+ return { left, width };
37
+ });
38
+ const isUncontrolledComponent = useMemo(() => !positionProp, [positionProp]);
39
+ const onPress = useCallback((index) => {
40
+ if (isUncontrolledComponent) {
41
+ positionInner.value = withTiming(index, {
42
+ duration: DEFAULT_ANIMATION_DURATION,
43
+ easing: Easing.linear,
44
+ });
45
+ }
46
+ onPressProp?.(index);
47
+ }, [isUncontrolledComponent, onPressProp, positionInner]);
48
+ return (<View collapsable={false} style={[styles.container, style]} testID={testID} {...rest}>
49
+ {buttons.map(({ label, Icon, key, showIcon }, index) => (<SelectButtonItem Icon={Icon} disabled={disabled} index={index} key={key} label={label} position={position} showIcon={showIcon} size={size} testID={`SelectButton_SelectButtonItem_${index}`} onLayout={(event) => onButtonLayout(index, event)} onPress={() => onPress(index)}/>))}
50
+
51
+ {!disabled && (<Animated.View key={frameKey} style={[styles.frame, framePositionStyle]} testID='SelectButton_AnimatedFrame'/>)}
52
+ </View>);
53
+ });
54
+ const useStyles = makeStyles(({ theme }) => ({
55
+ container: {
56
+ flexDirection: 'row',
57
+ padding: theme.Form.SelectButton.selectButtonGroupPadding,
58
+ gap: theme.Form.SelectButton.selectButtonGroupPadding,
59
+ borderRadius: theme.General.borderRadiusXL,
60
+ backgroundColor: theme.Form.SelectButton.selectButtonGroupBg,
61
+ },
62
+ frame: {
63
+ position: 'absolute',
64
+ top: theme.Form.SelectButton.selectButtonGroupPadding,
65
+ bottom: theme.Form.SelectButton.selectButtonGroupPadding,
66
+ left: theme.Form.SelectButton.selectButtonGroupPadding,
67
+ borderRadius: theme.Form.SelectButton.selectButtonBorderRadius,
68
+ backgroundColor: theme.Form.SelectButton.selectButtonActiveBg,
69
+ zIndex: -1,
70
+ },
71
+ textColor: { color: theme.Form.SelectButton.selectButtonTextColor },
72
+ checkedTextColor: {
73
+ color: theme.Form.SelectButton.selectButtonIconActiveColor,
74
+ },
75
+ }));
@@ -0,0 +1,35 @@
1
+ import { type ViewProps } from 'react-native';
2
+ import { type SharedValue } from 'react-native-reanimated';
3
+ import { type SvgSource } from '../../utils/SvgUniversal';
4
+ export interface SelectButtonItemProps extends Pick<ViewProps, 'onLayout' | 'testID'> {
5
+ /** Индекс кнопки */
6
+ index: number;
7
+ /** Обработчик нажатия на кнопку */
8
+ onPress: () => void;
9
+ /**
10
+ * Анимированное значение 0...n-1, где n - это количество кнопок.
11
+ * Кнопка считается выбранной, если значение position равно индексу кнопки.
12
+ */
13
+ position: SharedValue<number>;
14
+ /** true - если кнопка недоступна для нажатия */
15
+ disabled?: boolean;
16
+ /** Текст на кнопке */
17
+ label?: string;
18
+ /**
19
+ * Выбор размера элемента
20
+ * @default 'base'
21
+ */
22
+ size?: 'small' | 'base' | 'large' | 'xlarge';
23
+ /**
24
+ * Показать или скрыть иконку внутри компонента
25
+ * @default true
26
+ */
27
+ showIcon?: boolean;
28
+ /** SVG-иконка */
29
+ Icon?: SvgSource;
30
+ }
31
+ /**
32
+ * Дочерний элемент компонента SelectButton. Не используется отдельно от SelectButton.
33
+ * @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=481-4393
34
+ */
35
+ export declare const SelectButtonItem: import("react").NamedExoticComponent<SelectButtonItemProps>;