@cdek-it/react-native-ui-kit 0.6.9 → 1.0.0-beta.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/README.md +9 -0
- package/dist/components/Accordion/Accordion.js +9 -10
- package/dist/components/Avatar/Avatar.js +7 -9
- package/dist/components/Badge/Badge.js +28 -20
- package/dist/components/Button/BaseButton.d.ts +3 -3
- package/dist/components/Button/BaseButton.js +12 -41
- package/dist/components/Button/Button.js +6 -4
- package/dist/components/Button/ButtonBadge.js +13 -12
- package/dist/components/Button/ButtonSeverity.js +6 -4
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/types.d.ts +2 -25
- package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -3
- package/dist/components/Button/utils/ButtonActivityIndicator.js +16 -12
- package/dist/components/Button/utils/ButtonContainer.d.ts +15 -6
- package/dist/components/Button/utils/ButtonContainer.js +424 -4
- package/dist/components/Button/utils/ButtonIcon.d.ts +8 -4
- package/dist/components/Button/utils/ButtonIcon.js +147 -4
- package/dist/components/Button/utils/ButtonLabel.d.ts +9 -4
- package/dist/components/Button/utils/ButtonLabel.js +139 -4
- package/dist/components/Button/utils/ButtonLeftArea.d.ts +9 -4
- package/dist/components/Button/utils/ButtonLeftArea.js +3 -3
- package/dist/components/Button/utils/ButtonPressedContext.d.ts +1 -0
- package/dist/components/Button/utils/ButtonPressedContext.js +2 -0
- package/dist/components/Button/utils/ButtonRightArea.d.ts +9 -3
- package/dist/components/Button/utils/ButtonRightArea.js +3 -3
- package/dist/components/Button/utils/ButtonVariantContext.d.ts +6 -0
- package/dist/components/Button/utils/ButtonVariantContext.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +6 -7
- package/dist/components/Checkbox/Checkbox.js +74 -22
- package/dist/components/Chip/Chip.js +13 -7
- package/dist/components/Dialog/DialogComponent.js +2 -3
- package/dist/components/Dialog/DialogHeader.js +17 -13
- package/dist/components/Divider/Divider.js +6 -6
- package/dist/components/Input/InputGroup.js +6 -13
- package/dist/components/Input/InputGroupAddon.js +5 -5
- package/dist/components/Input/InputOtp/InputOtp.js +2 -3
- package/dist/components/Input/InputOtp/InputOtpItem.js +2 -3
- package/dist/components/Input/InputSwitch/InputSwitch.js +2 -2
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +13 -11
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +6 -5
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +36 -29
- package/dist/components/Input/InputTextBase/InputTextBase.d.ts +0 -5
- package/dist/components/Input/InputTextBase/InputTextBase.js +41 -26
- package/dist/components/Input/InputTextBase/useInputStyles.d.ts +6 -5
- package/dist/components/Input/InputTextBase/useInputStyles.js +6 -9
- package/dist/components/Input/index.d.ts +0 -1
- package/dist/components/Input/index.js +0 -1
- package/dist/components/List/Base/ListBase.js +9 -12
- package/dist/components/MenuItem/MenuItemAccessory.js +5 -5
- package/dist/components/MenuItem/MenuItemIcon.js +4 -5
- package/dist/components/MenuItem/Template/MenuItemTemplate.js +8 -5
- package/dist/components/Message/Message.js +54 -38
- package/dist/components/ProgressBar/ProgressBar.js +2 -3
- package/dist/components/ProgressSpinner/ProgressSpinner.js +3 -4
- package/dist/components/RadioButton/RadioButton.js +87 -104
- package/dist/components/Rating/Rating.js +2 -3
- package/dist/components/Rating/RatingClear.js +10 -11
- package/dist/components/Rating/RatingItem.js +23 -24
- package/dist/components/Rating/RatingItemContainer.js +2 -3
- package/dist/components/SelectButton/SelectButton.js +2 -3
- package/dist/components/SelectButton/SelectButtonItem.js +22 -49
- package/dist/components/Skeleton/Skeleton.js +2 -3
- package/dist/components/Slider/Slider.js +4 -6
- package/dist/components/Tabs/TabItem/TabItem.js +12 -21
- package/dist/components/Tabs/Tabs.js +2 -3
- package/dist/components/Tag/Tag.js +44 -29
- package/dist/components/Timer/Timer.js +2 -3
- package/dist/components/Timer/TimerFlip.js +2 -3
- package/dist/components/ToggleButton/ToggleButton.js +159 -35
- package/dist/components/Typography/Anchor.js +11 -7
- package/dist/components/Typography/Body.js +2 -3
- package/dist/components/Typography/Caption.js +9 -4
- package/dist/components/Typography/Service.js +13 -7
- package/dist/components/Typography/Subtitle.js +3 -6
- package/dist/components/Typography/Title.js +3 -6
- package/dist/hooks/useChangeTheme.d.ts +2 -1
- package/dist/hooks/useChangeTheme.js +10 -3
- package/dist/hooks/useFonts.d.ts +2 -1
- package/dist/hooks/useFonts.js +3 -3
- package/dist/hooks/useTheme.d.ts +2 -1
- package/dist/hooks/useTheme.js +6 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/theme/ThemeContext.d.ts +9 -7
- package/dist/theme/ThemeContext.js +21 -14
- package/dist/theme/darkTheme.js +1 -0
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/lightTheme.js +1 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/utils/SvgUniversal.d.ts +9 -14
- package/dist/utils/SvgUniversal.js +10 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +18 -8
- package/dist/components/Button/styles/index.d.ts +0 -2
- package/dist/components/Button/styles/index.js +0 -2
- package/dist/components/Button/styles/useBasicButtonStyles.d.ts +0 -98
- package/dist/components/Button/styles/useBasicButtonStyles.js +0 -81
- package/dist/components/Button/styles/useDangerButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useDangerButtonStyles.js +0 -57
- package/dist/components/Button/styles/useInfoButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useInfoButtonStyles.js +0 -56
- package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +0 -64
- package/dist/components/Button/styles/useSeverityButtonStyles.js +0 -29
- package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useSuccessButtonStyles.js +0 -61
- package/dist/components/Button/styles/useWarningButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useWarningButtonStyles.js +0 -61
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +0 -3
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +0 -141
- package/dist/components/Button/utils/useButtonLabelStyle.d.ts +0 -3
- package/dist/components/Button/utils/useButtonLabelStyle.js +0 -40
- package/dist/components/Button/utils/useIconStyle.d.ts +0 -7
- package/dist/components/Button/utils/useIconStyle.js +0 -35
- package/dist/components/Button/utils/useTypeBasedStyle.d.ts +0 -2
- package/dist/components/Button/utils/useTypeBasedStyle.js +0 -4
- package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +0 -15
- package/dist/components/Checkbox/hooks/usePressableStyles.js +0 -91
- package/dist/components/Input/FloatLabel.d.ts +0 -22
- package/dist/components/Input/FloatLabel.js +0 -19
- package/dist/components/ToggleButton/hooks/useIconSize.d.ts +0 -14
- package/dist/components/ToggleButton/hooks/useIconSize.js +0 -26
- package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +0 -8
- package/dist/components/ToggleButton/hooks/useLabelSize.js +0 -19
- package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +0 -11
- package/dist/components/ToggleButton/hooks/useStateStyles.js +0 -92
- package/dist/utils/makeStyles.d.ts +0 -11
- package/dist/utils/makeStyles.js +0 -19
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Fragment, memo, useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { Pressable, Text, View, } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
4
|
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
4
|
-
import { makeStyles } from '../../utils/makeStyles';
|
|
5
5
|
const WORD_JOINER = '\u2060'; // символ невидимого пробела, чтобы избежать разрыва строки между текстом и иконкой
|
|
6
6
|
/**
|
|
7
7
|
* Используется для ссылок и якорей
|
|
8
8
|
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS--DS-?node-id=1-271
|
|
9
9
|
*/
|
|
10
10
|
export const Anchor = memo(({ onPress, base, visited, children, noWrapper, LeftIcon, RightIcon, testID, style, ...other }) => {
|
|
11
|
-
const styles = useStyles();
|
|
12
11
|
const [pressed, setPressed] = useState(false);
|
|
13
12
|
const onPressIn = useCallback(() => setPressed(true), []);
|
|
14
13
|
const onPressOut = useCallback(() => setPressed(false), []);
|
|
@@ -18,11 +17,16 @@ export const Anchor = memo(({ onPress, base, visited, children, noWrapper, LeftI
|
|
|
18
17
|
return {};
|
|
19
18
|
}
|
|
20
19
|
return { style: styles.container, testID: testID || AnchorTestId.root };
|
|
21
|
-
}, [noWrapper,
|
|
22
|
-
const
|
|
20
|
+
}, [noWrapper, testID]);
|
|
21
|
+
const iconSize = base ? styles.iconBase : styles.icon;
|
|
22
|
+
const iconUniProps = ({ typography: t }) => ({
|
|
23
|
+
color: visited
|
|
24
|
+
? t.Color.Service['text-help']
|
|
25
|
+
: t.Color.Service['text-info'],
|
|
26
|
+
});
|
|
23
27
|
return (<Wrapper {...containerProps}>
|
|
24
28
|
{LeftIcon ? (<Pressable style={styles.leftIconContainer} testID={AnchorTestId.leftPressable} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut}>
|
|
25
|
-
<SvgUniversal source={LeftIcon} testID={AnchorTestId.leftIcon}
|
|
29
|
+
<SvgUniversal {...iconSize} source={LeftIcon} testID={AnchorTestId.leftIcon} uniProps={iconUniProps}/>
|
|
26
30
|
</Pressable>) : null}
|
|
27
31
|
<Text suppressHighlighting style={[
|
|
28
32
|
styles.text,
|
|
@@ -37,11 +41,11 @@ export const Anchor = memo(({ onPress, base, visited, children, noWrapper, LeftI
|
|
|
37
41
|
</Text>
|
|
38
42
|
|
|
39
43
|
{RightIcon ? (<Pressable style={styles.rightIconContainer} testID={AnchorTestId.rightPressable} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut}>
|
|
40
|
-
<SvgUniversal
|
|
44
|
+
<SvgUniversal {...iconSize} source={RightIcon} testID={AnchorTestId.rightIcon} uniProps={iconUniProps}/>
|
|
41
45
|
</Pressable>) : null}
|
|
42
46
|
</Wrapper>);
|
|
43
47
|
});
|
|
44
|
-
const
|
|
48
|
+
const styles = StyleSheet.create(({ spacing, typography, fonts }) => ({
|
|
45
49
|
container: { flexDirection: 'row', alignItems: 'center' },
|
|
46
50
|
text: {
|
|
47
51
|
flexShrink: 1,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
3
|
export const Body = ({ base, color = 'default', disabled, paragraph, weight = 'regular', style, ...other }) => {
|
|
4
|
-
const styles = useStyles();
|
|
5
4
|
return (<Text style={[
|
|
6
5
|
styles.text,
|
|
7
6
|
styles[weight],
|
|
@@ -12,7 +11,7 @@ export const Body = ({ base, color = 'default', disabled, paragraph, weight = 'r
|
|
|
12
11
|
style,
|
|
13
12
|
]} testID='Body' {...other}/>);
|
|
14
13
|
};
|
|
15
|
-
const
|
|
14
|
+
const styles = StyleSheet.create(({ theme, typography, fonts }) => ({
|
|
16
15
|
text: {
|
|
17
16
|
fontSize: typography.Size['text-lg'],
|
|
18
17
|
includeFontPadding: false,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Text, View } from 'react-native';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
3
|
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
3
|
-
import { makeStyles } from '../../utils/makeStyles';
|
|
4
4
|
export const Caption = ({ color = 'default', disabled, style, Icon, ...other }) => {
|
|
5
|
-
const styles = useStyles();
|
|
6
5
|
const text = (<Text style={[
|
|
7
6
|
styles.text,
|
|
8
7
|
styles[color],
|
|
@@ -12,14 +11,20 @@ export const Caption = ({ color = 'default', disabled, style, Icon, ...other })
|
|
|
12
11
|
]} testID={CaptionTestId.text} {...other}/>);
|
|
13
12
|
if (Icon) {
|
|
14
13
|
return (<View style={styles.withIconContainer}>
|
|
15
|
-
<SvgUniversal source={Icon} testID={CaptionTestId.icon} {
|
|
14
|
+
<SvgUniversal {...styles.icon} source={Icon} testID={CaptionTestId.icon} uniProps={({ theme }) => ({
|
|
15
|
+
color: {
|
|
16
|
+
default: theme.General.textColor,
|
|
17
|
+
primary: theme.General.primaryColor,
|
|
18
|
+
secondary: theme.General.textSecondaryColor,
|
|
19
|
+
}[color],
|
|
20
|
+
})}/>
|
|
16
21
|
{text}
|
|
17
22
|
</View>);
|
|
18
23
|
}
|
|
19
24
|
return text;
|
|
20
25
|
};
|
|
21
26
|
const CaptionTestId = { text: 'CaptionText', icon: 'CaptionIcon' };
|
|
22
|
-
const
|
|
27
|
+
const styles = StyleSheet.create(({ theme, spacing, typography, fonts }) => ({
|
|
23
28
|
text: {
|
|
24
29
|
fontSize: typography.Size['text-sm'],
|
|
25
30
|
includeFontPadding: false,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { IconAlertTriangle, IconCircleCheck, IconCircleX, IconHelpCircle, IconInfoCircle, } from '@tabler/icons-react-native';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { Text, View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
5
|
import { SvgUniversal } from '../../utils/SvgUniversal';
|
|
5
|
-
import { makeStyles } from '../../utils/makeStyles';
|
|
6
6
|
/**
|
|
7
7
|
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=1-284&m=dev
|
|
8
8
|
*/
|
|
9
9
|
export const Service = ({ variant = 'success', showIcon = true, base = true, Icon: IconFromProps, ...other }) => {
|
|
10
|
-
const
|
|
11
|
-
const { Icon, variantStyle, iconSize, textStyles, containerStyle } = useMemo(() => {
|
|
10
|
+
const { Icon, iconSize, textStyles, containerStyle } = useMemo(() => {
|
|
12
11
|
const iconMap = {
|
|
13
12
|
danger: { Icon: IconCircleX, style: styles.danger },
|
|
14
13
|
warning: { Icon: IconAlertTriangle, style: styles.warning },
|
|
@@ -18,7 +17,6 @@ export const Service = ({ variant = 'success', showIcon = true, base = true, Ico
|
|
|
18
17
|
};
|
|
19
18
|
return {
|
|
20
19
|
Icon: IconFromProps || iconMap[variant]?.Icon || IconInfoCircle,
|
|
21
|
-
variantStyle: iconMap[variant]?.style || styles.info,
|
|
22
20
|
iconSize: base ? styles.iconBase : styles.icon,
|
|
23
21
|
textStyles: [
|
|
24
22
|
styles.textCommon,
|
|
@@ -27,13 +25,21 @@ export const Service = ({ variant = 'success', showIcon = true, base = true, Ico
|
|
|
27
25
|
],
|
|
28
26
|
containerStyle: base ? styles.containerBase : styles.container,
|
|
29
27
|
};
|
|
30
|
-
}, [variant, base,
|
|
28
|
+
}, [variant, base, IconFromProps]);
|
|
31
29
|
return (<View style={containerStyle}>
|
|
32
|
-
{showIcon ? (<SvgUniversal
|
|
30
|
+
{showIcon ? (<SvgUniversal {...iconSize} source={Icon} uniProps={({ typography: t }) => ({
|
|
31
|
+
color: {
|
|
32
|
+
danger: t.Color.Service['text-danger'],
|
|
33
|
+
warning: t.Color.Service['text-warning'],
|
|
34
|
+
success: t.Color.Service['text-success'],
|
|
35
|
+
info: t.Color.Service['text-info'],
|
|
36
|
+
help: t.Color.Service['text-help'],
|
|
37
|
+
}[variant],
|
|
38
|
+
})}/>) : null}
|
|
33
39
|
<Text style={textStyles} {...other}/>
|
|
34
40
|
</View>);
|
|
35
41
|
};
|
|
36
|
-
const
|
|
42
|
+
const styles = StyleSheet.create(({ typography, spacing, fonts }) => ({
|
|
37
43
|
iconBase: {
|
|
38
44
|
width: typography.Size['text-xl'],
|
|
39
45
|
height: typography.Size['text-xl'],
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
/**
|
|
5
5
|
* Используется для подзаголовков
|
|
6
6
|
* @see https://www.figma.com/design/2ZnL6XPKEpxAHvrlbRvnMu/Template-Tailwind-CSS-(DS)?node-id=1-245
|
|
7
7
|
*/
|
|
8
|
-
export const Subtitle = memo(({ base = false, color = 'default', style, ...other }) => {
|
|
9
|
-
|
|
10
|
-
return (<Text style={[styles.text, styles[color], base && styles.base, style]} testID='Subtitle' {...other}/>);
|
|
11
|
-
});
|
|
12
|
-
const useStyles = makeStyles(({ theme, typography, fonts }) => ({
|
|
8
|
+
export const Subtitle = memo(({ base = false, color = 'default', style, ...other }) => (<Text style={[styles.text, styles[color], base && styles.base, style]} testID='Subtitle' {...other}/>));
|
|
9
|
+
const styles = StyleSheet.create(({ theme, typography, fonts }) => ({
|
|
13
10
|
text: {
|
|
14
11
|
fontSize: typography.Size['text-sm'],
|
|
15
12
|
fontWeight: 700,
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
export const Title = ({ level, style, ...other }) => {
|
|
4
|
-
|
|
5
|
-
return (<Text style={[styles.text, styles[level], style]} testID='Title' {...other}/>);
|
|
6
|
-
};
|
|
7
|
-
const useStyles = makeStyles(({ theme, typography, fonts }) => ({
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
+
export const Title = ({ level, style, ...other }) => (<Text style={[styles.text, styles[level], style]} testID='Title' {...other}/>);
|
|
4
|
+
const styles = StyleSheet.create(({ theme, typography, fonts }) => ({
|
|
8
5
|
text: {
|
|
9
6
|
color: theme.General.textColor,
|
|
10
7
|
fontFamily: fonts.primary,
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ThemeVariant } from '../theme';
|
|
2
|
+
export declare const useChangeTheme: () => (theme: ThemeVariant) => void;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { UnistylesRuntime } from 'react-native-unistyles';
|
|
3
|
+
import { ThemeVariant } from '../theme';
|
|
4
|
+
const THEME_MAP = {
|
|
5
|
+
[ThemeVariant.Light]: 'light',
|
|
6
|
+
[ThemeVariant.Dark]: 'dark',
|
|
7
|
+
};
|
|
3
8
|
export const useChangeTheme = () => {
|
|
4
|
-
return
|
|
9
|
+
return useCallback((theme) => {
|
|
10
|
+
UnistylesRuntime.setTheme(THEME_MAP[theme]);
|
|
11
|
+
}, []);
|
|
5
12
|
};
|
package/dist/hooks/useFonts.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FontsConfig } from '../theme';
|
|
2
|
+
export declare const useFonts: () => FontsConfig;
|
package/dist/hooks/useFonts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ThemeContext } from '../theme';
|
|
1
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
3
2
|
export const useFonts = () => {
|
|
4
|
-
|
|
3
|
+
const { theme } = useUnistyles();
|
|
4
|
+
return theme.fonts;
|
|
5
5
|
};
|
package/dist/hooks/useTheme.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ThemeVariant } from '../theme';
|
|
2
|
+
export declare const useTheme: () => ThemeVariant;
|
package/dist/hooks/useTheme.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { UnistylesRuntime } from 'react-native-unistyles';
|
|
2
|
+
import { ThemeVariant } from '../theme';
|
|
3
|
+
const THEME_VARIANT_MAP = {
|
|
4
|
+
light: ThemeVariant.Light,
|
|
5
|
+
dark: ThemeVariant.Dark,
|
|
5
6
|
};
|
|
7
|
+
export const useTheme = () => THEME_VARIANT_MAP[UnistylesRuntime.themeName ?? 'light'];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import './theme';
|
|
1
2
|
export * from './components';
|
|
2
3
|
export { useChangeTheme } from './hooks/useChangeTheme';
|
|
3
|
-
export { ThemeContext, ThemeContextProvider, ThemeVariant, darkTheme, lightTheme, } from './theme';
|
|
4
|
-
export {
|
|
4
|
+
export { ThemeContext, ThemeContextProvider, ThemeVariant, darkTheme, lightTheme, type ThemeType, type FontsConfig, type FontsConfigType, type ThemeContextProviderProps, } from './theme';
|
|
5
|
+
export { useFonts } from './hooks/useFonts';
|
|
5
6
|
export { useTheme } from './hooks/useTheme';
|
|
6
7
|
export { SvgUniversal, type SvgSource } from './utils/SvgUniversal';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import './theme';
|
|
1
2
|
export * from './components';
|
|
2
3
|
export { useChangeTheme } from './hooks/useChangeTheme';
|
|
3
4
|
export { ThemeContext, ThemeContextProvider, ThemeVariant, darkTheme, lightTheme, } from './theme';
|
|
4
|
-
export {
|
|
5
|
+
export { useFonts } from './hooks/useFonts';
|
|
5
6
|
export { useTheme } from './hooks/useTheme';
|
|
6
7
|
export { SvgUniversal } from './utils/SvgUniversal';
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { darkTheme } from './darkTheme';
|
|
3
|
+
import { lightTheme } from './lightTheme';
|
|
4
|
+
import { type FontsConfig, ThemeVariant } from './types';
|
|
5
|
+
declare module 'react-native-unistyles' {
|
|
6
|
+
interface UnistylesThemes {
|
|
7
|
+
light: typeof lightTheme;
|
|
8
|
+
dark: typeof darkTheme;
|
|
9
|
+
}
|
|
7
10
|
}
|
|
8
11
|
export interface ThemeContextProviderProps {
|
|
9
12
|
readonly initialTheme?: ThemeVariant;
|
|
10
13
|
readonly fonts?: FontsConfig;
|
|
11
14
|
readonly children: ReactNode;
|
|
12
15
|
}
|
|
13
|
-
export declare const ThemeContext: import("react").Context<
|
|
16
|
+
export declare const ThemeContext: import("react").Context<null>;
|
|
14
17
|
export declare const ThemeContextProvider: ({ children, initialTheme, fonts, }: ThemeContextProviderProps) => import("react").JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { createContext,
|
|
1
|
+
import { createContext, useLayoutEffect } from 'react';
|
|
2
|
+
import { StyleSheet, UnistylesRuntime } from 'react-native-unistyles';
|
|
2
3
|
import { SkeletonContextProvider } from '../utils/SkeletonContext';
|
|
4
|
+
import { darkTheme } from './darkTheme';
|
|
5
|
+
import { lightTheme } from './lightTheme';
|
|
3
6
|
import { ThemeVariant } from './types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
StyleSheet.configure({
|
|
8
|
+
settings: { initialTheme: 'light' },
|
|
9
|
+
themes: { light: lightTheme, dark: darkTheme },
|
|
10
|
+
});
|
|
11
|
+
const THEME_NAME_MAP = {
|
|
12
|
+
[ThemeVariant.Light]: 'light',
|
|
13
|
+
[ThemeVariant.Dark]: 'dark',
|
|
10
14
|
};
|
|
11
|
-
export const ThemeContext = createContext(
|
|
12
|
-
export const ThemeContextProvider = ({ children, initialTheme =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
export const ThemeContext = createContext(null);
|
|
16
|
+
export const ThemeContextProvider = ({ children, initialTheme = ThemeVariant.Light, fonts, }) => {
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
UnistylesRuntime.setTheme(THEME_NAME_MAP[initialTheme]);
|
|
19
|
+
if (fonts) {
|
|
20
|
+
UnistylesRuntime.updateTheme('light', (t) => ({ ...t, fonts }));
|
|
21
|
+
UnistylesRuntime.updateTheme('dark', (t) => ({ ...t, fonts }));
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- initial* props применяем только на mount
|
|
16
24
|
}, []);
|
|
17
|
-
|
|
18
|
-
return (<ThemeContext.Provider value={contextValue}>
|
|
25
|
+
return (<ThemeContext.Provider value={null}>
|
|
19
26
|
<SkeletonContextProvider>{children}</SkeletonContextProvider>
|
|
20
27
|
</ThemeContext.Provider>);
|
|
21
28
|
};
|
package/dist/theme/darkTheme.js
CHANGED
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { darkTheme } from './darkTheme';
|
|
2
2
|
export { lightTheme } from './lightTheme';
|
|
3
|
-
export { ThemeContextProvider,
|
|
3
|
+
export { ThemeContext, ThemeContextProvider, type ThemeContextProviderProps, } from './ThemeContext';
|
|
4
4
|
export { type ThemeType, ThemeVariant, type FontsConfigType, type FontsConfig, } from './types';
|
package/dist/theme/index.js
CHANGED
package/dist/theme/lightTheme.js
CHANGED
package/dist/theme/types.d.ts
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import { type ComponentType } from 'react';
|
|
1
|
+
import { type ComponentType, type ForwardRefExoticComponent, type PropsWithoutRef, type RefAttributes } from 'react';
|
|
2
2
|
import { type SvgProps } from 'react-native-svg';
|
|
3
|
+
import type { ThemeType } from '../theme/types';
|
|
3
4
|
export type SvgSource = {
|
|
4
5
|
uri: string;
|
|
5
6
|
} | {
|
|
6
7
|
xml: string;
|
|
7
8
|
} | ComponentType<SvgProps>;
|
|
8
|
-
interface SvgUniversalProps extends SvgProps {
|
|
9
|
+
export interface SvgUniversalProps extends SvgProps {
|
|
9
10
|
/** Источник SVG */
|
|
10
11
|
source: SvgSource;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @example
|
|
19
|
-
* <SvgUniversal source={{ uri: 'https://example.com/icon.svg' }} />
|
|
20
|
-
* <SvgUniversal source={{ xml: '<svg><path d="M1 1h1v1H1z" /></svg>' }} />
|
|
21
|
-
* <SvgUniversal source={IconUser} />
|
|
22
|
-
*/
|
|
23
|
-
export declare const SvgUniversal: import("react").NamedExoticComponent<SvgUniversalProps>;
|
|
13
|
+
type SvgUniversalComponent = ForwardRefExoticComponent<PropsWithoutRef<Partial<SvgUniversalProps> & {
|
|
14
|
+
uniProps?: (theme: ThemeType) => Omit<Partial<SvgUniversalProps>, 'style' | 'contentContainerStyle'> & {
|
|
15
|
+
key?: string;
|
|
16
|
+
};
|
|
17
|
+
}> & RefAttributes<unknown>>;
|
|
18
|
+
export declare const SvgUniversal: SvgUniversalComponent;
|
|
24
19
|
export declare const SvgUniversalTestId: {
|
|
25
20
|
component: string;
|
|
26
21
|
uri: string;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
1
|
+
import { memo, } from 'react';
|
|
2
2
|
import { SvgUri, SvgXml } from 'react-native-svg';
|
|
3
|
+
import { withUnistyles } from 'react-native-unistyles';
|
|
3
4
|
/**
|
|
4
5
|
* Компонент для рендера SVG из разных источников
|
|
5
6
|
* Поддерживает:
|
|
6
7
|
* - uri
|
|
7
8
|
* - xml
|
|
8
9
|
* - ComponentType<SvgProps>
|
|
10
|
+
*
|
|
11
|
+
* Подписан на обновления темы Unistyles через uniProps
|
|
9
12
|
* @example
|
|
10
13
|
* <SvgUniversal source={{ uri: 'https://example.com/icon.svg' }} />
|
|
11
14
|
* <SvgUniversal source={{ xml: '<svg><path d="M1 1h1v1H1z" /></svg>' }} />
|
|
12
15
|
* <SvgUniversal source={IconUser} />
|
|
16
|
+
* <SvgUniversal
|
|
17
|
+
* source={IconUser}
|
|
18
|
+
* uniProps={(theme) => ({ color: theme.colors.primary })}
|
|
19
|
+
* />
|
|
13
20
|
*/
|
|
14
|
-
|
|
21
|
+
const SvgUniversalRaw = memo(({ source, ...rest }) => {
|
|
15
22
|
if ('uri' in source) {
|
|
16
23
|
return <SvgUri testID={SvgUniversalTestId.uri} uri={source.uri} {...rest}/>;
|
|
17
24
|
}
|
|
@@ -21,6 +28,7 @@ export const SvgUniversal = memo(({ source, ...rest }) => {
|
|
|
21
28
|
const Component = source;
|
|
22
29
|
return <Component testID={SvgUniversalTestId.component} {...rest}/>;
|
|
23
30
|
});
|
|
31
|
+
export const SvgUniversal = withUnistyles(SvgUniversalRaw);
|
|
24
32
|
export const SvgUniversalTestId = {
|
|
25
33
|
component: 'SvgUniversalComponent',
|
|
26
34
|
uri: 'SvgUniversalUri',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SvgUniversal, SvgUniversalTestId, type SvgSource, } from './SvgUniversal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SvgUniversal, SvgUniversalTestId, } from './SvgUniversal';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdek-it/react-native-ui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"description": "UI kit на основе Prime Faces, Prime Flex для React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://developer.cdek.ru/design-system",
|
|
@@ -24,17 +24,23 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
27
33
|
"scripts": {
|
|
28
34
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
29
35
|
"test": "jest",
|
|
30
|
-
"start": "expo start --dev-client",
|
|
36
|
+
"start": "expo start --dev-client --clear",
|
|
31
37
|
"android": "expo run:android",
|
|
32
38
|
"ios": "expo run:ios --no-install",
|
|
33
39
|
"storybook-generate": "sb-rn-get-stories --config-path .storybook && sed -i -e 's/export const view = global.view/export const view: ReturnType<typeof start> = global.view/' .storybook/storybook.requires.ts && prettier .storybook --write",
|
|
34
40
|
"doctor": "expo-doctor",
|
|
35
41
|
"check": "expo install --check",
|
|
36
|
-
"lint:check": "eslint .",
|
|
37
|
-
"lint:fix": "eslint --fix .",
|
|
42
|
+
"lint:check": "eslint --cache .",
|
|
43
|
+
"lint:fix": "eslint --fix --cache .",
|
|
38
44
|
"prettier:check": "prettier . --check",
|
|
39
45
|
"prettier:fix": "prettier . --write",
|
|
40
46
|
"prettier:watch": "onchange . -- prettier --write --ignore-unknown \"{{changed}}\"",
|
|
@@ -106,10 +112,12 @@
|
|
|
106
112
|
"react-native": "0.81.5",
|
|
107
113
|
"react-native-advanced-input-mask": "1.4.6",
|
|
108
114
|
"react-native-gesture-handler": "2.29.1",
|
|
109
|
-
"react-native-
|
|
115
|
+
"react-native-nitro-modules": "0.35.2",
|
|
116
|
+
"react-native-reanimated": "4.2.1",
|
|
110
117
|
"react-native-safe-area-context": "5.6.2",
|
|
111
118
|
"react-native-svg": "15.15.1",
|
|
112
|
-
"react-native-
|
|
119
|
+
"react-native-unistyles": "3.2.3",
|
|
120
|
+
"react-native-worklets": "0.7.1",
|
|
113
121
|
"release-it": "19.1.0",
|
|
114
122
|
"standard-version": "9.5.0",
|
|
115
123
|
"storybook": "10.1.10",
|
|
@@ -123,8 +131,10 @@
|
|
|
123
131
|
"expo": ">=54.x.x",
|
|
124
132
|
"react": ">=19.1",
|
|
125
133
|
"react-native": ">=0.81.5",
|
|
126
|
-
"react-native-reanimated": ">=4.
|
|
127
|
-
"react-native-svg": ">=15.15.1"
|
|
134
|
+
"react-native-reanimated": ">=4.2.1",
|
|
135
|
+
"react-native-svg": ">=15.15.1",
|
|
136
|
+
"react-native-unistyles": ">=3.2.3",
|
|
137
|
+
"react-native-worklets": ">=0.7.0"
|
|
128
138
|
},
|
|
129
139
|
"peerDependenciesMeta": {
|
|
130
140
|
"expo": {
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
export declare const useBasicButtonStyles: () => {
|
|
2
|
-
containerVariantStyles: {
|
|
3
|
-
primary: {
|
|
4
|
-
borderColor: string;
|
|
5
|
-
backgroundColor: string;
|
|
6
|
-
};
|
|
7
|
-
secondary: {
|
|
8
|
-
borderColor: string;
|
|
9
|
-
backgroundColor: string;
|
|
10
|
-
};
|
|
11
|
-
tertiary: {
|
|
12
|
-
borderColor: string;
|
|
13
|
-
backgroundColor: string;
|
|
14
|
-
};
|
|
15
|
-
text: {
|
|
16
|
-
borderColor: string;
|
|
17
|
-
backgroundColor: string;
|
|
18
|
-
};
|
|
19
|
-
link: {
|
|
20
|
-
paddingHorizontal: number;
|
|
21
|
-
paddingVertical: number;
|
|
22
|
-
height: "auto";
|
|
23
|
-
minHeight: "auto";
|
|
24
|
-
borderColor: string;
|
|
25
|
-
backgroundColor: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
labelVariantStyles: {
|
|
29
|
-
primary: {
|
|
30
|
-
color: string;
|
|
31
|
-
};
|
|
32
|
-
secondary: {
|
|
33
|
-
color: string;
|
|
34
|
-
};
|
|
35
|
-
tertiary: {
|
|
36
|
-
color: string;
|
|
37
|
-
};
|
|
38
|
-
text: {
|
|
39
|
-
color: string;
|
|
40
|
-
};
|
|
41
|
-
link: {
|
|
42
|
-
color: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
pressedVariantStyles: {
|
|
46
|
-
primary: {
|
|
47
|
-
borderColor: string;
|
|
48
|
-
backgroundColor: string;
|
|
49
|
-
};
|
|
50
|
-
secondary: {
|
|
51
|
-
borderColor: string;
|
|
52
|
-
backgroundColor: string;
|
|
53
|
-
};
|
|
54
|
-
tertiary: {
|
|
55
|
-
borderColor: string;
|
|
56
|
-
backgroundColor: string;
|
|
57
|
-
};
|
|
58
|
-
text: {
|
|
59
|
-
borderColor: string;
|
|
60
|
-
backgroundColor: string;
|
|
61
|
-
};
|
|
62
|
-
link: {};
|
|
63
|
-
};
|
|
64
|
-
iconVariantStyles: {
|
|
65
|
-
primary: {
|
|
66
|
-
color: string;
|
|
67
|
-
};
|
|
68
|
-
secondary: {
|
|
69
|
-
color: string;
|
|
70
|
-
};
|
|
71
|
-
tertiary: {
|
|
72
|
-
color: string;
|
|
73
|
-
};
|
|
74
|
-
text: {
|
|
75
|
-
color: string;
|
|
76
|
-
};
|
|
77
|
-
link: {
|
|
78
|
-
color: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
pressedLabelVariantStyles: {
|
|
82
|
-
primary: {
|
|
83
|
-
color: string;
|
|
84
|
-
};
|
|
85
|
-
secondary: {
|
|
86
|
-
color: string;
|
|
87
|
-
};
|
|
88
|
-
tertiary: {
|
|
89
|
-
color: string;
|
|
90
|
-
};
|
|
91
|
-
text: {
|
|
92
|
-
color: string;
|
|
93
|
-
};
|
|
94
|
-
link: {
|
|
95
|
-
color: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|