@particle-network/ui-native 0.1.4-beta.5 → 0.1.4-beta.7
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.
|
@@ -116,13 +116,13 @@ const UXModal = /*#__PURE__*/ forwardRef((props, scrollViewRef)=>{
|
|
|
116
116
|
isDragging,
|
|
117
117
|
touchStartY,
|
|
118
118
|
modalHeight,
|
|
119
|
-
height,
|
|
120
119
|
translateY,
|
|
121
|
-
onDismiss
|
|
120
|
+
onDismiss,
|
|
121
|
+
isAndroid
|
|
122
122
|
]);
|
|
123
123
|
const keyboardAvoidValue = useMemo(()=>{
|
|
124
|
-
const containerValue = 'container' === keyboardAvoidPosition ? Math.max(insets.bottom, ms(32), keyboardHeight) : Math.max(insets.bottom, ms(32));
|
|
125
|
-
const contentValue = 'content' === keyboardAvoidPosition && keyboardHeight > 0 ? keyboardHeight - footerHeight - Math.max(insets.bottom, ms(32)) : 0;
|
|
124
|
+
const containerValue = 'container' === keyboardAvoidPosition ? Math.max(insets.bottom, ms(32), keyboardHeight + (isAndroid ? insets.bottom : 0)) : Math.max(insets.bottom, ms(32));
|
|
125
|
+
const contentValue = 'content' === keyboardAvoidPosition && keyboardHeight > 0 ? keyboardHeight - footerHeight - Math.max(insets.bottom, ms(32)) + (isAndroid ? insets.bottom : 0) : 0;
|
|
126
126
|
return {
|
|
127
127
|
containerValue,
|
|
128
128
|
contentValue
|
|
@@ -131,7 +131,9 @@ const UXModal = /*#__PURE__*/ forwardRef((props, scrollViewRef)=>{
|
|
|
131
131
|
keyboardAvoidPosition,
|
|
132
132
|
insets.bottom,
|
|
133
133
|
keyboardHeight,
|
|
134
|
-
footerHeight
|
|
134
|
+
footerHeight,
|
|
135
|
+
isAndroid,
|
|
136
|
+
ms
|
|
135
137
|
]);
|
|
136
138
|
const styles = StyleSheet.create({
|
|
137
139
|
modalContainer: {
|
|
@@ -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();
|
|
@@ -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.
|
|
3
|
+
"version": "0.1.4-beta.7",
|
|
4
4
|
"main": "./entry.js",
|
|
5
5
|
"react-native": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"unfetch": "^4.2.0",
|
|
91
91
|
"vite": "^6.3.5",
|
|
92
92
|
"zustand": "^5.0.8",
|
|
93
|
+
"@particle-network/icons": "0.1.3-beta.3",
|
|
93
94
|
"@particle-network/eslint-config": "0.3.0",
|
|
94
|
-
"@particle-network/lintstaged-config": "0.1.0"
|
|
95
|
-
"@particle-network/icons": "0.1.3-beta.3"
|
|
95
|
+
"@particle-network/lintstaged-config": "0.1.0"
|
|
96
96
|
},
|
|
97
97
|
"overrides": {
|
|
98
98
|
"react-docgen-typescript": "2.2.2",
|