@cdek-it/react-native-ui-kit 0.4.2 → 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 +3 -3
- package/dist/components/Input/InputTextBase/types.d.ts +7 -0
- package/dist/components/Input/InputTextBase/{useStyles.d.ts → useInputStyles.d.ts} +2 -1
- package/dist/components/Input/InputTextBase/{useStyles.js → useInputStyles.js} +18 -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, editable = true, ...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);
|
|
@@ -35,6 +35,13 @@ export interface InputTextBaseProps extends Omit<TextInputProps, 'style' | 'secu
|
|
|
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,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'],
|
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