@particle-network/ui-native 0.1.4-beta.4 → 0.1.4-beta.6

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
3
3
  import { TextInput } from "react-native";
4
- import { useColors } from "../../hooks/index.js";
4
+ import { useColors, useKeyboard } from "../../hooks/index.js";
5
5
  import { Icon } from "../../icons/index.js";
6
6
  import { HStack } from "../layout/HStack.js";
7
7
  import { VStack } from "../layout/VStack.js";
@@ -9,12 +9,19 @@ import { Text } from "../Text/index.js";
9
9
  import { UXPressable } from "../UXPressable/index.js";
10
10
  import { useStyles } from "./styles.js";
11
11
  const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
12
- const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, startContent, endContent, isReadOnly, isDisabled, isRequired, isClearable, isInvalid: isInvalidProp, autoErrorMessage, label, onChangeText, onValueChange, onFocus, onBlur, ...restProps } = props;
12
+ const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, startContent, endContent, isReadOnly, isDisabled, isRequired, isClearable, isInvalid: isInvalidProp, autoErrorMessage, label, onChangeText, onValueChange, onFocus, onBlur, blurOnKeyboardHide = true, ...restProps } = props;
13
13
  const { getColor } = useColors();
14
14
  const inputRef = useRef(null);
15
15
  const [internalValue, setInternalValue] = useState(defaultValue);
16
16
  const [isFocused, setIsFocused] = useState(false);
17
17
  const [isInvalid, setIsInvalid] = useState(isInvalidProp);
18
+ const { isKeyboardVisible } = useKeyboard();
19
+ useEffect(()=>{
20
+ if (!isKeyboardVisible && blurOnKeyboardHide) inputRef.current?.blur();
21
+ }, [
22
+ isKeyboardVisible,
23
+ blurOnKeyboardHide
24
+ ]);
18
25
  useImperativeHandle(ref, ()=>({
19
26
  blur: ()=>{
20
27
  inputRef.current?.blur();
@@ -130,6 +137,7 @@ const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
130
137
  styles.input,
131
138
  inputStyle
132
139
  ],
140
+ textAlignVertical: restProps.multiline ? 'top' : void 0,
133
141
  value: internalValue,
134
142
  onBlur: handleBlur,
135
143
  onChangeText: (v)=>{
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
3
3
  import { Platform, TextInput } from "react-native";
4
- import { useColors } from "../../hooks/index.js";
4
+ import { useColors, useKeyboard } from "../../hooks/index.js";
5
5
  import { Icon } from "../../icons/index.js";
6
6
  import { HStack } from "../layout/HStack.js";
7
7
  import { VStack } from "../layout/VStack.js";
@@ -9,13 +9,20 @@ import { Text } from "../Text/index.js";
9
9
  import { UXPressable } from "../UXPressable/index.js";
10
10
  import { useStyles } from "./styles.js";
11
11
  const UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
12
- const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, minValue, maxValue, formatOptions, startContent, endContent, isRequired, isReadOnly, isDisabled, isClearable, isInvalid: isInvalidProp, autoErrorMessage, allowNegative, label, onChangeText, onValueChange, onFocus, onBlur, ...restProps } = props;
12
+ const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, minValue, maxValue, formatOptions, startContent, endContent, isRequired, isReadOnly, isDisabled, isClearable, isInvalid: isInvalidProp, autoErrorMessage, allowNegative, label, onChangeText, onValueChange, onFocus, onBlur, blurOnKeyboardHide = true, ...restProps } = props;
13
13
  const { getColor } = useColors();
14
14
  const inputRef = useRef(null);
15
15
  const [internalValue, setInternalValue] = useState(defaultValue ?? NaN);
16
16
  const [displayText, setDisplayText] = useState(defaultValue?.toString() ?? '');
17
17
  const [isFocused, setIsFocused] = useState(false);
18
18
  const [isInvalid, setIsInvalid] = useState(isInvalidProp);
19
+ const { isKeyboardVisible } = useKeyboard();
20
+ useEffect(()=>{
21
+ if (!isKeyboardVisible && blurOnKeyboardHide) inputRef.current?.blur();
22
+ }, [
23
+ isKeyboardVisible,
24
+ blurOnKeyboardHide
25
+ ]);
19
26
  useImperativeHandle(ref, ()=>({
20
27
  blur: ()=>{
21
28
  inputRef.current?.blur();
@@ -39,6 +39,11 @@ export interface UXInputCommonProps extends Omit<TextInputProps, 'style' | 'valu
39
39
  label?: string;
40
40
  textAlign?: 'left' | 'center' | 'right';
41
41
  autoErrorMessage?: boolean;
42
+ /**
43
+ * 是否在键盘隐藏时自动 blur
44
+ * @default true
45
+ */
46
+ blurOnKeyboardHide?: boolean;
42
47
  }
43
48
  export interface UXInputProps extends UXInputCommonProps {
44
49
  value?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-native",
3
- "version": "0.1.4-beta.4",
3
+ "version": "0.1.4-beta.6",
4
4
  "main": "./entry.js",
5
5
  "react-native": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -90,8 +90,8 @@
90
90
  "unfetch": "^4.2.0",
91
91
  "vite": "^6.3.5",
92
92
  "zustand": "^5.0.8",
93
- "@particle-network/lintstaged-config": "0.1.0",
94
93
  "@particle-network/eslint-config": "0.3.0",
94
+ "@particle-network/lintstaged-config": "0.1.0",
95
95
  "@particle-network/icons": "0.1.3-beta.3"
96
96
  },
97
97
  "overrides": {