@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,23 @@
|
|
|
1
|
+
import { IconLock } from '@tabler/icons-react-native';
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
5
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
6
|
+
/**
|
|
7
|
+
* Аксессуар элемента меню. Выводится в крайней левой или крайней правой позиции пункта меню.
|
|
8
|
+
*/
|
|
9
|
+
export const MenuItemAccessory = memo(({ Icon, disabled }) => {
|
|
10
|
+
const styles = useStyles();
|
|
11
|
+
const IconComponent = useMemo(() => (disabled ? IconLock : Icon), [Icon, disabled]);
|
|
12
|
+
return (<View style={styles.container}>
|
|
13
|
+
<SvgUniversal source={IconComponent} {...styles.icon}/>
|
|
14
|
+
</View>);
|
|
15
|
+
});
|
|
16
|
+
const useStyles = makeStyles(({ theme }) => ({
|
|
17
|
+
container: { justifyContent: 'center' },
|
|
18
|
+
icon: {
|
|
19
|
+
width: theme.Menu.Item.menuitemSubmenuIconFontSize,
|
|
20
|
+
height: theme.Menu.Item.menuitemSubmenuIconFontSize,
|
|
21
|
+
color: theme.Menu.Item.menuitemIconColor,
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ColorValue } from 'react-native';
|
|
2
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
3
|
+
import { type BadgeSeverity } from '../Badge/Badge';
|
|
4
|
+
interface MenuItemIconStyle {
|
|
5
|
+
/** Ширина иконки в поинтах*/
|
|
6
|
+
width?: number;
|
|
7
|
+
/** Высота иконки в поинтах*/
|
|
8
|
+
height?: number;
|
|
9
|
+
/** Цвет иконки*/
|
|
10
|
+
color?: ColorValue;
|
|
11
|
+
}
|
|
12
|
+
interface MenuItemIconProps {
|
|
13
|
+
/**
|
|
14
|
+
* SVG-иконка
|
|
15
|
+
* @type {SvgSource}
|
|
16
|
+
*/
|
|
17
|
+
readonly Icon: SvgSource;
|
|
18
|
+
/**
|
|
19
|
+
* Стиль иконки
|
|
20
|
+
*/
|
|
21
|
+
readonly style: MenuItemIconStyle;
|
|
22
|
+
/**
|
|
23
|
+
* Цвет бейджа
|
|
24
|
+
*
|
|
25
|
+
* @type {BadgeSeverity}
|
|
26
|
+
*/
|
|
27
|
+
readonly badgeSeverity?: BadgeSeverity;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Иконка в составе элемента меню. Состоит из центрирующего враппера, иконки и опционального бейджа (точки)
|
|
31
|
+
* @param Icon - SVG-иконка
|
|
32
|
+
* @param style - Стиль иконки
|
|
33
|
+
* @param badgeSeverity - Цвет бейджа (undefined если бейдж не нужен)
|
|
34
|
+
*/
|
|
35
|
+
export declare const MenuItemIcon: ({ Icon, style, badgeSeverity, }: MenuItemIconProps) => import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { View, StyleSheet, } from 'react-native';
|
|
3
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
4
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
5
|
+
import { Badge } from '../Badge/Badge';
|
|
6
|
+
/**
|
|
7
|
+
* Иконка в составе элемента меню. Состоит из центрирующего враппера, иконки и опционального бейджа (точки)
|
|
8
|
+
* @param Icon - SVG-иконка
|
|
9
|
+
* @param style - Стиль иконки
|
|
10
|
+
* @param badgeSeverity - Цвет бейджа (undefined если бейдж не нужен)
|
|
11
|
+
*/
|
|
12
|
+
export const MenuItemIcon = ({ Icon, style, badgeSeverity, }) => {
|
|
13
|
+
const styles = useStyles();
|
|
14
|
+
const [badgePosition, setBadgePosition] = useState({ top: 0, right: 0 });
|
|
15
|
+
const onLayout = useCallback((event) => {
|
|
16
|
+
const { width, height } = event.nativeEvent.layout;
|
|
17
|
+
setBadgePosition({ top: -width / 2, right: -height / 2 });
|
|
18
|
+
}, []);
|
|
19
|
+
const badgeStyle = useMemo(() => StyleSheet.flatten([
|
|
20
|
+
styles.badge,
|
|
21
|
+
{ top: badgePosition.top, right: badgePosition.right },
|
|
22
|
+
]), [badgePosition.right, badgePosition.top, styles.badge]);
|
|
23
|
+
return (<View style={styles.container}>
|
|
24
|
+
<View>
|
|
25
|
+
<SvgUniversal source={Icon} {...style}/>
|
|
26
|
+
{badgeSeverity ? (<Badge dot severity={badgeSeverity} style={badgeStyle} testID='MenuItemIconBadge' onLayout={onLayout}/>) : null}
|
|
27
|
+
</View>
|
|
28
|
+
</View>);
|
|
29
|
+
};
|
|
30
|
+
const useStyles = makeStyles(() => ({
|
|
31
|
+
container: { justifyContent: 'center', position: 'relative' },
|
|
32
|
+
badge: { position: 'absolute' },
|
|
33
|
+
}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ViewProps, type ColorValue, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { SvgSource } from '../../../utils/SvgUniversal';
|
|
4
|
+
import type { BadgeSeverity } from '../../Badge/Badge';
|
|
5
|
+
export interface MenuItemTemplateProps extends ViewProps {
|
|
6
|
+
/** Заголовок пункта меню */
|
|
7
|
+
title: string;
|
|
8
|
+
/** Подзаголовок пункта меню */
|
|
9
|
+
caption?: string;
|
|
10
|
+
/** SVG-иконка слева от заголовка */
|
|
11
|
+
Icon?: SvgSource;
|
|
12
|
+
/** Цвет иконки. Если цвет не задан - применяется такой же цвет что и для аксессуаров (prefix, suffix) */
|
|
13
|
+
iconColor?: ColorValue;
|
|
14
|
+
/** Цвет бейджа (точки) в правом верхнем углу иконки. Бейдж может выводиться только при наличии иконки. */
|
|
15
|
+
badgeSeverity?: BadgeSeverity;
|
|
16
|
+
/** Аксессуар (SVG-иконка) в самой левой части пункта меню */
|
|
17
|
+
PrefixIcon?: SvgSource;
|
|
18
|
+
/** Аксессуар (SVG-иконка) в самой правой части пункта меню */
|
|
19
|
+
SuffixIcon?: SvgSource;
|
|
20
|
+
/**
|
|
21
|
+
* Дополнительный контент пункта меню, выводится справа от текста. Может быть любым react компонентом. Важно! Размеры доплолнительного контента не контролируются пунктом меню и могут его растягивать. Использовать с осторожностью.
|
|
22
|
+
*/
|
|
23
|
+
extra?: ReactNode;
|
|
24
|
+
/** Неактивное состояние. В неактивном состоянии отключается чувствительность к нажатиям, компонент становится полупрозрачным, а аксессуары заменяются иконкой с замком*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Разделитель. Выводится как полоска сверху. Изменяет общую высоту элемента меню.*/
|
|
27
|
+
separator?: boolean;
|
|
28
|
+
/** Обработчик нажатия */
|
|
29
|
+
onPress?: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Кастомные стили
|
|
32
|
+
* Если нужно изменить отступы, не используйте `padding`.
|
|
33
|
+
* Допускается использовать `paddingVertical`, `paddingHorizontal`, `paddingStart`, `paddingEnd`, `paddingLeft`, `paddingRight`, `paddingTop`, `paddingBottom`.
|
|
34
|
+
*/
|
|
35
|
+
style?: StyleProp<ViewStyle>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Шаблон элемента меню. Содержит максимальное количество компонентов внутри пункта меню и используется как основа для создания пунктов меню любой возможной конфигурации.
|
|
39
|
+
*
|
|
40
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=937-6724&m=dev
|
|
41
|
+
*/
|
|
42
|
+
export declare const MenuItemTemplate: import("react").NamedExoticComponent<MenuItemTemplateProps>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { View, Pressable, } from 'react-native';
|
|
3
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
4
|
+
import { Body, Caption } from '../../Typography';
|
|
5
|
+
import { MenuItemAccessory } from '../MenuItemAccessory';
|
|
6
|
+
import { MenuItemIcon } from '../MenuItemIcon';
|
|
7
|
+
/**
|
|
8
|
+
* Шаблон элемента меню. Содержит максимальное количество компонентов внутри пункта меню и используется как основа для создания пунктов меню любой возможной конфигурации.
|
|
9
|
+
*
|
|
10
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=937-6724&m=dev
|
|
11
|
+
*/
|
|
12
|
+
export const MenuItemTemplate = memo(({ title, caption, Icon, iconColor, badgeSeverity, PrefixIcon, SuffixIcon, extra, separator, testID, onPress, disabled, style, ...rest }) => {
|
|
13
|
+
const styles = useStyles();
|
|
14
|
+
const iconStyle = useMemo(() => ({ ...styles.icon, color: iconColor || styles.icon.color }), [iconColor, styles.icon]);
|
|
15
|
+
const pressableStyle = useCallback(({ pressed }) => [
|
|
16
|
+
styles.container,
|
|
17
|
+
pressed && styles.containerPressed,
|
|
18
|
+
style,
|
|
19
|
+
disabled && styles.containerDisabled,
|
|
20
|
+
], [disabled, styles, style]);
|
|
21
|
+
return (<View style={separator ? styles.separator : null}>
|
|
22
|
+
<Pressable accessibilityLabel={title} accessibilityRole='button' accessibilityValue={{ text: caption }} disabled={disabled} style={pressableStyle} testID={testID || 'menuItemButton'} onPress={onPress} {...rest}>
|
|
23
|
+
<View style={styles.contentContainer}>
|
|
24
|
+
{PrefixIcon ? (<MenuItemAccessory Icon={PrefixIcon} disabled={disabled}/>) : null}
|
|
25
|
+
<View style={styles.templateContainer}>
|
|
26
|
+
{Icon ? (<MenuItemIcon Icon={Icon} badgeSeverity={badgeSeverity} style={iconStyle}/>) : null}
|
|
27
|
+
<View style={styles.textContainer}>
|
|
28
|
+
<Body base>{title}</Body>
|
|
29
|
+
{caption ? (<Caption color='secondary'>{caption}</Caption>) : null}
|
|
30
|
+
</View>
|
|
31
|
+
</View>
|
|
32
|
+
{extra}
|
|
33
|
+
{SuffixIcon ? (<MenuItemAccessory Icon={SuffixIcon} disabled={disabled}/>) : null}
|
|
34
|
+
</View>
|
|
35
|
+
</Pressable>
|
|
36
|
+
</View>);
|
|
37
|
+
});
|
|
38
|
+
const useStyles = makeStyles(({ theme, spacing, typography, border }) => ({
|
|
39
|
+
container: {
|
|
40
|
+
borderColor: theme.Menu.Item.menuitemBorderColor,
|
|
41
|
+
borderWidth: border.Width.border,
|
|
42
|
+
borderRadius: theme.Menu.Item.menuitemBorderRadius,
|
|
43
|
+
backgroundColor: theme.Menu.Item.menuitemBg,
|
|
44
|
+
},
|
|
45
|
+
containerPressed: { backgroundColor: theme.Menu.Item.menuitemHoverBg },
|
|
46
|
+
containerDisabled: {
|
|
47
|
+
borderColor: theme.Button.Disabled.disabledButtonBorderColor,
|
|
48
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
49
|
+
opacity: 0.6,
|
|
50
|
+
},
|
|
51
|
+
separator: {
|
|
52
|
+
borderTopWidth: 1,
|
|
53
|
+
borderTopColor: theme.Menu.Overlay.overlayMenuBorderColor,
|
|
54
|
+
paddingTop: theme.Menu.Common.menuSeparatorMarginTopBottom,
|
|
55
|
+
},
|
|
56
|
+
contentContainer: {
|
|
57
|
+
flexDirection: 'row',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
gap: theme.General.inlineSpacing,
|
|
60
|
+
paddingHorizontal: theme.Menu.Item.menuitemPaddingLeftRight,
|
|
61
|
+
paddingVertical: theme.Menu.Item.menuitemPaddingTopBottom,
|
|
62
|
+
},
|
|
63
|
+
accessory: {
|
|
64
|
+
color: theme.Menu.Item.menuitemIconColor,
|
|
65
|
+
width: theme.Menu.Item.menuitemSubmenuIconFontSize,
|
|
66
|
+
height: theme.Menu.Item.menuitemSubmenuIconFontSize,
|
|
67
|
+
},
|
|
68
|
+
templateContainer: {
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
gap: spacing.Gap['gap-2'],
|
|
71
|
+
flexGrow: 1,
|
|
72
|
+
},
|
|
73
|
+
icon: {
|
|
74
|
+
width: typography.Size['text-xl'],
|
|
75
|
+
height: typography.Size['text-xl'],
|
|
76
|
+
color: theme.Menu.Item.menuitemIconColor,
|
|
77
|
+
},
|
|
78
|
+
textContainer: { gap: spacing.Gap['gap-1'] },
|
|
79
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MenuItemTemplate, type MenuItemTemplateProps, } from './Template/MenuItemTemplate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MenuItemTemplate, } from './Template/MenuItemTemplate';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type AccessibilityProps, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
4
|
+
export interface MessageProps extends AccessibilityProps, Pick<ViewProps, 'testID'> {
|
|
5
|
+
/** Текст заголовка */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Тело сообщения */
|
|
8
|
+
body?: ReactNode;
|
|
9
|
+
/** Текст подписи */
|
|
10
|
+
caption?: string;
|
|
11
|
+
/** Футер сообщения */
|
|
12
|
+
footer?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Обработчик нажатия на кнопку закрытия.
|
|
15
|
+
* Кнопка не отображается, если обработчик не передан.
|
|
16
|
+
*/
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Текст на кнопке закрытия тоста
|
|
20
|
+
* Если не указан, в кнопке отображается иконка "крестик"
|
|
21
|
+
* Это свойство игнорируется если onClose = undefined
|
|
22
|
+
*/
|
|
23
|
+
closeLabel?: string;
|
|
24
|
+
/** Срабатывает при истечении таймера */
|
|
25
|
+
onTimerFinish?: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Выбор варианта стиля компонента
|
|
28
|
+
* @default 'info'
|
|
29
|
+
*/
|
|
30
|
+
severity?: 'info' | 'success' | 'warning' | 'danger';
|
|
31
|
+
/** Дополнительная стилизация для контейнера компонента */
|
|
32
|
+
style?: ViewStyle;
|
|
33
|
+
/** Значение таймера, если нужно отображать таймер вместо иконки */
|
|
34
|
+
timerValue?: number;
|
|
35
|
+
/**
|
|
36
|
+
* SVG-иконка.
|
|
37
|
+
* Дефолтные значения:
|
|
38
|
+
* <pre>
|
|
39
|
+
* IconInfoCircle для severity='info'
|
|
40
|
+
* IconCircleCheck для severity='success'
|
|
41
|
+
* IconAlertTriangle для severity='warning'
|
|
42
|
+
* IconCircleX для severity='danger'
|
|
43
|
+
* </pre>
|
|
44
|
+
*/
|
|
45
|
+
Icon?: SvgSource;
|
|
46
|
+
/**
|
|
47
|
+
* Скрыть иконку.
|
|
48
|
+
* Позволяет скрывать установленные или дефолтные иконки
|
|
49
|
+
* Дефолтное значение: false
|
|
50
|
+
*/
|
|
51
|
+
hiddenIcon?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Унифицированный компонент, который используется для отображения информационных сообщений
|
|
55
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=562-2947
|
|
56
|
+
*/
|
|
57
|
+
export declare const Message: import("react").NamedExoticComponent<MessageProps>;
|
|
58
|
+
export declare enum TestId {
|
|
59
|
+
Container = "MessageContainer",
|
|
60
|
+
CloseButton = "CloseButton",
|
|
61
|
+
Title = "Title",
|
|
62
|
+
Caption = "Caption",
|
|
63
|
+
Body = "Body",
|
|
64
|
+
Icon = "Icon"
|
|
65
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { IconAlertCircle, IconAlertTriangle, IconCircleCheck, IconInfoCircle, IconX, } from '@tabler/icons-react-native';
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
|
+
import { View, } from 'react-native';
|
|
4
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
5
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
6
|
+
import { ButtonSeverity } from '../Button/ButtonSeverity';
|
|
7
|
+
import { Timer } from '../Timer/Timer';
|
|
8
|
+
import { Body, Caption } from '../Typography';
|
|
9
|
+
/**
|
|
10
|
+
* Унифицированный компонент, который используется для отображения информационных сообщений
|
|
11
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=562-2947
|
|
12
|
+
*/
|
|
13
|
+
export const Message = memo(({ title, body, caption, footer, onClose, closeLabel, onTimerFinish, severity = 'info', hiddenIcon = false, style, testID, timerValue, Icon: IconProp, ...rest }) => {
|
|
14
|
+
const styles = useStyles();
|
|
15
|
+
const Icon = useMemo(() => {
|
|
16
|
+
if (IconProp) {
|
|
17
|
+
return IconProp;
|
|
18
|
+
}
|
|
19
|
+
switch (severity) {
|
|
20
|
+
case 'info':
|
|
21
|
+
return IconInfoCircle;
|
|
22
|
+
case 'success':
|
|
23
|
+
return IconCircleCheck;
|
|
24
|
+
case 'warning':
|
|
25
|
+
return IconAlertTriangle;
|
|
26
|
+
case 'danger':
|
|
27
|
+
return IconAlertCircle;
|
|
28
|
+
}
|
|
29
|
+
}, [IconProp, severity]);
|
|
30
|
+
const button = useMemo(() => {
|
|
31
|
+
if (!onClose) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const buttonCommonProps = { severity, size: 'small', variant: 'outlined', onPress: onClose };
|
|
35
|
+
if (closeLabel) {
|
|
36
|
+
return (<ButtonSeverity label={closeLabel} {...buttonCommonProps} testID={TestId.CloseButton}/>);
|
|
37
|
+
}
|
|
38
|
+
return (<ButtonSeverity iconOnly Icon={IconX} {...buttonCommonProps} testID={TestId.CloseButton}/>);
|
|
39
|
+
}, [closeLabel, severity, onClose]);
|
|
40
|
+
const LeftContent = useMemo(() => {
|
|
41
|
+
if (timerValue) {
|
|
42
|
+
return <Timer countFrom={timerValue} onFinish={onTimerFinish}/>;
|
|
43
|
+
}
|
|
44
|
+
if (!hiddenIcon) {
|
|
45
|
+
return (<SvgUniversal color={styles[`content${severity}`].borderColor} height={styles.iconSize.height} source={Icon} testID={TestId.Icon} width={styles.iconSize.width}/>);
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}, [timerValue, hiddenIcon, onTimerFinish, Icon, styles, severity]);
|
|
49
|
+
return (<View accessible style={[styles.container, styles[severity], style]} testID={testID || TestId.Container} {...rest}>
|
|
50
|
+
<View style={[styles.content, styles[`content${severity}`]]}>
|
|
51
|
+
<View style={styles.titleRow}>
|
|
52
|
+
{LeftContent}
|
|
53
|
+
<View style={styles.titleTextContainer}>
|
|
54
|
+
<Body base testID={TestId.Title} weight='bold'>
|
|
55
|
+
{title}
|
|
56
|
+
</Body>
|
|
57
|
+
{caption ? (<Caption testID={TestId.Caption}>{caption}</Caption>) : null}
|
|
58
|
+
</View>
|
|
59
|
+
{button}
|
|
60
|
+
</View>
|
|
61
|
+
{body ? <View testID={TestId.Body}>{body}</View> : null}
|
|
62
|
+
{footer}
|
|
63
|
+
</View>
|
|
64
|
+
</View>);
|
|
65
|
+
});
|
|
66
|
+
const useStyles = makeStyles(({ theme, typography, spacing, border }) => ({
|
|
67
|
+
container: {
|
|
68
|
+
borderRadius: theme.General.borderRadiusXL,
|
|
69
|
+
borderWidth: border.Width.border,
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
},
|
|
72
|
+
content: {
|
|
73
|
+
flexGrow: 1,
|
|
74
|
+
borderLeftWidth: border.Width['border-3'] - border.Width.border,
|
|
75
|
+
padding: spacing.Padding['p-4'],
|
|
76
|
+
paddingLeft: spacing.Padding['p-5'],
|
|
77
|
+
gap: spacing.Gap['gap-4'],
|
|
78
|
+
},
|
|
79
|
+
info: {
|
|
80
|
+
borderColor: theme.Message.Severities.Info.infoMessageBorderColor,
|
|
81
|
+
backgroundColor: theme.Message.Severities.Info.infoMessageBg,
|
|
82
|
+
},
|
|
83
|
+
contentinfo: {
|
|
84
|
+
borderColor: theme.Message.Severities.Info.infoMessageIconColor,
|
|
85
|
+
},
|
|
86
|
+
success: {
|
|
87
|
+
borderColor: theme.Message.Severities.Success.successMessageBorderColor,
|
|
88
|
+
backgroundColor: theme.Message.Severities.Success.successMessageBg,
|
|
89
|
+
},
|
|
90
|
+
contentsuccess: {
|
|
91
|
+
borderColor: theme.Message.Severities.Success.successMessageIconColor,
|
|
92
|
+
},
|
|
93
|
+
warning: {
|
|
94
|
+
borderColor: theme.Message.Severities.Warning.warningMessageBorderColor,
|
|
95
|
+
backgroundColor: theme.Message.Severities.Warning.warningMessageBg,
|
|
96
|
+
},
|
|
97
|
+
contentwarning: {
|
|
98
|
+
borderColor: theme.Message.Severities.Warning.warningMessageIconColor,
|
|
99
|
+
},
|
|
100
|
+
danger: {
|
|
101
|
+
borderColor: theme.Message.Severities.Danger.dangerMessageBorderColor,
|
|
102
|
+
backgroundColor: theme.Message.Severities.Danger.dangerMessageBg,
|
|
103
|
+
},
|
|
104
|
+
contentdanger: {
|
|
105
|
+
borderColor: theme.Message.Severities.Danger.dangerMessageIconColor,
|
|
106
|
+
},
|
|
107
|
+
titleRow: { flexDirection: 'row', gap: spacing.Gap['gap-4'] },
|
|
108
|
+
titleTextContainer: {
|
|
109
|
+
flex: 1,
|
|
110
|
+
alignSelf: 'center',
|
|
111
|
+
gap: spacing.Gap['gap-1'],
|
|
112
|
+
},
|
|
113
|
+
iconSize: {
|
|
114
|
+
width: typography.Size['text-4xl'],
|
|
115
|
+
height: typography.Size['text-4xl'],
|
|
116
|
+
},
|
|
117
|
+
}));
|
|
118
|
+
export var TestId;
|
|
119
|
+
(function (TestId) {
|
|
120
|
+
TestId["Container"] = "MessageContainer";
|
|
121
|
+
TestId["CloseButton"] = "CloseButton";
|
|
122
|
+
TestId["Title"] = "Title";
|
|
123
|
+
TestId["Caption"] = "Caption";
|
|
124
|
+
TestId["Body"] = "Body";
|
|
125
|
+
TestId["Icon"] = "Icon";
|
|
126
|
+
})(TestId || (TestId = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Message, type MessageProps } from './Message';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Message } from './Message';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Тип свойств компонента ProgressBar
|
|
4
|
+
* @see ProgressBar
|
|
5
|
+
*/
|
|
6
|
+
export interface ProgressBarProps extends Pick<ViewProps, 'testID'> {
|
|
7
|
+
/**
|
|
8
|
+
* Значение прогресса от 0 до 100
|
|
9
|
+
*/
|
|
10
|
+
value: number;
|
|
11
|
+
/**
|
|
12
|
+
* Отображение значения прогресса
|
|
13
|
+
*/
|
|
14
|
+
showValue?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Стилизация компонента ProgressBar
|
|
17
|
+
*/
|
|
18
|
+
style?: StyleProp<ProgressBarStyle>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Компонент ProgressBar
|
|
22
|
+
* @param value - значение прогресса от 0 до 100
|
|
23
|
+
* @param showValue - отображение значения прогресса
|
|
24
|
+
* @param style - стилизация компонента ProgressBar
|
|
25
|
+
* @see ProgressBarProps
|
|
26
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5024&m=dev
|
|
27
|
+
*/
|
|
28
|
+
export declare const ProgressBar: import("react").NamedExoticComponent<ProgressBarProps>;
|
|
29
|
+
/**
|
|
30
|
+
* Стиль компонента ProgressBar
|
|
31
|
+
* @see ProgressBar
|
|
32
|
+
*/
|
|
33
|
+
export type ProgressBarStyle = Pick<ViewStyle, 'height' | 'width' | 'maxWidth' | 'minWidth' | 'maxHeight' | 'minHeight' | 'flex' | 'alignSelf' | 'position' | 'top' | 'right' | 'left' | 'bottom' | 'margin' | 'marginBottom' | 'marginEnd' | 'marginHorizontal' | 'marginLeft' | 'marginRight' | 'marginStart' | 'marginTop' | 'marginVertical'>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { View, Text, } from 'react-native';
|
|
3
|
+
import Animated, { useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
5
|
+
/**
|
|
6
|
+
* Компонент ProgressBar
|
|
7
|
+
* @param value - значение прогресса от 0 до 100
|
|
8
|
+
* @param showValue - отображение значения прогресса
|
|
9
|
+
* @param style - стилизация компонента ProgressBar
|
|
10
|
+
* @see ProgressBarProps
|
|
11
|
+
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5024&m=dev
|
|
12
|
+
*/
|
|
13
|
+
export const ProgressBar = memo(({ value: propsValue, showValue = false, style }) => {
|
|
14
|
+
const styles = useStyles();
|
|
15
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
16
|
+
const indicatorWidth = useSharedValue(0);
|
|
17
|
+
const onLayout = useCallback(({ nativeEvent: { layout: { width }, }, }) => {
|
|
18
|
+
setContainerWidth(width);
|
|
19
|
+
}, []);
|
|
20
|
+
const value = useMemo(() => {
|
|
21
|
+
if (propsValue > 100) {
|
|
22
|
+
return 100;
|
|
23
|
+
}
|
|
24
|
+
if (propsValue < 0) {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
return propsValue;
|
|
28
|
+
}, [propsValue]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
indicatorWidth.value = withTiming(containerWidth * (value / 100));
|
|
31
|
+
}, [containerWidth, indicatorWidth, value]);
|
|
32
|
+
return (<View style={[
|
|
33
|
+
styles.container,
|
|
34
|
+
style,
|
|
35
|
+
showValue && styles.containerShowValue,
|
|
36
|
+
]} onLayout={onLayout}>
|
|
37
|
+
<Animated.View style={[styles.indicator, { width: indicatorWidth }]}>
|
|
38
|
+
{showValue ? (<Text style={styles.indicatorText}>{value} %</Text>) : null}
|
|
39
|
+
</Animated.View>
|
|
40
|
+
</View>);
|
|
41
|
+
});
|
|
42
|
+
const useStyles = makeStyles(({ theme, typography, border, fonts }) => ({
|
|
43
|
+
container: {
|
|
44
|
+
borderRadius: border.Radius['rounded-full'],
|
|
45
|
+
backgroundColor: theme.Misc.ProgressBar.progressBarBg,
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
},
|
|
48
|
+
indicator: {
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
backgroundColor: theme.Misc.ProgressBar.progressBarValueBg,
|
|
52
|
+
height: '100%',
|
|
53
|
+
overflow: 'hidden',
|
|
54
|
+
},
|
|
55
|
+
containerShowValue: { height: theme.Misc.ProgressBar.progressBarHeight },
|
|
56
|
+
indicatorText: {
|
|
57
|
+
fontSize: typography.Size['text-xs'],
|
|
58
|
+
textAlign: 'center',
|
|
59
|
+
color: theme.Misc.ProgressBar.progressBarValueTextColor,
|
|
60
|
+
fontFamily: fonts.primary,
|
|
61
|
+
},
|
|
62
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProgressBar, type ProgressBarProps } from './ProgressBar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProgressBar } from './ProgressBar';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ProgressSpinnerProps {
|
|
2
|
+
/**
|
|
3
|
+
* Выбор размера компонента
|
|
4
|
+
* @default 'md'
|
|
5
|
+
*/
|
|
6
|
+
size?: 'xl' | 'lg' | 'md' | 'sm';
|
|
7
|
+
/**
|
|
8
|
+
* Выбор цвета компонента
|
|
9
|
+
* @default 'primary'
|
|
10
|
+
*/
|
|
11
|
+
fill?: 'primary' | 'white';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Используется для отображения состояний ожидания в интерфейсе
|
|
15
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=1219-3086
|
|
16
|
+
*/
|
|
17
|
+
export declare const ProgressSpinner: import("react").NamedExoticComponent<ProgressSpinnerProps>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { memo, useEffect, useMemo } from 'react';
|
|
2
|
+
import Animated, { Easing, interpolate, useAnimatedProps, useAnimatedStyle, useSharedValue, withRepeat, withTiming, } from 'react-native-reanimated';
|
|
3
|
+
import Svg, { Circle } from 'react-native-svg';
|
|
4
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
5
|
+
// eslint-disable-next-line import-x/no-deprecated
|
|
6
|
+
const AnimatedSvg = Animated.createAnimatedComponent(Svg);
|
|
7
|
+
// eslint-disable-next-line import-x/no-deprecated
|
|
8
|
+
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
9
|
+
const STROKE_WIDTH = 2;
|
|
10
|
+
/**
|
|
11
|
+
* Используется для отображения состояний ожидания в интерфейсе
|
|
12
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=1219-3086
|
|
13
|
+
*/
|
|
14
|
+
export const ProgressSpinner = memo(({ size = 'md', fill = 'primary' }) => {
|
|
15
|
+
const styles = useStyles();
|
|
16
|
+
const circleAnimation = useSharedValue(0);
|
|
17
|
+
const containerAnimation = useSharedValue(0);
|
|
18
|
+
const sizeInDp = useMemo(() => {
|
|
19
|
+
switch (size) {
|
|
20
|
+
case 'xl':
|
|
21
|
+
return 56;
|
|
22
|
+
case 'lg':
|
|
23
|
+
return 42;
|
|
24
|
+
case 'md':
|
|
25
|
+
return 28;
|
|
26
|
+
case 'sm':
|
|
27
|
+
return 14;
|
|
28
|
+
}
|
|
29
|
+
}, [size]);
|
|
30
|
+
const color = useMemo(() => {
|
|
31
|
+
switch (fill) {
|
|
32
|
+
case 'primary':
|
|
33
|
+
return styles.primary.color;
|
|
34
|
+
case 'white':
|
|
35
|
+
return styles.white.color;
|
|
36
|
+
}
|
|
37
|
+
}, [fill, styles.primary.color, styles.white.color]);
|
|
38
|
+
const center = useMemo(() => sizeInDp / 2, [sizeInDp]);
|
|
39
|
+
const radius = useMemo(() => center - STROKE_WIDTH / 2, [center]);
|
|
40
|
+
const circleLength = useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
41
|
+
const containerAnimatedStyle = useAnimatedStyle(() => ({
|
|
42
|
+
transform: [{ rotate: `${containerAnimation.value * 360}deg` }],
|
|
43
|
+
}));
|
|
44
|
+
const circleAnimatedProps = useAnimatedProps(() => ({
|
|
45
|
+
strokeDasharray: [
|
|
46
|
+
interpolate(circleAnimation.value, [0, 0.5, 1], [1, 0.7 * circleLength, circleLength]),
|
|
47
|
+
circleLength,
|
|
48
|
+
],
|
|
49
|
+
strokeDashoffset: interpolate(circleAnimation.value, [0, 0.5, 1], [0, -(0.3 * circleLength), -circleLength + 2]),
|
|
50
|
+
}));
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
circleAnimation.value = withRepeat(withTiming(1, { duration: 1500, easing: Easing.inOut(Easing.ease) }), -1, false);
|
|
53
|
+
}, [circleAnimation]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
containerAnimation.value = withRepeat(withTiming(1, { duration: 2000, easing: Easing.linear }), -1);
|
|
56
|
+
}, [containerAnimation]);
|
|
57
|
+
return (<AnimatedSvg style={[containerAnimatedStyle, { width: sizeInDp, height: sizeInDp }]} testID={TestId.ProgressSpinner}>
|
|
58
|
+
<AnimatedCircle animatedProps={circleAnimatedProps} cx={center} cy={center} fill='none' r={radius} stroke={color} strokeLinecap='round' strokeWidth={STROKE_WIDTH}/>
|
|
59
|
+
</AnimatedSvg>);
|
|
60
|
+
});
|
|
61
|
+
const useStyles = makeStyles(({ theme, global }) => ({
|
|
62
|
+
primary: { color: theme.General.primaryColor },
|
|
63
|
+
white: { color: global.Neutrals.White['white-100'] },
|
|
64
|
+
}));
|
|
65
|
+
var TestId;
|
|
66
|
+
(function (TestId) {
|
|
67
|
+
TestId["ProgressSpinner"] = "ProgressSpinner";
|
|
68
|
+
})(TestId || (TestId = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProgressSpinner, type ProgressSpinnerProps } from './ProgressSpinner';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProgressSpinner } from './ProgressSpinner';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AccessibilityProps, type ViewProps } from 'react-native';
|
|
2
|
+
export interface RadioButtonProps extends AccessibilityProps, Pick<ViewProps, 'testID'> {
|
|
3
|
+
/** Обработчик нажатия на кнопку */
|
|
4
|
+
onPress: () => void;
|
|
5
|
+
/**
|
|
6
|
+
* true, если необходим компонент в активном состоянии
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Управление доступностью компонента
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Выбор состояния компонента */
|
|
16
|
+
state?: 'default' | 'danger';
|
|
17
|
+
}
|
|
18
|
+
export declare const RadioButton: import("react").NamedExoticComponent<RadioButtonProps>;
|