@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.
@@ -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 { useStyles } from './useStyles';
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 = useStyles();
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,4 +1,5 @@
1
- export declare const useStyles: () => {
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";
@@ -1,7 +1,23 @@
1
+ import { useMemo } from 'react';
1
2
  import { makeStyles } from '../../../utils/makeStyles';
2
- export const useStyles = makeStyles(({ theme, border, typography, spacing, fonts }) => ({
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'],
@@ -0,0 +1,3 @@
1
+ {
2
+ "min-height": 35
3
+ }
@@ -0,0 +1,11 @@
1
+ export declare const InputSize: {
2
+ base: {
3
+ "min-height": number;
4
+ };
5
+ large: {
6
+ "min-height": number;
7
+ };
8
+ xlarge: {
9
+ "min-height": number;
10
+ };
11
+ };
@@ -0,0 +1,4 @@
1
+ import base from './base.json';
2
+ import large from './large.json';
3
+ import xlarge from './xlarge.json';
4
+ export const InputSize = { base, large, xlarge };
@@ -0,0 +1,3 @@
1
+ {
2
+ "min-height": 49
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "min-height": 56
3
+ }
@@ -0,0 +1,18 @@
1
+ export declare const ModalSize: {
2
+ sm: {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ md: {
7
+ width: number;
8
+ height: number;
9
+ };
10
+ lg: {
11
+ width: number;
12
+ height: number;
13
+ };
14
+ xl: {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ };
@@ -0,0 +1,5 @@
1
+ import lg from './lg.json';
2
+ import md from './md.json';
3
+ import sm from './sm.json';
4
+ import xl from './xl.json';
5
+ export const ModalSize = { sm, md, lg, xl };
@@ -0,0 +1,4 @@
1
+ {
2
+ "width": 420,
3
+ "height": 280
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "width": 350,
3
+ "height": 210
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "width": 280,
3
+ "height": 140
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "width": 630,
3
+ "height": 350
4
+ }
@@ -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
  };
@@ -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
  };
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdek-it/react-native-ui-kit",
3
- "version": "0.4.2",
3
+ "version": "0.5.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",