@particle-network/ui-native 0.0.20 → 0.0.21
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.
|
@@ -5,19 +5,19 @@ export declare const useTextStyles: ({ variant, fontWeight, color, lineHeight, a
|
|
|
5
5
|
textAlign: ("right" | "left" | "center") | undefined;
|
|
6
6
|
color: string | undefined;
|
|
7
7
|
lineHeight: number;
|
|
8
|
-
fontWeight: "
|
|
8
|
+
fontWeight: "400" | "500" | "600" | "700" | "800";
|
|
9
9
|
fontSize: number;
|
|
10
10
|
} | {
|
|
11
11
|
textAlign: ("right" | "left" | "center") | undefined;
|
|
12
12
|
color: string | undefined;
|
|
13
13
|
lineHeight: number;
|
|
14
|
-
fontWeight: "
|
|
14
|
+
fontWeight: "400" | "500" | "600" | "700" | "800";
|
|
15
15
|
fontSize: number;
|
|
16
16
|
} | {
|
|
17
17
|
textAlign: ("right" | "left" | "center") | undefined;
|
|
18
18
|
color: string | undefined;
|
|
19
19
|
lineHeight: number;
|
|
20
|
-
fontWeight: "
|
|
20
|
+
fontWeight: "400" | "500" | "600" | "700" | "800";
|
|
21
21
|
fontSize: number;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
@@ -2,12 +2,14 @@ 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
4
|
import { useColors } from "../../hooks/index.js";
|
|
5
|
+
import CloseIcon from "../../icons/CloseIcon.js";
|
|
5
6
|
import { HStack } from "../layout/HStack.js";
|
|
6
7
|
import { VStack } from "../layout/VStack.js";
|
|
7
8
|
import { Text } from "../Text/index.js";
|
|
9
|
+
import { UXPressable } from "../UXPressable/index.js";
|
|
8
10
|
import { useStyles } from "./styles.js";
|
|
9
11
|
const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
10
|
-
const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, startContent, endContent, isReadOnly, isDisabled, isRequired, 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, ...restProps } = props;
|
|
11
13
|
const { getColor } = useColors();
|
|
12
14
|
const inputRef = useRef(null);
|
|
13
15
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
@@ -53,6 +55,17 @@ const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
53
55
|
}, [
|
|
54
56
|
onBlur
|
|
55
57
|
]);
|
|
58
|
+
const handleClear = useCallback(()=>{
|
|
59
|
+
if (isDisabled || isReadOnly) return;
|
|
60
|
+
setInternalValue('');
|
|
61
|
+
onChangeText?.('');
|
|
62
|
+
onValueChange?.('');
|
|
63
|
+
}, [
|
|
64
|
+
isDisabled,
|
|
65
|
+
isReadOnly,
|
|
66
|
+
onChangeText,
|
|
67
|
+
onValueChange
|
|
68
|
+
]);
|
|
56
69
|
const validationResult = useMemo(()=>{
|
|
57
70
|
if (!internalValue && isRequired) {
|
|
58
71
|
setIsInvalid(true);
|
|
@@ -126,7 +139,13 @@ const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
126
139
|
onFocus: handleFocus,
|
|
127
140
|
...restProps
|
|
128
141
|
}),
|
|
129
|
-
renderContent(endContent)
|
|
142
|
+
renderContent(endContent),
|
|
143
|
+
!isClearable || !internalValue || isDisabled || isReadOnly ? null : /*#__PURE__*/ jsx(UXPressable, {
|
|
144
|
+
onPress: handleClear,
|
|
145
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {
|
|
146
|
+
size: 16
|
|
147
|
+
})
|
|
148
|
+
})
|
|
130
149
|
]
|
|
131
150
|
}),
|
|
132
151
|
!!renderError && /*#__PURE__*/ jsx(Text, {
|
|
@@ -4,7 +4,7 @@ type UseStylesProps = UXInputCommonProps & {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const useStyles: (props: UseStylesProps) => {
|
|
6
6
|
container: {
|
|
7
|
-
width: number | import("react-native").Animated.AnimatedNode |
|
|
7
|
+
width: number | "auto" | import("react-native").Animated.AnimatedNode | `${number}%`;
|
|
8
8
|
height: number | undefined;
|
|
9
9
|
paddingTop: number;
|
|
10
10
|
paddingBottom: number;
|