@cdek-it/react-native-ui-kit 0.4.1 → 0.5.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/dist/components/Input/InputTextBase/InputTextBase.js +5 -4
- package/dist/components/Input/InputTextBase/types.d.ts +8 -1
- package/dist/components/Input/InputTextBase/{useStyles.d.ts → useInputStyles.d.ts} +3 -1
- package/dist/components/Input/InputTextBase/{useStyles.js → useInputStyles.js} +19 -2
- package/dist/theme/assets/InputSize/base.json +3 -0
- package/dist/theme/assets/InputSize/index.d.ts +11 -0
- package/dist/theme/assets/InputSize/index.js +4 -0
- package/dist/theme/assets/InputSize/large.json +3 -0
- package/dist/theme/assets/InputSize/xlarge.json +3 -0
- package/dist/theme/assets/ModalSize/index.d.ts +18 -0
- package/dist/theme/assets/ModalSize/index.js +5 -0
- package/dist/theme/assets/ModalSize/lg.json +4 -0
- package/dist/theme/assets/ModalSize/md.json +4 -0
- package/dist/theme/assets/ModalSize/sm.json +4 -0
- package/dist/theme/assets/ModalSize/xl.json +4 -0
- package/dist/theme/darkTheme.js +3 -1
- package/dist/theme/lightTheme.js +3 -1
- package/dist/theme/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, }
|
|
|
6
6
|
import { useLoadingRotationAnimation } from '../../../hooks/useLoadingRotationAnimation';
|
|
7
7
|
import { useMakeTestId } from '../../../hooks/useMakeTestId';
|
|
8
8
|
import { InputTextBaseTestId } from './testIds';
|
|
9
|
-
import {
|
|
9
|
+
import { useInputStyle } from './useInputStyles';
|
|
10
10
|
/**
|
|
11
11
|
* Базовое поле
|
|
12
12
|
* @link https://www.figma.com/design/4TYeki0MDLhfPGJstbIicf/UI-kit-PrimeFace-(DS)?node-id=484-5470&m=dev
|
|
@@ -14,11 +14,11 @@ import { useStyles } from './useStyles';
|
|
|
14
14
|
*/
|
|
15
15
|
export const InputTextBase = memo(
|
|
16
16
|
// eslint-disable-next-line max-lines-per-function
|
|
17
|
-
({ state, clearable = true, secureTextEntry: secureTextEntryProp = false, inputRef: propsInputRef, disabled, containerStyle, loading, renderTextInput, clearButtonAccessibilityLabel, floatLabel = false, placeholder, ...otherProps
|
|
17
|
+
({ state, clearable = true, secureTextEntry: secureTextEntryProp = false, inputRef: propsInputRef, disabled, containerStyle, loading, renderTextInput, clearButtonAccessibilityLabel, floatLabel = false, placeholder, editable = true, size, ...otherProps
|
|
18
18
|
// TODO: разделить float label и обычный инпут -> добавить во float label поддержку font scale
|
|
19
19
|
// eslint-disable-next-line complexity
|
|
20
20
|
}) => {
|
|
21
|
-
const styles =
|
|
21
|
+
const styles = useInputStyle(size);
|
|
22
22
|
const inputRef = useRef(null);
|
|
23
23
|
const [valueState, setValueState] = useState('');
|
|
24
24
|
const [isFocused, setIsFocused] = useState(otherProps.autoFocus || false);
|
|
@@ -80,7 +80,7 @@ export const InputTextBase = memo(
|
|
|
80
80
|
allowFontScaling: floatLabel ? false : otherProps.allowFontScaling,
|
|
81
81
|
placeholder: '',
|
|
82
82
|
testID: makeTestId(),
|
|
83
|
-
editable:
|
|
83
|
+
editable: disabled ? false : editable,
|
|
84
84
|
secureTextEntry,
|
|
85
85
|
style: [
|
|
86
86
|
styles.inputFont,
|
|
@@ -97,6 +97,7 @@ export const InputTextBase = memo(
|
|
|
97
97
|
floatLabel,
|
|
98
98
|
makeTestId,
|
|
99
99
|
disabled,
|
|
100
|
+
editable,
|
|
100
101
|
secureTextEntry,
|
|
101
102
|
styles.inputFont,
|
|
102
103
|
styles.floatLabelInput,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Ref, ReactNode } from 'react';
|
|
2
2
|
import type { TextInputProps, ViewStyle, TextInput } from 'react-native';
|
|
3
3
|
/** @see TextInputProps */
|
|
4
|
-
export interface InputTextBaseProps extends Omit<TextInputProps, 'style' | '
|
|
4
|
+
export interface InputTextBaseProps extends Omit<TextInputProps, 'style' | 'secureTextEntry'> {
|
|
5
5
|
/**
|
|
6
6
|
* Управление отображения иконки очистки поля
|
|
7
7
|
* @default true
|
|
@@ -35,6 +35,13 @@ export interface InputTextBaseProps extends Omit<TextInputProps, 'style' | 'edit
|
|
|
35
35
|
* @default false
|
|
36
36
|
*/
|
|
37
37
|
floatLabel?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Управление высотой поля ввода.
|
|
40
|
+
* Работает только если floatLabel = false.
|
|
41
|
+
* Можно передать число. Если переданное число меньше размера base, будет использован размер base.
|
|
42
|
+
* @default 'base'
|
|
43
|
+
*/
|
|
44
|
+
size?: 'base' | 'large' | 'xlarge' | number;
|
|
38
45
|
}
|
|
39
46
|
export type RenderTextInputArgs = TextInputProps & {
|
|
40
47
|
inputRef: Ref<TextInput>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { InputTextBaseProps } from './types';
|
|
2
|
+
export declare const useInputStyle: (size?: InputTextBaseProps["size"]) => {
|
|
2
3
|
container: {
|
|
3
4
|
minHeight: number;
|
|
4
5
|
flexDirection: "row";
|
|
@@ -70,6 +71,7 @@ export declare const useStyles: () => {
|
|
|
70
71
|
paddingHorizontal: number;
|
|
71
72
|
gap: number;
|
|
72
73
|
overflow: "hidden";
|
|
74
|
+
alignItems: "center";
|
|
73
75
|
};
|
|
74
76
|
rightButtonContainer: {
|
|
75
77
|
justifyContent: "center";
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
1
2
|
import { makeStyles } from '../../../utils/makeStyles';
|
|
2
|
-
export const
|
|
3
|
+
export const useInputStyle = (size = 'base') => {
|
|
4
|
+
const styles = useStyles();
|
|
5
|
+
const containerMinHeight = useContainerMinHeight();
|
|
6
|
+
const minHeight = useMemo(() => {
|
|
7
|
+
if (typeof size === 'number') {
|
|
8
|
+
return Math.max(size, containerMinHeight.base.minHeight);
|
|
9
|
+
}
|
|
10
|
+
return containerMinHeight[size].minHeight;
|
|
11
|
+
}, [size, containerMinHeight]);
|
|
12
|
+
return { ...styles, container: { ...styles.container, minHeight } };
|
|
13
|
+
};
|
|
14
|
+
const useContainerMinHeight = makeStyles(({ theme }) => ({
|
|
15
|
+
base: { minHeight: theme.InputSize.base['min-height'] },
|
|
16
|
+
large: { minHeight: theme.InputSize.large['min-height'] },
|
|
17
|
+
xlarge: { minHeight: theme.InputSize.xlarge['min-height'] },
|
|
18
|
+
}));
|
|
19
|
+
const useStyles = makeStyles(({ theme, border, typography, spacing, fonts }) => ({
|
|
3
20
|
container: {
|
|
4
|
-
minHeight: theme.Button.Common.buttonHeight,
|
|
5
21
|
flexDirection: 'row',
|
|
6
22
|
borderWidth: border.Width.border,
|
|
7
23
|
borderRadius: border.Radius['rounded-xl'],
|
|
@@ -65,6 +81,7 @@ export const useStyles = makeStyles(({ theme, border, typography, spacing, fonts
|
|
|
65
81
|
paddingHorizontal: theme.Form.InputText.inputPaddingLeftRight,
|
|
66
82
|
gap: theme.Form.InputText.inputPaddingLeftRight,
|
|
67
83
|
overflow: 'hidden',
|
|
84
|
+
alignItems: 'center',
|
|
68
85
|
},
|
|
69
86
|
rightButtonContainer: { justifyContent: 'center' },
|
|
70
87
|
rightIcon: { color: theme.Form.InputText.inputIconColor },
|
package/dist/theme/darkTheme.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { InputSize } from './assets/InputSize';
|
|
2
|
+
import { ModalSize } from './assets/ModalSize';
|
|
1
3
|
import { customDark } from './assets/customDark';
|
|
2
4
|
import darkThemeAssets from './assets/themeDark.json';
|
|
3
5
|
import { commonTheme } from './commonTheme';
|
|
4
6
|
export const darkTheme = {
|
|
5
|
-
theme: { ...darkThemeAssets, custom: customDark },
|
|
7
|
+
theme: { ...darkThemeAssets, InputSize, ModalSize, custom: customDark },
|
|
6
8
|
...commonTheme,
|
|
7
9
|
};
|
package/dist/theme/lightTheme.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { InputSize } from './assets/InputSize';
|
|
2
|
+
import { ModalSize } from './assets/ModalSize';
|
|
1
3
|
import { customLight } from './assets/customLight';
|
|
2
4
|
import lightThemeAssets from './assets/themeLight.json';
|
|
3
5
|
import { commonTheme } from './commonTheme';
|
|
4
6
|
export const lightTheme = {
|
|
5
|
-
theme: { ...lightThemeAssets, custom: customLight },
|
|
7
|
+
theme: { ...lightThemeAssets, InputSize, ModalSize, custom: customLight },
|
|
6
8
|
...commonTheme,
|
|
7
9
|
};
|
package/dist/theme/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { InputSize } from './assets/InputSize';
|
|
2
|
+
import type { ModalSize } from './assets/ModalSize';
|
|
1
3
|
import type background from './assets/background.json';
|
|
2
4
|
import type border from './assets/border.json';
|
|
3
5
|
import type { customCommon } from './assets/customCommon';
|
|
@@ -22,6 +24,8 @@ export interface ThemeType {
|
|
|
22
24
|
spacing: typeof spacing;
|
|
23
25
|
theme: typeof lightTheme & {
|
|
24
26
|
custom: typeof customLight;
|
|
27
|
+
InputSize: typeof InputSize;
|
|
28
|
+
ModalSize: typeof ModalSize;
|
|
25
29
|
};
|
|
26
30
|
typography: typeof typography;
|
|
27
31
|
custom: typeof customCommon;
|
package/package.json
CHANGED