@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.
- package/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/components/Accordion/Accordion.d.ts +39 -0
- package/dist/components/Accordion/Accordion.js +103 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/Avatar/Avatar.d.ts +96 -0
- package/dist/components/Avatar/Avatar.js +121 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.d.ts +35 -0
- package/dist/components/Badge/Badge.js +74 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Button/BaseButton.d.ts +5 -0
- package/dist/components/Button/BaseButton.js +62 -0
- package/dist/components/Button/Button.d.ts +16 -0
- package/dist/components/Button/Button.js +21 -0
- package/dist/components/Button/ButtonBadge.d.ts +21 -0
- package/dist/components/Button/ButtonBadge.js +53 -0
- package/dist/components/Button/ButtonSeverity.d.ts +17 -0
- package/dist/components/Button/ButtonSeverity.js +22 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.js +3 -0
- package/dist/components/Button/styles/index.d.ts +2 -0
- package/dist/components/Button/styles/index.js +2 -0
- package/dist/components/Button/styles/useBasicButtonStyles.d.ts +98 -0
- package/dist/components/Button/styles/useBasicButtonStyles.js +81 -0
- package/dist/components/Button/styles/useDangerButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useDangerButtonStyles.js +57 -0
- package/dist/components/Button/styles/useInfoButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useInfoButtonStyles.js +56 -0
- package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +64 -0
- package/dist/components/Button/styles/useSeverityButtonStyles.js +29 -0
- package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useSuccessButtonStyles.js +61 -0
- package/dist/components/Button/styles/useWarningButtonStyles.d.ts +63 -0
- package/dist/components/Button/styles/useWarningButtonStyles.js +61 -0
- package/dist/components/Button/types.d.ts +107 -0
- package/dist/components/Button/types.js +0 -0
- package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -0
- package/dist/components/Button/utils/ButtonActivityIndicator.js +17 -0
- package/dist/components/Button/utils/ButtonContainer.d.ts +7 -0
- package/dist/components/Button/utils/ButtonContainer.js +10 -0
- package/dist/components/Button/utils/ButtonIcon.d.ts +4 -0
- package/dist/components/Button/utils/ButtonIcon.js +11 -0
- package/dist/components/Button/utils/ButtonLabel.d.ts +4 -0
- package/dist/components/Button/utils/ButtonLabel.js +13 -0
- package/dist/components/Button/utils/ButtonLeftArea.d.ts +4 -0
- package/dist/components/Button/utils/ButtonLeftArea.js +13 -0
- package/dist/components/Button/utils/ButtonRightArea.d.ts +3 -0
- package/dist/components/Button/utils/ButtonRightArea.js +13 -0
- package/dist/components/Button/utils/index.d.ts +4 -0
- package/dist/components/Button/utils/index.js +4 -0
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +3 -0
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +141 -0
- package/dist/components/Button/utils/useButtonLabelStyle.d.ts +3 -0
- package/dist/components/Button/utils/useButtonLabelStyle.js +40 -0
- package/dist/components/Button/utils/useIconStyle.d.ts +7 -0
- package/dist/components/Button/utils/useIconStyle.js +35 -0
- package/dist/components/Button/utils/useTypeBasedStyle.d.ts +2 -0
- package/dist/components/Button/utils/useTypeBasedStyle.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +31 -0
- package/dist/components/Checkbox/Checkbox.js +55 -0
- package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +15 -0
- package/dist/components/Checkbox/hooks/usePressableStyles.js +91 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/Chip/Chip.d.ts +30 -0
- package/dist/components/Chip/Chip.js +70 -0
- package/dist/components/Chip/index.d.ts +1 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Dialog/Dialog.d.ts +14 -0
- package/dist/components/Dialog/Dialog.js +96 -0
- package/dist/components/Dialog/DialogComponent.d.ts +7 -0
- package/dist/components/Dialog/DialogComponent.js +34 -0
- package/dist/components/Dialog/DialogHeader.d.ts +12 -0
- package/dist/components/Dialog/DialogHeader.js +68 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.js +3 -0
- package/dist/components/Divider/Divider.d.ts +42 -0
- package/dist/components/Divider/Divider.js +95 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/Input/FloatLabel.d.ts +22 -0
- package/dist/components/Input/FloatLabel.js +19 -0
- package/dist/components/Input/InputGroup.d.ts +21 -0
- package/dist/components/Input/InputGroup.js +52 -0
- package/dist/components/Input/InputGroupAddon.d.ts +17 -0
- package/dist/components/Input/InputGroupAddon.js +57 -0
- package/dist/components/Input/InputSwitch/InputSwitch.d.ts +8 -0
- package/dist/components/Input/InputSwitch/InputSwitch.js +16 -0
- package/dist/components/Input/InputSwitch/index.d.ts +1 -0
- package/dist/components/Input/InputSwitch/index.js +1 -0
- package/dist/components/Input/InputSwitch/styles/index.d.ts +2 -0
- package/dist/components/Input/InputSwitch/styles/index.js +2 -0
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.d.ts +13 -0
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +47 -0
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +17 -0
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +95 -0
- package/dist/components/Input/InputText.d.ts +13 -0
- package/dist/components/Input/InputText.js +14 -0
- package/dist/components/Input/InputTextBase/InputTextBase.d.ts +13 -0
- package/dist/components/Input/InputTextBase/InputTextBase.js +124 -0
- package/dist/components/Input/InputTextBase/testIds.d.ts +11 -0
- package/dist/components/Input/InputTextBase/testIds.js +11 -0
- package/dist/components/Input/InputTextBase/types.d.ts +41 -0
- package/dist/components/Input/InputTextBase/types.js +0 -0
- package/dist/components/Input/InputTextBase/useStyles.d.ts +86 -0
- package/dist/components/Input/InputTextBase/useStyles.js +78 -0
- package/dist/components/Input/index.d.ts +5 -0
- package/dist/components/Input/index.js +4 -0
- package/dist/components/List/Base/ListBase.d.ts +32 -0
- package/dist/components/List/Base/ListBase.js +88 -0
- package/dist/components/List/Base/index.d.ts +1 -0
- package/dist/components/List/Base/index.js +1 -0
- package/dist/components/MenuItem/MenuItemAccessory.d.ts +11 -0
- package/dist/components/MenuItem/MenuItemAccessory.js +23 -0
- package/dist/components/MenuItem/MenuItemIcon.d.ts +36 -0
- package/dist/components/MenuItem/MenuItemIcon.js +33 -0
- package/dist/components/MenuItem/Template/MenuItemTemplate.d.ts +42 -0
- package/dist/components/MenuItem/Template/MenuItemTemplate.js +79 -0
- package/dist/components/MenuItem/index.d.ts +1 -0
- package/dist/components/MenuItem/index.js +1 -0
- package/dist/components/Message/Message.d.ts +65 -0
- package/dist/components/Message/Message.js +126 -0
- package/dist/components/Message/index.d.ts +1 -0
- package/dist/components/Message/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +33 -0
- package/dist/components/ProgressBar/ProgressBar.js +62 -0
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressSpinner/ProgressSpinner.d.ts +17 -0
- package/dist/components/ProgressSpinner/ProgressSpinner.js +68 -0
- package/dist/components/ProgressSpinner/index.d.ts +1 -0
- package/dist/components/ProgressSpinner/index.js +1 -0
- package/dist/components/RadioButton/RadioButton.d.ts +18 -0
- package/dist/components/RadioButton/RadioButton.js +134 -0
- package/dist/components/RadioButton/index.d.ts +1 -0
- package/dist/components/RadioButton/index.js +1 -0
- package/dist/components/Rating/Rating.d.ts +48 -0
- package/dist/components/Rating/Rating.js +37 -0
- package/dist/components/Rating/RatingClear.d.ts +14 -0
- package/dist/components/Rating/RatingClear.js +28 -0
- package/dist/components/Rating/RatingItem.d.ts +19 -0
- package/dist/components/Rating/RatingItem.js +44 -0
- package/dist/components/Rating/RatingItemContainer.d.ts +37 -0
- package/dist/components/Rating/RatingItemContainer.js +30 -0
- package/dist/components/Rating/index.d.ts +1 -0
- package/dist/components/Rating/index.js +1 -0
- package/dist/components/SelectButton/SelectButton.d.ts +32 -0
- package/dist/components/SelectButton/SelectButton.js +75 -0
- package/dist/components/SelectButton/SelectButtonItem.d.ts +35 -0
- package/dist/components/SelectButton/SelectButtonItem.js +133 -0
- package/dist/components/SelectButton/index.d.ts +1 -0
- package/dist/components/SelectButton/index.js +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +15 -0
- package/dist/components/Skeleton/Skeleton.js +53 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Slider/Slider.d.ts +36 -0
- package/dist/components/Slider/Slider.js +153 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Tabs/TabItem/TabItem.d.ts +24 -0
- package/dist/components/Tabs/TabItem/TabItem.js +82 -0
- package/dist/components/Tabs/TabItem/index.d.ts +1 -0
- package/dist/components/Tabs/TabItem/index.js +1 -0
- package/dist/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
- package/dist/components/Tabs/TabPanel/TabPanel.js +11 -0
- package/dist/components/Tabs/TabPanel/index.d.ts +1 -0
- package/dist/components/Tabs/TabPanel/index.js +1 -0
- package/dist/components/Tabs/Tabs.d.ts +15 -0
- package/dist/components/Tabs/Tabs.js +48 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tag/Tag.d.ts +33 -0
- package/dist/components/Tag/Tag.js +71 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/Tag/index.js +1 -0
- package/dist/components/Timer/Timer.d.ts +18 -0
- package/dist/components/Timer/Timer.js +74 -0
- package/dist/components/Timer/TimerFlip.d.ts +7 -0
- package/dist/components/Timer/TimerFlip.js +69 -0
- package/dist/components/Timer/constants.d.ts +1 -0
- package/dist/components/Timer/constants.js +1 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +45 -0
- package/dist/components/ToggleButton/ToggleButton.js +85 -0
- package/dist/components/ToggleButton/hooks/useIconSize.d.ts +14 -0
- package/dist/components/ToggleButton/hooks/useIconSize.js +26 -0
- package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +8 -0
- package/dist/components/ToggleButton/hooks/useLabelSize.js +19 -0
- package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +11 -0
- package/dist/components/ToggleButton/hooks/useStateStyles.js +92 -0
- package/dist/components/ToggleButton/index.d.ts +1 -0
- package/dist/components/ToggleButton/index.js +1 -0
- package/dist/components/Typography/Anchor.d.ts +31 -0
- package/dist/components/Typography/Anchor.js +75 -0
- package/dist/components/Typography/Body.d.ts +9 -0
- package/dist/components/Typography/Body.js +32 -0
- package/dist/components/Typography/Caption.d.ts +9 -0
- package/dist/components/Typography/Caption.js +38 -0
- package/dist/components/Typography/Service.d.ts +25 -0
- package/dist/components/Typography/Service.js +63 -0
- package/dist/components/Typography/Subtitle.d.ts +18 -0
- package/dist/components/Typography/Subtitle.js +23 -0
- package/dist/components/Typography/Title.d.ts +5 -0
- package/dist/components/Typography/Title.js +24 -0
- package/dist/components/Typography/index.d.ts +6 -0
- package/dist/components/Typography/index.js +6 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.js +23 -0
- package/dist/hooks/useChangeTheme.d.ts +1 -0
- package/dist/hooks/useChangeTheme.js +5 -0
- package/dist/hooks/useFonts.d.ts +1 -0
- package/dist/hooks/useFonts.js +5 -0
- package/dist/hooks/useLoadingRotationAnimation.d.ts +5 -0
- package/dist/hooks/useLoadingRotationAnimation.js +19 -0
- package/dist/hooks/useMakeTestId.d.ts +3 -0
- package/dist/hooks/useMakeTestId.js +7 -0
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useTheme.js +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/theme/ThemeContext.d.ts +15 -0
- package/dist/theme/ThemeContext.js +20 -0
- package/dist/theme/assets/background.json +149 -0
- package/dist/theme/assets/border.json +103 -0
- package/dist/theme/assets/customCommon.d.ts +4 -0
- package/dist/theme/assets/customCommon.js +4 -0
- package/dist/theme/assets/customDark.d.ts +5 -0
- package/dist/theme/assets/customDark.js +15 -0
- package/dist/theme/assets/customLight.d.ts +15 -0
- package/dist/theme/assets/customLight.js +15 -0
- package/dist/theme/assets/effects.json +15 -0
- package/dist/theme/assets/global.json +114 -0
- package/dist/theme/assets/primaryColors.json +14 -0
- package/dist/theme/assets/shadow.d.ts +6 -0
- package/dist/theme/assets/shadow.js +6 -0
- package/dist/theme/assets/sizing.json +78 -0
- package/dist/theme/assets/spacing.json +48 -0
- package/dist/theme/assets/themeDark.json +1141 -0
- package/dist/theme/assets/themeLight.json +1141 -0
- package/dist/theme/assets/typography.json +45 -0
- package/dist/theme/commonTheme.d.ts +582 -0
- package/dist/theme/commonTheme.js +22 -0
- package/dist/theme/darkTheme.d.ts +2 -0
- package/dist/theme/darkTheme.js +7 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/lightTheme.d.ts +2 -0
- package/dist/theme/lightTheme.js +7 -0
- package/dist/theme/types.d.ts +40 -0
- package/dist/theme/types.js +5 -0
- package/dist/utils/SvgUniversal.d.ts +29 -0
- package/dist/utils/SvgUniversal.js +28 -0
- package/dist/utils/genericMemo.d.ts +1 -0
- package/dist/utils/genericMemo.js +2 -0
- package/dist/utils/makeStyles.d.ts +11 -0
- package/dist/utils/makeStyles.js +19 -0
- package/package.json +159 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
+
import { makeStyles } from '../../../../utils/makeStyles';
|
|
5
|
+
export const useSliderStyles = (checked, disabled, danger) => {
|
|
6
|
+
const styles = useStyles();
|
|
7
|
+
const calculateSliderBackground = useCallback((checked, disabled, pressed) => {
|
|
8
|
+
if (disabled) {
|
|
9
|
+
if (checked) {
|
|
10
|
+
return styles.sliderOnDisabled.backgroundColor;
|
|
11
|
+
}
|
|
12
|
+
return styles.sliderDisabled.backgroundColor;
|
|
13
|
+
}
|
|
14
|
+
if (pressed) {
|
|
15
|
+
if (checked) {
|
|
16
|
+
return styles.sliderOnPressed.backgroundColor;
|
|
17
|
+
}
|
|
18
|
+
return styles.sliderPressed.backgroundColor;
|
|
19
|
+
}
|
|
20
|
+
if (checked) {
|
|
21
|
+
return styles.sliderOn.backgroundColor;
|
|
22
|
+
}
|
|
23
|
+
return styles.sliderOff.backgroundColor;
|
|
24
|
+
}, [
|
|
25
|
+
styles.sliderDisabled.backgroundColor,
|
|
26
|
+
styles.sliderOff.backgroundColor,
|
|
27
|
+
styles.sliderOn.backgroundColor,
|
|
28
|
+
styles.sliderOnDisabled.backgroundColor,
|
|
29
|
+
styles.sliderOnPressed.backgroundColor,
|
|
30
|
+
styles.sliderPressed.backgroundColor,
|
|
31
|
+
]);
|
|
32
|
+
const calculateSliderBorderColor = useCallback((danger) => {
|
|
33
|
+
if (danger && !disabled) {
|
|
34
|
+
return styles.sliderDanger.borderColor;
|
|
35
|
+
}
|
|
36
|
+
return styles.sliderNoDanger.borderColor;
|
|
37
|
+
}, [
|
|
38
|
+
disabled,
|
|
39
|
+
styles.sliderDanger.borderColor,
|
|
40
|
+
styles.sliderNoDanger.borderColor,
|
|
41
|
+
]);
|
|
42
|
+
const sliderBackground = useSharedValue(calculateSliderBackground(checked, disabled, false));
|
|
43
|
+
const sliderBorderColor = useSharedValue(calculateSliderBorderColor(danger));
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
sliderBorderColor.value = withTiming(calculateSliderBorderColor(danger));
|
|
46
|
+
}, [calculateSliderBorderColor, danger, sliderBorderColor]);
|
|
47
|
+
const sliderStyle = useMemo(() => StyleSheet.flatten([
|
|
48
|
+
styles.slider,
|
|
49
|
+
{ backgroundColor: sliderBackground, borderColor: sliderBorderColor },
|
|
50
|
+
]), [sliderBackground, sliderBorderColor, styles.slider]);
|
|
51
|
+
const onPressedChange = useCallback(({ pressed }) => {
|
|
52
|
+
sliderBackground.value = withTiming(calculateSliderBackground(checked, disabled, pressed));
|
|
53
|
+
return styles.container;
|
|
54
|
+
}, [
|
|
55
|
+
calculateSliderBackground,
|
|
56
|
+
checked,
|
|
57
|
+
disabled,
|
|
58
|
+
sliderBackground,
|
|
59
|
+
styles.container,
|
|
60
|
+
]);
|
|
61
|
+
return { sliderStyle, onPressedChange };
|
|
62
|
+
};
|
|
63
|
+
const useStyles = makeStyles(({ theme, border }) => ({
|
|
64
|
+
container: {
|
|
65
|
+
height: theme.Form.inputSwitch.inputSwitchHeight,
|
|
66
|
+
width: theme.Form.inputSwitch.inputSwitchWidth,
|
|
67
|
+
},
|
|
68
|
+
slider: {
|
|
69
|
+
padding: theme.Form.inputSwitch.inputSwitchSliderPadding,
|
|
70
|
+
height: theme.Form.inputSwitch.inputSwitchHeight,
|
|
71
|
+
width: theme.Form.inputSwitch.inputSwitchWidth,
|
|
72
|
+
borderRadius: border.Radius['rounded-full'],
|
|
73
|
+
borderWidth: border.Width.border,
|
|
74
|
+
},
|
|
75
|
+
sliderOff: { backgroundColor: theme.Form.inputSwitch.inputSwitchSliderOffBg },
|
|
76
|
+
sliderOn: { backgroundColor: theme.Form.inputSwitch.inputSwitchSliderOnBg },
|
|
77
|
+
sliderPressed: {
|
|
78
|
+
backgroundColor: theme.Form.inputSwitch.inputSwitchSliderOffHoverBg,
|
|
79
|
+
},
|
|
80
|
+
sliderOnPressed: {
|
|
81
|
+
backgroundColor: theme.Form.inputSwitch.inputSwitchSliderOnHoverBg,
|
|
82
|
+
},
|
|
83
|
+
sliderDisabled: {
|
|
84
|
+
backgroundColor: theme.custom.inputSwitch.inputSwitchSliderOffDisabledBg,
|
|
85
|
+
},
|
|
86
|
+
sliderOnDisabled: {
|
|
87
|
+
backgroundColor: theme.custom.inputSwitch.inputSwitchSliderOnDisabledBg,
|
|
88
|
+
},
|
|
89
|
+
sliderNoDanger: { borderColor: 'transparent' },
|
|
90
|
+
sliderDanger: {
|
|
91
|
+
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
92
|
+
outlineColor: theme.General.focusOutlineErrorColor,
|
|
93
|
+
outlineWidth: Math.round(theme.General.focusShadowWidth),
|
|
94
|
+
},
|
|
95
|
+
}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ViewStyle } from 'react-native';
|
|
2
|
+
import type { InputTextBaseProps } from './InputTextBase/types';
|
|
3
|
+
export interface InputTextProps extends InputTextBaseProps {
|
|
4
|
+
/** Дополнительная стилизация для контейнера компонента */
|
|
5
|
+
style?: ViewStyle;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Компонент для ввода текста
|
|
9
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5470&m=dev
|
|
10
|
+
* @see InputTextBase
|
|
11
|
+
* @see InputTextBaseProps
|
|
12
|
+
*/
|
|
13
|
+
export declare const InputText: import("react").NamedExoticComponent<InputTextProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { InputTextBase } from './InputTextBase/InputTextBase';
|
|
4
|
+
/**
|
|
5
|
+
* Компонент для ввода текста
|
|
6
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5470&m=dev
|
|
7
|
+
* @see InputTextBase
|
|
8
|
+
* @see InputTextBaseProps
|
|
9
|
+
*/
|
|
10
|
+
export const InputText = memo(({ style, ...otherProps }) => {
|
|
11
|
+
return (<View style={style}>
|
|
12
|
+
<InputTextBase {...otherProps}/>
|
|
13
|
+
</View>);
|
|
14
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ViewStyle } from 'react-native';
|
|
2
|
+
import type { InputTextBaseProps } from './types';
|
|
3
|
+
interface PrivateInputTextBaseProps {
|
|
4
|
+
inputStyle?: ViewStyle;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Базовое поле
|
|
9
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5470&m=dev
|
|
10
|
+
* @see InputText
|
|
11
|
+
*/
|
|
12
|
+
export declare const InputTextBase: import("react").NamedExoticComponent<InputTextBaseProps & PrivateInputTextBaseProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { IconEye, IconEyeOff, IconLoader2, IconLock, IconX, } from '@tabler/icons-react-native';
|
|
2
|
+
import { memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { TextInput, View, TouchableOpacity, Pressable, } from 'react-native';
|
|
4
|
+
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
|
|
5
|
+
import { useLoadingRotationAnimation } from '../../../hooks/useLoadingRotationAnimation';
|
|
6
|
+
import { useMakeTestId } from '../../../hooks/useMakeTestId';
|
|
7
|
+
import { InputTextBaseTestId } from './testIds';
|
|
8
|
+
import { useStyles } from './useStyles';
|
|
9
|
+
/**
|
|
10
|
+
* Базовое поле
|
|
11
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5470&m=dev
|
|
12
|
+
* @see InputText
|
|
13
|
+
*/
|
|
14
|
+
export const InputTextBase = memo(
|
|
15
|
+
// eslint-disable-next-line max-lines-per-function
|
|
16
|
+
({ state, clearable = true, secureTextEntry: secureTextEntryProp = false, inputRef: propsInputRef, disabled, containerStyle, inputStyle, loading, renderTextInput, clearButtonAccessibilityLabel, floatLabel = false, placeholder, ...otherProps }) => {
|
|
17
|
+
const styles = useStyles();
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const [valueState, setValueState] = useState('');
|
|
20
|
+
const [isFocused, setIsFocused] = useState(otherProps.autoFocus || false);
|
|
21
|
+
const labelAnimation = useSharedValue(0);
|
|
22
|
+
const onFocus = useCallback((e) => {
|
|
23
|
+
setIsFocused(true);
|
|
24
|
+
otherProps.onFocus?.(e);
|
|
25
|
+
}, [otherProps]);
|
|
26
|
+
const onBlur = useCallback((e) => {
|
|
27
|
+
setIsFocused(false);
|
|
28
|
+
otherProps.onBlur?.(e);
|
|
29
|
+
}, [otherProps]);
|
|
30
|
+
const onChangeText = useCallback((nextValue) => {
|
|
31
|
+
otherProps.onChangeText?.(nextValue);
|
|
32
|
+
setValueState(nextValue);
|
|
33
|
+
}, [otherProps]);
|
|
34
|
+
const clear = useCallback(() => {
|
|
35
|
+
inputRef.current?.clear();
|
|
36
|
+
onChangeText('');
|
|
37
|
+
}, [onChangeText]);
|
|
38
|
+
const value = useMemo(() => otherProps.value ?? valueState, [otherProps.value, valueState]);
|
|
39
|
+
const showClearButton = useMemo(() => clearable && !!value.length, [clearable, value.length]);
|
|
40
|
+
const onContainerPress = useCallback(() => {
|
|
41
|
+
inputRef.current?.focus();
|
|
42
|
+
}, []);
|
|
43
|
+
const loadingAnimatedStyle = useLoadingRotationAnimation(loading);
|
|
44
|
+
const labelAnimatedStyle = useAnimatedStyle(() => ({
|
|
45
|
+
top: interpolate(labelAnimation.value, [0, 1], [styles.label.top, styles.labelReducedSize.top]),
|
|
46
|
+
paddingVertical: interpolate(labelAnimation.value, [0, 1], [styles.label.paddingVertical, styles.labelReducedSize.paddingVertical]),
|
|
47
|
+
fontSize: interpolate(labelAnimation.value, [0, 1], [styles.label.fontSize, styles.labelReducedSize.fontSize]),
|
|
48
|
+
fontFamily: labelAnimation.value > 0.5
|
|
49
|
+
? styles.labelReducedSize.fontFamily
|
|
50
|
+
: styles.label.fontFamily,
|
|
51
|
+
}));
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
labelAnimation.value = withTiming(isFocused || value ? 1 : 0, {
|
|
54
|
+
duration: 100,
|
|
55
|
+
});
|
|
56
|
+
}, [isFocused, labelAnimation, value]);
|
|
57
|
+
const iconSize = useMemo(() => (floatLabel ? styles.iconSizeFloatLabel : styles.iconSize), [floatLabel, styles.iconSize, styles.iconSizeFloatLabel]);
|
|
58
|
+
useImperativeHandle(propsInputRef, () => (inputRef.current ? inputRef.current : null), [inputRef]);
|
|
59
|
+
const { makeTestId } = useMakeTestId(otherProps.testID || InputTextBaseTestId.default);
|
|
60
|
+
const [userDefinedSecureTextEntry, setUserDefinedSecureTextEntry] = useState(true);
|
|
61
|
+
const secureTextEntry = useMemo(() => secureTextEntryProp === 'toggleable'
|
|
62
|
+
? userDefinedSecureTextEntry
|
|
63
|
+
: secureTextEntryProp, [secureTextEntryProp, userDefinedSecureTextEntry]);
|
|
64
|
+
const toggleUserDefinedSecureTextEntry = useCallback(() => setUserDefinedSecureTextEntry((old) => !old), []);
|
|
65
|
+
const texInputProps = useMemo(() => ({
|
|
66
|
+
placeholderTextColor: styles.placeholderTextColor.color,
|
|
67
|
+
...otherProps,
|
|
68
|
+
placeholder: floatLabel ? '' : placeholder,
|
|
69
|
+
testID: makeTestId(),
|
|
70
|
+
editable: !disabled,
|
|
71
|
+
secureTextEntry,
|
|
72
|
+
style: [styles.input, floatLabel && styles.inputFloatLabel, inputStyle],
|
|
73
|
+
inputRef,
|
|
74
|
+
value,
|
|
75
|
+
onBlur,
|
|
76
|
+
onChangeText,
|
|
77
|
+
onFocus,
|
|
78
|
+
}), [
|
|
79
|
+
styles.placeholderTextColor.color,
|
|
80
|
+
styles.input,
|
|
81
|
+
styles.inputFloatLabel,
|
|
82
|
+
otherProps,
|
|
83
|
+
floatLabel,
|
|
84
|
+
placeholder,
|
|
85
|
+
makeTestId,
|
|
86
|
+
disabled,
|
|
87
|
+
secureTextEntry,
|
|
88
|
+
inputStyle,
|
|
89
|
+
value,
|
|
90
|
+
onBlur,
|
|
91
|
+
onChangeText,
|
|
92
|
+
onFocus,
|
|
93
|
+
]);
|
|
94
|
+
return (<Pressable accessible={false} disabled={disabled} style={[
|
|
95
|
+
styles.container,
|
|
96
|
+
floatLabel && styles.containerFloatLabel,
|
|
97
|
+
isFocused && styles.containerFocused,
|
|
98
|
+
containerStyle,
|
|
99
|
+
state === 'danger' && styles.danger,
|
|
100
|
+
state === 'danger' && isFocused && styles.dangerFocused,
|
|
101
|
+
disabled && styles.disabled,
|
|
102
|
+
]} testID={makeTestId(InputTextBaseTestId.pressableContainer)} onPress={onContainerPress}>
|
|
103
|
+
{floatLabel ? (<Animated.Text style={[styles.label, labelAnimatedStyle]} testID={makeTestId(InputTextBaseTestId.floatingPlaceholder)}>
|
|
104
|
+
{placeholder}
|
|
105
|
+
</Animated.Text>) : null}
|
|
106
|
+
{renderTextInput ? (renderTextInput(texInputProps)) : (<TextInput {...texInputProps} ref={inputRef}/>)}
|
|
107
|
+
|
|
108
|
+
<View style={styles.rightContainer}>
|
|
109
|
+
{loading ? (<Animated.View style={loadingAnimatedStyle} testID={makeTestId(InputTextBaseTestId.loading)}>
|
|
110
|
+
<IconLoader2 color={styles.rightIcon.color} height={iconSize.height} width={iconSize.width}/>
|
|
111
|
+
</Animated.View>) : null}
|
|
112
|
+
|
|
113
|
+
{showClearButton && !disabled ? (<TouchableOpacity accessibilityLabel={clearButtonAccessibilityLabel} testID={makeTestId(InputTextBaseTestId.clearButton)} onPress={clear}>
|
|
114
|
+
<IconX color={styles.rightIcon.color} height={iconSize.height} width={iconSize.width}/>
|
|
115
|
+
</TouchableOpacity>) : null}
|
|
116
|
+
|
|
117
|
+
{secureTextEntryProp === 'toggleable' ? (<TouchableOpacity testID={makeTestId(InputTextBaseTestId.secureInputButton)} onPress={toggleUserDefinedSecureTextEntry}>
|
|
118
|
+
{userDefinedSecureTextEntry ? (<IconEye color={styles.rightIcon.color} height={iconSize.height} width={iconSize.width}/>) : (<IconEyeOff color={styles.rightIcon.color} height={iconSize.height} width={iconSize.width}/>)}
|
|
119
|
+
</TouchableOpacity>) : null}
|
|
120
|
+
|
|
121
|
+
{disabled ? (<IconLock color={styles.rightIcon.color} height={iconSize.height} testID={makeTestId(InputTextBaseTestId.disabledIcon)} width={iconSize.width}/>) : null}
|
|
122
|
+
</View>
|
|
123
|
+
</Pressable>);
|
|
124
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const InputTextBaseTestId: {
|
|
2
|
+
default: string;
|
|
3
|
+
focusOutline: string;
|
|
4
|
+
dangerOutline: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
clearButton: string;
|
|
7
|
+
secureInputButton: string;
|
|
8
|
+
disabledIcon: string;
|
|
9
|
+
floatingPlaceholder: string;
|
|
10
|
+
pressableContainer: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const InputTextBaseTestId = {
|
|
2
|
+
default: 'InputTextBase',
|
|
3
|
+
focusOutline: 'FocusOutline',
|
|
4
|
+
dangerOutline: 'DangerOutline',
|
|
5
|
+
loading: 'Loading',
|
|
6
|
+
clearButton: 'ClearButton',
|
|
7
|
+
secureInputButton: 'SecureInputButton',
|
|
8
|
+
disabledIcon: 'DisabledIcon',
|
|
9
|
+
floatingPlaceholder: 'FloatingPlaceholder',
|
|
10
|
+
pressableContainer: 'PressableContainer',
|
|
11
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Ref, ReactNode } from 'react';
|
|
2
|
+
import type { TextInputProps, ViewStyle, TextInput } from 'react-native';
|
|
3
|
+
/** @see TextInputProps */
|
|
4
|
+
export interface InputTextBaseProps extends Omit<TextInputProps, 'style' | 'editable' | 'secureTextEntry'> {
|
|
5
|
+
/**
|
|
6
|
+
* Управление отображения иконки очистки поля
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
clearable?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Управление режимом скрытия текста
|
|
12
|
+
* - `true` — всегда скрывать (как в TextInput)
|
|
13
|
+
* - `false` — не скрывать
|
|
14
|
+
* - `"toggleable"` — скрытие управляется пользователем через кнопку-глаз
|
|
15
|
+
*/
|
|
16
|
+
secureTextEntry?: boolean | 'toggleable';
|
|
17
|
+
/** Озвучка для кнопки очистки поля */
|
|
18
|
+
clearButtonAccessibilityLabel?: string;
|
|
19
|
+
/** Управление стилем контейнера поля ввода */
|
|
20
|
+
containerStyle?: ViewStyle;
|
|
21
|
+
/** Управление доступностью поля */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Ref для управления полем ввода */
|
|
24
|
+
inputRef?: Ref<TextInput | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Функция для рендера поля ввода.
|
|
27
|
+
* Используется, когда необходимо использовать отличный от стандартного компонент.
|
|
28
|
+
* Например, для реализации масок
|
|
29
|
+
*/
|
|
30
|
+
renderTextInput?: (props: RenderTextInputArgs) => ReactNode;
|
|
31
|
+
/** Управление состоянием компонента */
|
|
32
|
+
state?: 'default' | 'danger';
|
|
33
|
+
/**
|
|
34
|
+
* Управляет видом плейсхолдера в компоненте
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
floatLabel?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type RenderTextInputArgs = TextInputProps & {
|
|
40
|
+
inputRef: Ref<TextInput>;
|
|
41
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export declare const useStyles: () => {
|
|
2
|
+
container: {
|
|
3
|
+
minHeight: number;
|
|
4
|
+
flexDirection: "row";
|
|
5
|
+
borderWidth: number;
|
|
6
|
+
borderRadius: number;
|
|
7
|
+
borderColor: string;
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
justifyContent: "center";
|
|
10
|
+
};
|
|
11
|
+
containerFocused: {
|
|
12
|
+
outlineColor: string;
|
|
13
|
+
outlineWidth: number;
|
|
14
|
+
};
|
|
15
|
+
containerFloatLabel: {
|
|
16
|
+
minHeight: number;
|
|
17
|
+
maxHeight: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
danger: {
|
|
21
|
+
borderColor: string;
|
|
22
|
+
};
|
|
23
|
+
dangerFocused: {
|
|
24
|
+
outlineColor: string;
|
|
25
|
+
};
|
|
26
|
+
disabled: {
|
|
27
|
+
opacity: number;
|
|
28
|
+
borderColor: string;
|
|
29
|
+
backgroundColor: string;
|
|
30
|
+
};
|
|
31
|
+
input: {
|
|
32
|
+
flex: number;
|
|
33
|
+
paddingHorizontal: number;
|
|
34
|
+
fontSize: number;
|
|
35
|
+
borderRadius: number;
|
|
36
|
+
color: string;
|
|
37
|
+
overflow: "hidden";
|
|
38
|
+
includeFontPadding: false;
|
|
39
|
+
verticalAlign: "middle";
|
|
40
|
+
fontFamily: string;
|
|
41
|
+
};
|
|
42
|
+
inputFloatLabel: {
|
|
43
|
+
paddingTop: number;
|
|
44
|
+
paddingBottom: number;
|
|
45
|
+
};
|
|
46
|
+
placeholderTextColor: {
|
|
47
|
+
color: string;
|
|
48
|
+
};
|
|
49
|
+
rightContainer: {
|
|
50
|
+
flexDirection: "row";
|
|
51
|
+
alignItems: "center";
|
|
52
|
+
paddingRight: number;
|
|
53
|
+
gap: number;
|
|
54
|
+
overflow: "hidden";
|
|
55
|
+
};
|
|
56
|
+
rightIcon: {
|
|
57
|
+
color: string;
|
|
58
|
+
};
|
|
59
|
+
iconSize: {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
};
|
|
63
|
+
iconSizeFloatLabel: {
|
|
64
|
+
width: number;
|
|
65
|
+
height: number;
|
|
66
|
+
};
|
|
67
|
+
label: {
|
|
68
|
+
position: "absolute";
|
|
69
|
+
left: number;
|
|
70
|
+
top: number;
|
|
71
|
+
paddingVertical: number;
|
|
72
|
+
paddingLeft: number;
|
|
73
|
+
paddingRight: number;
|
|
74
|
+
color: string;
|
|
75
|
+
includeFontPadding: false;
|
|
76
|
+
verticalAlign: "middle";
|
|
77
|
+
fontSize: number;
|
|
78
|
+
fontFamily: string;
|
|
79
|
+
};
|
|
80
|
+
labelReducedSize: {
|
|
81
|
+
fontSize: number;
|
|
82
|
+
paddingVertical: number;
|
|
83
|
+
top: number;
|
|
84
|
+
fontFamily: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
2
|
+
export const useStyles = makeStyles(({ theme, border, typography, spacing, fonts }) => ({
|
|
3
|
+
container: {
|
|
4
|
+
minHeight: theme.Button.Common.buttonHeight,
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
borderWidth: border.Width.border,
|
|
7
|
+
borderRadius: border.Radius['rounded-xl'],
|
|
8
|
+
borderColor: theme.Form.InputText.inputBorderColor,
|
|
9
|
+
backgroundColor: theme.Form.InputText.inputBg,
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
},
|
|
12
|
+
containerFocused: {
|
|
13
|
+
outlineColor: theme.General.focusOutlineColor,
|
|
14
|
+
outlineWidth: Math.round(theme.General.focusShadowWidth),
|
|
15
|
+
},
|
|
16
|
+
containerFloatLabel: {
|
|
17
|
+
minHeight: theme.Button.Common.buttonHeightXL,
|
|
18
|
+
maxHeight: theme.Button.Common.buttonHeightXL,
|
|
19
|
+
height: theme.Button.Common.buttonHeightXL,
|
|
20
|
+
},
|
|
21
|
+
danger: { borderColor: theme.Form.InputText.inputErrorBorderColor },
|
|
22
|
+
dangerFocused: { outlineColor: theme.General.focusOutlineErrorColor },
|
|
23
|
+
disabled: {
|
|
24
|
+
opacity: 0.6,
|
|
25
|
+
borderColor: theme.Form.InputText.inputBorderColor,
|
|
26
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
27
|
+
},
|
|
28
|
+
input: {
|
|
29
|
+
flex: 1,
|
|
30
|
+
paddingHorizontal: theme.Form.InputText.inputPaddingLeftRight,
|
|
31
|
+
fontSize: typography.Size['text-base'],
|
|
32
|
+
borderRadius: border.Radius['rounded-xl'],
|
|
33
|
+
color: theme.Form.InputText.inputTextColor,
|
|
34
|
+
overflow: 'hidden',
|
|
35
|
+
includeFontPadding: false,
|
|
36
|
+
verticalAlign: 'middle',
|
|
37
|
+
fontFamily: fonts.secondary,
|
|
38
|
+
},
|
|
39
|
+
inputFloatLabel: { paddingTop: 26, paddingBottom: 12 },
|
|
40
|
+
placeholderTextColor: {
|
|
41
|
+
color: theme.Form.InputText.inputPlaceholderTextColor,
|
|
42
|
+
},
|
|
43
|
+
rightContainer: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
paddingRight: theme.Form.InputText.inputPaddingLeftRight,
|
|
47
|
+
gap: theme.Form.InputText.inputPaddingLeftRight,
|
|
48
|
+
overflow: 'hidden',
|
|
49
|
+
},
|
|
50
|
+
rightIcon: { color: theme.Form.InputText.inputIconColor },
|
|
51
|
+
iconSize: {
|
|
52
|
+
width: typography.Size['text-base'],
|
|
53
|
+
height: typography.Size['text-base'],
|
|
54
|
+
},
|
|
55
|
+
iconSizeFloatLabel: {
|
|
56
|
+
width: typography.Size['text-xl'],
|
|
57
|
+
height: typography.Size['text-xl'],
|
|
58
|
+
},
|
|
59
|
+
label: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
left: 7,
|
|
62
|
+
top: 19,
|
|
63
|
+
paddingVertical: 0,
|
|
64
|
+
paddingLeft: spacing.Padding['p-1'],
|
|
65
|
+
paddingRight: spacing.Padding['p-2'],
|
|
66
|
+
color: typography.Color.Common['text-color-secondary'],
|
|
67
|
+
includeFontPadding: false,
|
|
68
|
+
verticalAlign: 'middle',
|
|
69
|
+
fontSize: typography.Size['text-base'],
|
|
70
|
+
fontFamily: fonts.secondary,
|
|
71
|
+
},
|
|
72
|
+
labelReducedSize: {
|
|
73
|
+
fontSize: typography.Size['text-sm'],
|
|
74
|
+
paddingVertical: spacing.Padding['p-1'],
|
|
75
|
+
top: 7,
|
|
76
|
+
fontFamily: fonts.primary,
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ViewProps, type ColorValue } from 'react-native';
|
|
3
|
+
import { type SvgSource } from '../../../utils/SvgUniversal';
|
|
4
|
+
/** Свойства ListBase */
|
|
5
|
+
export interface ListBaseProps extends ViewProps {
|
|
6
|
+
/** Положение левой иконки - вверху или по центру. Правая иконка всегда по центру. */
|
|
7
|
+
iconAlignment?: 'top' | 'center';
|
|
8
|
+
/** Основной текст */
|
|
9
|
+
text: string;
|
|
10
|
+
/** Заголовок */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Пояснение */
|
|
13
|
+
caption?: string;
|
|
14
|
+
/** Левая иконка (SVG) */
|
|
15
|
+
LeftIcon?: SvgSource;
|
|
16
|
+
leftIconColor?: ColorValue;
|
|
17
|
+
/** Правая иконка (SVG) */
|
|
18
|
+
RightIcon?: SvgSource;
|
|
19
|
+
rightIconColor?: ColorValue;
|
|
20
|
+
/** Дополнительный контент. Выводится между названием и правой иконкой */
|
|
21
|
+
extra?: React.ReactNode;
|
|
22
|
+
/** Разделитель - наверху только контента, не захватывая левую иконку, либо наверху всего компонента*/
|
|
23
|
+
divider?: 'content' | 'full';
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
onPress?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Базовый элемент списка
|
|
29
|
+
*
|
|
30
|
+
* Фигма https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=641-2254&m=dev
|
|
31
|
+
*/
|
|
32
|
+
export declare const ListBase: React.NamedExoticComponent<ListBaseProps>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { View, Pressable, } from 'react-native';
|
|
3
|
+
import { SvgUniversal } from '../../../utils/SvgUniversal';
|
|
4
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
5
|
+
import { Subtitle, Body, Caption } from '../../Typography';
|
|
6
|
+
/**
|
|
7
|
+
* Базовый элемент списка
|
|
8
|
+
*
|
|
9
|
+
* Фигма https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=641-2254&m=dev
|
|
10
|
+
*/
|
|
11
|
+
export const ListBase = memo(({ iconAlignment = 'top', text: title, title: subtitle, caption, LeftIcon, leftIconColor, RightIcon, rightIconColor, extra, divider, disabled = false, onPress, style, testID, ...rest }) => {
|
|
12
|
+
const styles = useStyles();
|
|
13
|
+
const leftIconStyle = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
...styles.leftIcon,
|
|
16
|
+
alignSelf: iconAlignment === 'top' ? 'flex-start' : undefined,
|
|
17
|
+
};
|
|
18
|
+
}, [styles.leftIcon, iconAlignment]);
|
|
19
|
+
const fullDivider = divider === 'full' ? styles.divider : {};
|
|
20
|
+
const contentDivider = divider === 'content' ? styles.divider : {};
|
|
21
|
+
const accessibilityLabel = useMemo(() => [subtitle, title].join(' '), [subtitle, title]);
|
|
22
|
+
return (<Pressable accessibilityLabel={accessibilityLabel} accessibilityRole='button' accessibilityValue={{ text: caption }} disabled={disabled} testID={testID || 'ListBase'} onPress={onPress} {...rest}>
|
|
23
|
+
{({ pressed }) => (<View style={[
|
|
24
|
+
style,
|
|
25
|
+
styles.container,
|
|
26
|
+
fullDivider,
|
|
27
|
+
disabled && styles.disabled,
|
|
28
|
+
pressed && styles.pressed,
|
|
29
|
+
]} {...rest}>
|
|
30
|
+
{LeftIcon ? (<View style={leftIconStyle}>
|
|
31
|
+
<SvgUniversal source={LeftIcon} {...styles.icon} color={leftIconColor}/>
|
|
32
|
+
</View>) : null}
|
|
33
|
+
<View style={[styles.content, contentDivider]}>
|
|
34
|
+
<View style={styles.labelContainer}>
|
|
35
|
+
{subtitle ? (<Subtitle color='primary'>{subtitle}</Subtitle>) : null}
|
|
36
|
+
<View style={styles.titleContainer}>
|
|
37
|
+
<Body>{title}</Body>
|
|
38
|
+
{caption ? (<Caption color='secondary'>{caption}</Caption>) : null}
|
|
39
|
+
</View>
|
|
40
|
+
</View>
|
|
41
|
+
<View style={styles.rightSection}>
|
|
42
|
+
{extra ? (<View style={styles.extraContainer}>{extra}</View>) : null}
|
|
43
|
+
{RightIcon ? (<SvgUniversal source={RightIcon} {...styles.icon} color={rightIconColor}/>) : null}
|
|
44
|
+
</View>
|
|
45
|
+
</View>
|
|
46
|
+
</View>)}
|
|
47
|
+
</Pressable>);
|
|
48
|
+
});
|
|
49
|
+
const useStyles = makeStyles(({ spacing, typography, theme, background }) => ({
|
|
50
|
+
container: {
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
paddingLeft: spacing.Padding['p-4'],
|
|
53
|
+
gap: spacing.Padding['p-4'],
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
},
|
|
56
|
+
pressed: { backgroundColor: background.Common['bg-surface-ground-hover'] },
|
|
57
|
+
disabled: { opacity: 0.6 },
|
|
58
|
+
leftIcon: { paddingVertical: spacing.Padding['p-4'] },
|
|
59
|
+
content: {
|
|
60
|
+
flex: 1,
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
justifyContent: 'space-between',
|
|
63
|
+
paddingVertical: spacing.Padding['p-2'],
|
|
64
|
+
paddingEnd: spacing.Padding['p-4'],
|
|
65
|
+
gap: spacing.Gap['gap-4'],
|
|
66
|
+
},
|
|
67
|
+
labelContainer: {
|
|
68
|
+
paddingVertical: spacing.Padding['p-2'],
|
|
69
|
+
gap: spacing.Gap['gap-2'],
|
|
70
|
+
flex: 1,
|
|
71
|
+
},
|
|
72
|
+
titleContainer: { gap: spacing.Gap['gap-1'] },
|
|
73
|
+
extraContainer: { paddingVertical: spacing.Padding['p-2'] },
|
|
74
|
+
icon: {
|
|
75
|
+
width: typography.Size['text-2xl'],
|
|
76
|
+
height: typography.Size['text-2xl'],
|
|
77
|
+
},
|
|
78
|
+
rightSection: {
|
|
79
|
+
flexDirection: 'row',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
paddingVertical: spacing.Padding['p-2'],
|
|
82
|
+
gap: spacing.Gap['gap-4'],
|
|
83
|
+
},
|
|
84
|
+
divider: {
|
|
85
|
+
borderTopColor: theme.Surface['surface-border'],
|
|
86
|
+
borderTopWidth: 1,
|
|
87
|
+
},
|
|
88
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListBase, type ListBaseProps as ListItemBaseProps } from './ListBase';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListBase } from './ListBase';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
2
|
+
export interface MenuItemAccessoryProps {
|
|
3
|
+
/** SVG-иконка */
|
|
4
|
+
readonly Icon: SvgSource;
|
|
5
|
+
/** Неактивное состояние. Если true, заменяет Icon на иконку замка. */
|
|
6
|
+
readonly disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Аксессуар элемента меню. Выводится в крайней левой или крайней правой позиции пункта меню.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MenuItemAccessory: import("react").NamedExoticComponent<MenuItemAccessoryProps>;
|