@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,141 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet, } from 'react-native';
|
|
3
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
4
|
+
import { useTypeBasedStyle } from './useTypeBasedStyle';
|
|
5
|
+
export const useButtonContainerCallbackStyle = (size, variant, shape, disabled, loading, iconOnly, style, containerVariantStyles, pressedVariantStyles) => {
|
|
6
|
+
const styles = useButtonContainerStyle();
|
|
7
|
+
const sizeBasedStyle = useTypeBasedStyle(size, styles);
|
|
8
|
+
const variantBasedStyle = useTypeBasedStyle(variant, containerVariantStyles);
|
|
9
|
+
const shapeBasedStyle = useTypeBasedStyle(shape, styles);
|
|
10
|
+
const pressedStyle = useTypeBasedStyle(variant, pressedVariantStyles);
|
|
11
|
+
const iconOnlyLinkContainerStyle = useIconOnlyLinkContainerStyle();
|
|
12
|
+
const disabledStyle = useMemo(() => {
|
|
13
|
+
if (variant === 'link') {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return styles.disabled;
|
|
17
|
+
}, [styles.disabled, variant]);
|
|
18
|
+
return useCallback(({ pressed }) => {
|
|
19
|
+
const containerStyle = [
|
|
20
|
+
styles.container,
|
|
21
|
+
sizeBasedStyle,
|
|
22
|
+
variantBasedStyle,
|
|
23
|
+
shapeBasedStyle,
|
|
24
|
+
];
|
|
25
|
+
if (iconOnly) {
|
|
26
|
+
containerStyle.push(styles.iconOnly);
|
|
27
|
+
if (variant === 'link') {
|
|
28
|
+
containerStyle.push(iconOnlyLinkContainerStyle[size]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (disabled || loading) {
|
|
32
|
+
containerStyle.push(disabledStyle);
|
|
33
|
+
}
|
|
34
|
+
if (pressed) {
|
|
35
|
+
containerStyle.push(pressedStyle);
|
|
36
|
+
}
|
|
37
|
+
if (typeof style === 'function') {
|
|
38
|
+
containerStyle.push(style({ pressed }));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
containerStyle.push(style);
|
|
42
|
+
}
|
|
43
|
+
return StyleSheet.flatten(containerStyle);
|
|
44
|
+
}, [
|
|
45
|
+
disabled,
|
|
46
|
+
disabledStyle,
|
|
47
|
+
iconOnly,
|
|
48
|
+
iconOnlyLinkContainerStyle,
|
|
49
|
+
loading,
|
|
50
|
+
pressedStyle,
|
|
51
|
+
shapeBasedStyle,
|
|
52
|
+
size,
|
|
53
|
+
sizeBasedStyle,
|
|
54
|
+
style,
|
|
55
|
+
styles.container,
|
|
56
|
+
styles.iconOnly,
|
|
57
|
+
variant,
|
|
58
|
+
variantBasedStyle,
|
|
59
|
+
]);
|
|
60
|
+
};
|
|
61
|
+
const useButtonContainerStyle = makeStyles(({ theme, border, spacing }) => ({
|
|
62
|
+
container: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
borderWidth: border.Width.border,
|
|
67
|
+
},
|
|
68
|
+
xlarge: {
|
|
69
|
+
paddingHorizontal: spacing.Padding['p-6'],
|
|
70
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
71
|
+
height: theme.Button.Common.buttonHeightXL,
|
|
72
|
+
minHeight: theme.Button.Common.buttonHeightXL,
|
|
73
|
+
maxHeight: theme.Button.Common.buttonHeightXL,
|
|
74
|
+
gap: spacing.Gap['gap-3'],
|
|
75
|
+
borderRadius: theme.General.borderRadius2XL,
|
|
76
|
+
},
|
|
77
|
+
large: {
|
|
78
|
+
paddingHorizontal: spacing.Padding['p-6'],
|
|
79
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
80
|
+
height: theme.Button.Common.buttonHeightLG,
|
|
81
|
+
minHeight: theme.Button.Common.buttonHeightLG,
|
|
82
|
+
maxHeight: theme.Button.Common.buttonHeightLG,
|
|
83
|
+
gap: spacing.Gap['gap-3'],
|
|
84
|
+
borderRadius: theme.General.borderRadius2XL,
|
|
85
|
+
},
|
|
86
|
+
base: {
|
|
87
|
+
paddingHorizontal: theme.Button.Common.buttonPaddingLeftRight,
|
|
88
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
89
|
+
height: theme.Button.Common.buttonHeight,
|
|
90
|
+
minHeight: theme.Button.Common.buttonHeight,
|
|
91
|
+
maxHeight: theme.Button.Common.buttonHeight,
|
|
92
|
+
gap: theme.General.inlineSpacing,
|
|
93
|
+
borderRadius: theme.General.borderRadiusXL,
|
|
94
|
+
},
|
|
95
|
+
small: {
|
|
96
|
+
paddingHorizontal: spacing.Padding['p-3'],
|
|
97
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
98
|
+
height: theme.Button.Common.buttonHeightSM,
|
|
99
|
+
minHeight: theme.Button.Common.buttonHeightSM,
|
|
100
|
+
maxHeight: theme.Button.Common.buttonHeightSM,
|
|
101
|
+
gap: theme.General.inlineSpacing,
|
|
102
|
+
borderRadius: theme.General.borderRadiusXL,
|
|
103
|
+
},
|
|
104
|
+
square: {},
|
|
105
|
+
circle: { borderRadius: border.Radius['rounded-full'] },
|
|
106
|
+
disabled: {
|
|
107
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
108
|
+
borderColor: theme.Button.Disabled.disabledButtonBorderColor,
|
|
109
|
+
},
|
|
110
|
+
iconOnly: { aspectRatio: 1 },
|
|
111
|
+
}));
|
|
112
|
+
const useIconOnlyLinkContainerStyle = makeStyles(({ spacing, sizing }) => ({
|
|
113
|
+
xlarge: {
|
|
114
|
+
paddingHorizontal: spacing.Gap['gap-1'],
|
|
115
|
+
paddingVertical: spacing.Gap['gap-1'],
|
|
116
|
+
height: sizing.Height['h-2'],
|
|
117
|
+
minHeight: sizing.Height['h-2'],
|
|
118
|
+
maxHeight: sizing.Height['h-2'],
|
|
119
|
+
},
|
|
120
|
+
large: {
|
|
121
|
+
paddingHorizontal: spacing.Gap['gap-0'],
|
|
122
|
+
paddingVertical: spacing.Gap['gap-0'],
|
|
123
|
+
height: 24.5,
|
|
124
|
+
minHeight: 24.5,
|
|
125
|
+
maxHeight: 24.5,
|
|
126
|
+
},
|
|
127
|
+
base: {
|
|
128
|
+
paddingHorizontal: spacing.Gap['gap-1'],
|
|
129
|
+
paddingVertical: spacing.Gap['gap-1'],
|
|
130
|
+
height: 21.5,
|
|
131
|
+
minHeight: 21.5,
|
|
132
|
+
maxHeight: 21.5,
|
|
133
|
+
},
|
|
134
|
+
small: {
|
|
135
|
+
paddingHorizontal: spacing.Gap['gap-1'],
|
|
136
|
+
paddingVertical: spacing.Gap['gap-1'],
|
|
137
|
+
height: sizing.Height['h-1'],
|
|
138
|
+
minHeight: sizing.Height['h-2'],
|
|
139
|
+
maxHeight: sizing.Height['h-2'],
|
|
140
|
+
},
|
|
141
|
+
}));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type TextStyle } from 'react-native';
|
|
2
|
+
import type { BaseButtonProps, ButtonVariant, LabelVariantStyles } from '../types';
|
|
3
|
+
export declare const useButtonLabelStyle: <Variant extends ButtonVariant>(size: Required<BaseButtonProps<Variant>>["size"], variant: Required<BaseButtonProps<Variant>>["variant"], disabled: Required<BaseButtonProps<Variant>>["disabled"], loading: Required<BaseButtonProps<Variant>>["loading"], labelVariantStyles: LabelVariantStyles<Variant>) => TextStyle;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
4
|
+
import { useTypeBasedStyle } from './useTypeBasedStyle';
|
|
5
|
+
export const useButtonLabelStyle = (size, variant, disabled, loading, labelVariantStyles) => {
|
|
6
|
+
const styles = useButtonLabelStyles();
|
|
7
|
+
const sizeBasedStyle = useTypeBasedStyle(size, styles);
|
|
8
|
+
const variantBasedStyle = useTypeBasedStyle(variant, labelVariantStyles);
|
|
9
|
+
return useMemo(() => {
|
|
10
|
+
const containerStyle = [
|
|
11
|
+
styles.font,
|
|
12
|
+
sizeBasedStyle,
|
|
13
|
+
variantBasedStyle,
|
|
14
|
+
];
|
|
15
|
+
if (disabled || loading) {
|
|
16
|
+
containerStyle.push(styles.disabled);
|
|
17
|
+
}
|
|
18
|
+
return StyleSheet.flatten(containerStyle);
|
|
19
|
+
}, [
|
|
20
|
+
disabled,
|
|
21
|
+
loading,
|
|
22
|
+
sizeBasedStyle,
|
|
23
|
+
styles.disabled,
|
|
24
|
+
styles.font,
|
|
25
|
+
variantBasedStyle,
|
|
26
|
+
]);
|
|
27
|
+
};
|
|
28
|
+
const useButtonLabelStyles = makeStyles(({ theme, typography, fonts }) => ({
|
|
29
|
+
font: {
|
|
30
|
+
fontWeight: 600,
|
|
31
|
+
includeFontPadding: false,
|
|
32
|
+
verticalAlign: 'middle',
|
|
33
|
+
fontFamily: fonts.primary,
|
|
34
|
+
},
|
|
35
|
+
xlarge: { fontSize: typography.Size['text-xl'] },
|
|
36
|
+
large: { fontSize: typography.Size['text-xl'] },
|
|
37
|
+
base: { fontSize: typography.Size['text-base'] },
|
|
38
|
+
small: { fontSize: typography.Size['text-sm'] },
|
|
39
|
+
disabled: { color: theme.Button.Disabled.disabledButtonTextColor },
|
|
40
|
+
}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ColorValue } from 'react-native';
|
|
2
|
+
import type { BaseButtonProps, ButtonVariant, IconVariantStyles } from '../types';
|
|
3
|
+
export declare const useIconStyle: <Variant extends ButtonVariant>(size: Required<BaseButtonProps<Variant>>["size"], variant: Required<BaseButtonProps<Variant>>["variant"], disabled: Required<BaseButtonProps<Variant>>["disabled"], loading: Required<BaseButtonProps<Variant>>["loading"], iconVariantStyles: IconVariantStyles<Variant>) => {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
color: ColorValue;
|
|
7
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
4
|
+
import { useTypeBasedStyle } from './useTypeBasedStyle';
|
|
5
|
+
export const useIconStyle = (size, variant, disabled, loading, iconVariantStyles) => {
|
|
6
|
+
const styles = useStyles();
|
|
7
|
+
const sizeBasedStyle = useTypeBasedStyle(size, styles);
|
|
8
|
+
const variantBasedStyle = useTypeBasedStyle(variant, iconVariantStyles);
|
|
9
|
+
return useMemo(() => {
|
|
10
|
+
const containerStyle = [sizeBasedStyle, variantBasedStyle];
|
|
11
|
+
if (disabled || loading) {
|
|
12
|
+
containerStyle.push(styles.disabled);
|
|
13
|
+
}
|
|
14
|
+
return StyleSheet.flatten(containerStyle);
|
|
15
|
+
}, [disabled, loading, sizeBasedStyle, styles.disabled, variantBasedStyle]);
|
|
16
|
+
};
|
|
17
|
+
const useStyles = makeStyles(({ theme, typography }) => ({
|
|
18
|
+
xlarge: {
|
|
19
|
+
height: typography.Size['text-2xl'],
|
|
20
|
+
width: typography.Size['text-2xl'],
|
|
21
|
+
},
|
|
22
|
+
large: {
|
|
23
|
+
height: typography.Size['text-2xl'],
|
|
24
|
+
width: typography.Size['text-2xl'],
|
|
25
|
+
},
|
|
26
|
+
base: {
|
|
27
|
+
height: typography.Size['text-xl'],
|
|
28
|
+
width: typography.Size['text-xl'],
|
|
29
|
+
},
|
|
30
|
+
small: {
|
|
31
|
+
height: typography.Size['text-base'],
|
|
32
|
+
width: typography.Size['text-base'],
|
|
33
|
+
},
|
|
34
|
+
disabled: { color: theme.Button.Disabled.disabledButtonTextColor },
|
|
35
|
+
}));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle, TextStyle, ImageStyle } from 'react-native';
|
|
2
|
+
export declare const useTypeBasedStyle: <Type extends string, Style extends TextStyle | ViewStyle | ImageStyle | object>(type: Type, styles: Record<Type, StyleProp<Style>>) => Record<Type, StyleProp<Style>>[Type];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AccessibilityProps } from 'react-native';
|
|
3
|
+
import type { ViewProps } from 'react-native-svg/lib/typescript/fabric/utils';
|
|
4
|
+
type CheckboxState = 'default' | 'danger';
|
|
5
|
+
export interface CheckboxProps extends AccessibilityProps, Pick<ViewProps, 'testID'> {
|
|
6
|
+
/** Обработчик нажатия на чекбокс */
|
|
7
|
+
readonly onPress: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* true, если необходим компонент в активном состоянии
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
readonly checked?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* true, если необходим компонент в неопределенном состоянии
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
readonly indeterminate?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Управление доступностью компонента
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
readonly disabled?: boolean;
|
|
23
|
+
/** Выбор состояния компонента */
|
|
24
|
+
readonly state: CheckboxState;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Используется для множественного выбора элементов
|
|
28
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5316
|
|
29
|
+
*/
|
|
30
|
+
export declare const Checkbox: React.NamedExoticComponent<CheckboxProps>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IconCheck, IconMinus } from '@tabler/icons-react-native';
|
|
2
|
+
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { Pressable, StyleSheet, View, } from 'react-native';
|
|
4
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
5
|
+
import { usePressableStyles } from './hooks/usePressableStyles';
|
|
6
|
+
/**
|
|
7
|
+
* Используется для множественного выбора элементов
|
|
8
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5316
|
|
9
|
+
*/
|
|
10
|
+
export const Checkbox = memo(({ onPress, checked = false, disabled = false, indeterminate = false, testID, state, }) => {
|
|
11
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
12
|
+
const Icon = useMemo(() => {
|
|
13
|
+
if (indeterminate) {
|
|
14
|
+
return IconMinus;
|
|
15
|
+
}
|
|
16
|
+
if (checked) {
|
|
17
|
+
return IconCheck;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}, [indeterminate, checked]);
|
|
21
|
+
const getPressableStyles = usePressableStyles({
|
|
22
|
+
checked,
|
|
23
|
+
indeterminate,
|
|
24
|
+
disabled,
|
|
25
|
+
state,
|
|
26
|
+
});
|
|
27
|
+
const styles = useStyles();
|
|
28
|
+
const onPressIn = useCallback(() => {
|
|
29
|
+
setIsPressed(true);
|
|
30
|
+
}, []);
|
|
31
|
+
const onPressOut = useCallback(() => {
|
|
32
|
+
setIsPressed(false);
|
|
33
|
+
}, []);
|
|
34
|
+
const pressableStyles = useMemo(() => {
|
|
35
|
+
return getPressableStyles(isPressed);
|
|
36
|
+
}, [getPressableStyles, isPressed]);
|
|
37
|
+
return (<Pressable accessibilityRole='button' disabled={disabled} hitSlop={10} style={styles.container} testID={testID || 'CheckboxButton_Pressable'} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut}>
|
|
38
|
+
<View style={[styles.background, pressableStyles]}/>
|
|
39
|
+
{Icon ? (<Icon height={styles.icon.height} style={styles.icon} width={styles.icon.width}/>) : null}
|
|
40
|
+
</Pressable>);
|
|
41
|
+
});
|
|
42
|
+
const useStyles = makeStyles(({ theme, sizing }) => ({
|
|
43
|
+
container: {
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
width: theme.Form.Checkbox.checkboxWidth,
|
|
47
|
+
height: theme.Form.Checkbox.checkboxHeight,
|
|
48
|
+
},
|
|
49
|
+
background: { ...StyleSheet.absoluteFillObject },
|
|
50
|
+
icon: {
|
|
51
|
+
height: sizing.Height['h-1'],
|
|
52
|
+
width: sizing.Width['w-1'],
|
|
53
|
+
color: theme.Form.Checkbox.checkboxIconActiveColor,
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CheckboxProps } from '../Checkbox';
|
|
2
|
+
export declare const usePressableStyles: ({ checked, indeterminate, disabled, state, }: Pick<CheckboxProps, "checked" | "indeterminate" | "disabled" | "state">) => (pressed: boolean) => (false | {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
borderRadius: number;
|
|
6
|
+
borderWidth: number;
|
|
7
|
+
} | {
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
borderColor: string;
|
|
10
|
+
} | {
|
|
11
|
+
borderColor: string;
|
|
12
|
+
opacity: number;
|
|
13
|
+
outlineWidth: number;
|
|
14
|
+
mixBlendMode: "luminosity";
|
|
15
|
+
})[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { makeStyles } from '../../../utils/makeStyles';
|
|
3
|
+
export const usePressableStyles = ({ checked, indeterminate = false, disabled = false, state, }) => {
|
|
4
|
+
const styles = useStyles();
|
|
5
|
+
const styleMap = useMemo(() => ({
|
|
6
|
+
default: { filled: styles.defaultFilled, clean: styles.defaultClean },
|
|
7
|
+
disabled: { filled: styles.disabledFilled, clean: styles.disabledClean },
|
|
8
|
+
danger: {
|
|
9
|
+
filled: { ...styles.dangerFilled, ...styles.dangerOutline },
|
|
10
|
+
clean: { ...styles.dangerClean, ...styles.dangerOutline },
|
|
11
|
+
},
|
|
12
|
+
hover: { filled: styles.hoverFilled, clean: styles.hoverClean },
|
|
13
|
+
}), [
|
|
14
|
+
styles.defaultFilled,
|
|
15
|
+
styles.defaultClean,
|
|
16
|
+
styles.disabledFilled,
|
|
17
|
+
styles.disabledClean,
|
|
18
|
+
styles.dangerFilled,
|
|
19
|
+
styles.dangerClean,
|
|
20
|
+
styles.hoverFilled,
|
|
21
|
+
styles.hoverClean,
|
|
22
|
+
styles.dangerOutline,
|
|
23
|
+
]);
|
|
24
|
+
return useCallback((pressed) => {
|
|
25
|
+
const isFilled = checked || indeterminate;
|
|
26
|
+
const stateStyles = state in styleMap && isFilled
|
|
27
|
+
? styleMap[state].filled
|
|
28
|
+
: styleMap[state].clean;
|
|
29
|
+
const disabledStyles = isFilled
|
|
30
|
+
? styleMap.disabled.filled
|
|
31
|
+
: styleMap.disabled.clean;
|
|
32
|
+
const pressedStyles = isFilled
|
|
33
|
+
? styleMap.hover.filled
|
|
34
|
+
: styleMap.hover.clean;
|
|
35
|
+
return [
|
|
36
|
+
styles.container,
|
|
37
|
+
stateStyles,
|
|
38
|
+
disabled && disabledStyles,
|
|
39
|
+
pressed && pressedStyles,
|
|
40
|
+
];
|
|
41
|
+
}, [checked, indeterminate, disabled, state, styles.container, styleMap]);
|
|
42
|
+
};
|
|
43
|
+
const useStyles = makeStyles(({ theme, border }) => ({
|
|
44
|
+
container: {
|
|
45
|
+
width: theme.Form.Checkbox.checkboxWidth,
|
|
46
|
+
height: theme.Form.Checkbox.checkboxHeight,
|
|
47
|
+
borderRadius: border.Radius['rounded-lg'],
|
|
48
|
+
borderWidth: border.Width.border,
|
|
49
|
+
},
|
|
50
|
+
defaultClean: {
|
|
51
|
+
backgroundColor: theme.Form.InputText.inputBg,
|
|
52
|
+
borderColor: theme.Form.InputText.inputBorderColor,
|
|
53
|
+
},
|
|
54
|
+
defaultFilled: {
|
|
55
|
+
backgroundColor: theme.Form.Checkbox.checkboxActiveBg,
|
|
56
|
+
borderColor: theme.Form.Checkbox.checkboxActiveBorderColor,
|
|
57
|
+
},
|
|
58
|
+
hoverClean: {
|
|
59
|
+
backgroundColor: theme.Form.InputText.inputBg,
|
|
60
|
+
borderColor: theme.Form.InputText.inputHoverBorderColor,
|
|
61
|
+
},
|
|
62
|
+
hoverFilled: {
|
|
63
|
+
backgroundColor: theme.Form.Checkbox.checkboxActiveHoverBg,
|
|
64
|
+
borderColor: theme.Form.Checkbox.checkboxActiveHoverBorderColor,
|
|
65
|
+
},
|
|
66
|
+
dangerClean: {
|
|
67
|
+
backgroundColor: theme.Form.InputText.inputBg,
|
|
68
|
+
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
69
|
+
},
|
|
70
|
+
dangerFilled: {
|
|
71
|
+
backgroundColor: theme.Form.Checkbox.checkboxActiveBg,
|
|
72
|
+
borderColor: theme.Form.InputText.inputErrorBorderColor,
|
|
73
|
+
},
|
|
74
|
+
dangerOutline: {
|
|
75
|
+
outlineStyle: 'solid',
|
|
76
|
+
outlineColor: theme.General.focusOutlineErrorColor,
|
|
77
|
+
outlineWidth: Math.round(theme.General.focusShadowWidth),
|
|
78
|
+
},
|
|
79
|
+
disabledClean: {
|
|
80
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
81
|
+
borderColor: theme.Form.InputText.inputBorderColor,
|
|
82
|
+
outlineWidth: 0,
|
|
83
|
+
mixBlendMode: 'luminosity',
|
|
84
|
+
},
|
|
85
|
+
disabledFilled: {
|
|
86
|
+
borderColor: theme.Form.Checkbox.checkboxActiveBorderColor,
|
|
87
|
+
opacity: 0.2,
|
|
88
|
+
outlineWidth: 0,
|
|
89
|
+
mixBlendMode: 'luminosity',
|
|
90
|
+
},
|
|
91
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox, type CheckboxProps } from './Checkbox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from './Checkbox';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PressableProps } from 'react-native';
|
|
2
|
+
import { type SvgSource } from '../../utils/SvgUniversal';
|
|
3
|
+
export interface ChipProps extends PressableProps {
|
|
4
|
+
/** SVG-иконка */
|
|
5
|
+
Icon?: SvgSource;
|
|
6
|
+
/** Текст для отображения */
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* Показывать или скрыть кнопку для скрытия компонента
|
|
10
|
+
* @default true если onClose задан, иначе false
|
|
11
|
+
*/
|
|
12
|
+
showClose?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Показывать или скрыть иконку внутри компонента
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
showIcon?: boolean;
|
|
18
|
+
/** Обработчик нажатия на кнопку скрытия компонента */
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Компонет Нажимабельного тега с возможностью закрытия
|
|
23
|
+
* Используется для представления массива данных в виде меток
|
|
24
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5126&t=jMMaE0JO924pG1ga-4
|
|
25
|
+
*/
|
|
26
|
+
export declare const Chip: import("react").NamedExoticComponent<ChipProps>;
|
|
27
|
+
export declare enum TestId {
|
|
28
|
+
Container = "Chip_Container",
|
|
29
|
+
RemoveButton = "Chip_RemoveButton"
|
|
30
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { IconX } from '@tabler/icons-react-native';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Text, Pressable } from 'react-native';
|
|
4
|
+
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
5
|
+
import { makeStyles } from '../../utils/makeStyles';
|
|
6
|
+
/**
|
|
7
|
+
* Компонет Нажимабельного тега с возможностью закрытия
|
|
8
|
+
* Используется для представления массива данных в виде меток
|
|
9
|
+
* @see https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5126&t=jMMaE0JO924pG1ga-4
|
|
10
|
+
*/
|
|
11
|
+
export const Chip = memo(({ Icon, label, disabled, testID, onClose, showClose = !!onClose, showIcon = true, ...rest }) => {
|
|
12
|
+
const styles = useStyles();
|
|
13
|
+
return (<Pressable {...rest} disabled={disabled} style={[styles.chip, disabled && styles.disabledChip]} testID={testID || TestId.Container}>
|
|
14
|
+
{showIcon && Icon ? (<SvgUniversal color={disabled ? styles.disabledIcon.color : styles.icon.color} height={styles.icon.height} source={Icon} width={styles.icon.width}/>) : null}
|
|
15
|
+
|
|
16
|
+
<Text numberOfLines={1} style={[styles.text, disabled && styles.disabledText]}>
|
|
17
|
+
{label}
|
|
18
|
+
</Text>
|
|
19
|
+
|
|
20
|
+
{showClose ? (<Pressable disabled={disabled} testID={TestId.RemoveButton} onPress={onClose}>
|
|
21
|
+
{({ pressed }) => (<IconX color={disabled ? styles.disabledIcon.color : styles.icon.color} height={styles.icon.height} style={pressed ? styles.pressedClose : null} width={styles.icon.width}/>)}
|
|
22
|
+
</Pressable>) : null}
|
|
23
|
+
</Pressable>);
|
|
24
|
+
});
|
|
25
|
+
const useStyles = makeStyles(({ theme, typography, border, fonts }) => ({
|
|
26
|
+
chip: {
|
|
27
|
+
height: theme.Misc.Chip.chipHeight,
|
|
28
|
+
alignSelf: 'flex-start',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
gap: theme.General.inlineSpacing,
|
|
33
|
+
paddingHorizontal: theme.Misc.Chip.chipPaddingLeftRight,
|
|
34
|
+
paddingVertical: theme.Misc.Chip.chipPaddingTopBottom,
|
|
35
|
+
borderRadius: theme.Misc.Chip.chipBorderRadius,
|
|
36
|
+
borderWidth: border.Width.border,
|
|
37
|
+
backgroundColor: theme.Misc.Chip.chipBg,
|
|
38
|
+
borderColor: theme.Misc.Chip.chipBorderColor,
|
|
39
|
+
},
|
|
40
|
+
disabledChip: {
|
|
41
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
42
|
+
borderColor: theme.Button.Disabled.disabledButtonBorderColor,
|
|
43
|
+
opacity: 0.6,
|
|
44
|
+
mixBlendMode: 'luminosity',
|
|
45
|
+
},
|
|
46
|
+
icon: {
|
|
47
|
+
width: typography.Size['text-base'],
|
|
48
|
+
height: typography.Size['text-base'],
|
|
49
|
+
color: theme.Misc.Chip.chipTextColor,
|
|
50
|
+
},
|
|
51
|
+
disabledIcon: { color: theme.Button.Disabled.disabledButtonTextColor },
|
|
52
|
+
text: {
|
|
53
|
+
fontSize: typography.Size['text-base'],
|
|
54
|
+
verticalAlign: 'middle',
|
|
55
|
+
color: theme.Misc.Chip.chipTextColor,
|
|
56
|
+
includeFontPadding: false,
|
|
57
|
+
fontFamily: fonts.secondary,
|
|
58
|
+
},
|
|
59
|
+
disabledText: { color: theme.General.textSecondaryColor },
|
|
60
|
+
pressedClose: {
|
|
61
|
+
borderWidth: border.Width['border-3'],
|
|
62
|
+
borderColor: border.Color.Service['border-success'][400],
|
|
63
|
+
borderRadius: border.Radius['rounded-full'],
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
66
|
+
export var TestId;
|
|
67
|
+
(function (TestId) {
|
|
68
|
+
TestId["Container"] = "Chip_Container";
|
|
69
|
+
TestId["RemoveButton"] = "Chip_RemoveButton";
|
|
70
|
+
})(TestId || (TestId = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Chip, type ChipProps } from './Chip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Chip } from './Chip';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type DialogComponentProps } from './DialogComponent';
|
|
3
|
+
export interface DialogProps extends DialogComponentProps {
|
|
4
|
+
readonly isVisible: boolean;
|
|
5
|
+
readonly onClose?: () => void;
|
|
6
|
+
readonly onHideComplete?: () => void;
|
|
7
|
+
readonly testID?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const Dialog: React.FC<DialogProps>;
|
|
10
|
+
export declare const DialogTestId: {
|
|
11
|
+
root: string;
|
|
12
|
+
backdrop: string;
|
|
13
|
+
contentContainer: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Portal } from '@gorhom/portal';
|
|
2
|
+
import React, { useCallback, useEffect } from 'react';
|
|
3
|
+
import { View, StyleSheet, BackHandler, Pressable } from 'react-native';
|
|
4
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withSpring, runOnJS, interpolate, } from 'react-native-reanimated';
|
|
5
|
+
import { DialogComponent } from './DialogComponent';
|
|
6
|
+
const ANIMATION_DURATION = 200;
|
|
7
|
+
const BACKDROP_OPACITY = 0.5;
|
|
8
|
+
const SCALE_DAMPING = 5;
|
|
9
|
+
const SCALE_STIFFNESS = 50;
|
|
10
|
+
const SCALE_INIT_VALUE = 0.9;
|
|
11
|
+
// eslint-disable-next-line import-x/no-deprecated
|
|
12
|
+
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
13
|
+
export const Dialog = ({ isVisible, onClose, onHideComplete, header, footer, body, testID, }) => {
|
|
14
|
+
const opacity = useSharedValue(0);
|
|
15
|
+
const scale = useSharedValue(SCALE_INIT_VALUE);
|
|
16
|
+
const handleAnimationComplete = useCallback(() => {
|
|
17
|
+
if (onHideComplete) {
|
|
18
|
+
onHideComplete();
|
|
19
|
+
}
|
|
20
|
+
}, [onHideComplete]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isVisible) {
|
|
23
|
+
opacity.value = withTiming(1, { duration: ANIMATION_DURATION });
|
|
24
|
+
scale.value = withSpring(1, {
|
|
25
|
+
damping: SCALE_DAMPING,
|
|
26
|
+
stiffness: SCALE_STIFFNESS,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
opacity.value = withTiming(0, { duration: ANIMATION_DURATION });
|
|
31
|
+
scale.value = withTiming(SCALE_INIT_VALUE, { duration: ANIMATION_DURATION }, (finished) => {
|
|
32
|
+
if (finished) {
|
|
33
|
+
runOnJS(handleAnimationComplete)();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [isVisible, opacity, scale, handleAnimationComplete]);
|
|
38
|
+
const backdropAnimatedStyle = useAnimatedStyle(() => {
|
|
39
|
+
return {
|
|
40
|
+
opacity: interpolate(opacity.value, [0, 1], [0, BACKDROP_OPACITY]),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const dialogAnimatedStyle = useAnimatedStyle(() => {
|
|
44
|
+
return { opacity: opacity.value, transform: [{ scale: scale.value }] };
|
|
45
|
+
});
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
48
|
+
if (isVisible) {
|
|
49
|
+
onClose?.();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
54
|
+
return subscription.remove;
|
|
55
|
+
}, [isVisible, onClose]);
|
|
56
|
+
return (<Portal>
|
|
57
|
+
<View style={[
|
|
58
|
+
styles.container,
|
|
59
|
+
!isVisible && styles.containerNoPointerEvents,
|
|
60
|
+
]} testID={testID ?? DialogTestId.root}>
|
|
61
|
+
<AnimatedPressable style={[styles.backdrop, backdropAnimatedStyle]} testID={DialogTestId.backdrop} onPress={onClose}/>
|
|
62
|
+
<Animated.View style={dialogAnimatedStyle} testID={DialogTestId.contentContainer}>
|
|
63
|
+
<DialogComponent body={body} footer={footer} header={header}/>
|
|
64
|
+
</Animated.View>
|
|
65
|
+
</View>
|
|
66
|
+
</Portal>);
|
|
67
|
+
};
|
|
68
|
+
const styles = StyleSheet.create({
|
|
69
|
+
container: {
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
top: 0,
|
|
72
|
+
left: 0,
|
|
73
|
+
right: 0,
|
|
74
|
+
bottom: 0,
|
|
75
|
+
flex: 1,
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
zIndex: 9999,
|
|
79
|
+
elevation: 999,
|
|
80
|
+
pointerEvents: 'auto',
|
|
81
|
+
},
|
|
82
|
+
containerNoPointerEvents: { pointerEvents: 'none' },
|
|
83
|
+
backdrop: {
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
top: 0,
|
|
86
|
+
left: 0,
|
|
87
|
+
right: 0,
|
|
88
|
+
bottom: 0,
|
|
89
|
+
backgroundColor: 'black',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
export const DialogTestId = {
|
|
93
|
+
root: 'DialogModal',
|
|
94
|
+
backdrop: 'Backdrop',
|
|
95
|
+
contentContainer: 'ContentContainer',
|
|
96
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
export interface DialogComponentProps {
|
|
3
|
+
readonly body?: React.ComponentType;
|
|
4
|
+
readonly footer?: React.ComponentType;
|
|
5
|
+
readonly header?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const DialogComponent: React.FC<DialogComponentProps>;
|