@particle-network/ui-native 0.0.21 → 0.0.22
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/UXButton/button.js +3 -2
- package/dist/components/UXButton/button.styles.d.ts +1 -1
- package/dist/components/UXButton/button.styles.js +5 -2
- package/dist/components/UXToast/toast.js +4 -1
- package/dist/components/input/input.js +5 -4
- package/dist/components/input/number-input.js +23 -1
- package/dist/components/input/styles.d.ts +2 -1
- package/dist/components/input/styles.js +2 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { UXPressable } from "../UXPressable/index.js";
|
|
|
7
7
|
import { UXSpinner } from "../UXSpinner/index.js";
|
|
8
8
|
import { useStyles } from "./button.styles.js";
|
|
9
9
|
const UXButton = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
10
|
-
const { style, size, radius, color, variant, onPress, isDisabled, isLoading, startContent, endContent, fullWidth, width, w, h, isIconOnly, children, ...restProps } = props;
|
|
10
|
+
const { style, size, radius, color, variant, onPress, isDisabled, isLoading, startContent, endContent, fullWidth, width, w, h, ph, isIconOnly, children, ...restProps } = props;
|
|
11
11
|
const handlePress = (e)=>{
|
|
12
12
|
Keyboard.dismiss();
|
|
13
13
|
triggerHapticFeedback();
|
|
@@ -24,7 +24,8 @@ const UXButton = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
24
24
|
isIconOnly,
|
|
25
25
|
width,
|
|
26
26
|
w,
|
|
27
|
-
h
|
|
27
|
+
h,
|
|
28
|
+
ph
|
|
28
29
|
});
|
|
29
30
|
const content = useMemo(()=>{
|
|
30
31
|
if ('string' == typeof children || 'number' == typeof children) return /*#__PURE__*/ jsx(Text, {
|
|
@@ -10,7 +10,7 @@ export declare const useStyles: (props: UXButtonProps) => {
|
|
|
10
10
|
paddingVertical: number;
|
|
11
11
|
height: number | undefined;
|
|
12
12
|
width: number | "100%" | undefined;
|
|
13
|
-
paddingHorizontal: number;
|
|
13
|
+
paddingHorizontal: number | undefined;
|
|
14
14
|
backgroundColor: string | undefined;
|
|
15
15
|
borderRadius: number | undefined;
|
|
16
16
|
borderWidth: number;
|
|
@@ -4,7 +4,7 @@ import { useColors, useComponentConfig, useMs, useRadius, useSpacing } from "../
|
|
|
4
4
|
import { disabledOpacity } from "../../theme/index.js";
|
|
5
5
|
const useStyles = (props)=>{
|
|
6
6
|
const { button: buttonConfig } = useComponentConfig();
|
|
7
|
-
const { size = 'md', radius = buttonConfig.defaultProps?.radius, color = 'default', variant = 'solid', isDisabled, isLoading, width, w, h, fullWidth, isIconOnly } = props;
|
|
7
|
+
const { size = 'md', radius = buttonConfig.defaultProps?.radius, color = 'default', variant = 'solid', isDisabled, isLoading, width, w, h, ph, fullWidth, isIconOnly } = props;
|
|
8
8
|
const { getColor } = useColors();
|
|
9
9
|
const { getRadius } = useRadius();
|
|
10
10
|
const { getSpacing } = useSpacing();
|
|
@@ -77,12 +77,15 @@ const useStyles = (props)=>{
|
|
|
77
77
|
]);
|
|
78
78
|
const paddingHorizontal = useMemo(()=>{
|
|
79
79
|
if (isIconOnly || 'auto' === size || 'text' === variant) return 0;
|
|
80
|
+
if (void 0 !== ph) return getSpacing(ph);
|
|
80
81
|
return paddingMap[size];
|
|
81
82
|
}, [
|
|
82
83
|
size,
|
|
83
84
|
isIconOnly,
|
|
84
85
|
variant,
|
|
85
|
-
paddingMap
|
|
86
|
+
paddingMap,
|
|
87
|
+
ph,
|
|
88
|
+
getSpacing
|
|
86
89
|
]);
|
|
87
90
|
const textColor = useMemo(()=>{
|
|
88
91
|
const customColorConfig = buttonConfig?.color?.[color];
|
|
@@ -5,6 +5,7 @@ const toast = {
|
|
|
5
5
|
UXToast.show({
|
|
6
6
|
type: 'success',
|
|
7
7
|
text1: message,
|
|
8
|
+
topOffset: 60,
|
|
8
9
|
...options
|
|
9
10
|
});
|
|
10
11
|
},
|
|
@@ -12,16 +13,18 @@ const toast = {
|
|
|
12
13
|
UXToast.show({
|
|
13
14
|
type: 'error',
|
|
14
15
|
text1: message,
|
|
16
|
+
topOffset: 60,
|
|
15
17
|
...options
|
|
16
18
|
});
|
|
17
19
|
},
|
|
18
20
|
loading: (message, options)=>{
|
|
19
|
-
const { visibilityTime = 0, autoHide = !!visibilityTime, ...restOptions } = options ?? {};
|
|
21
|
+
const { visibilityTime = 0, autoHide = !!visibilityTime, topOffset = 60, ...restOptions } = options ?? {};
|
|
20
22
|
UXToast.show({
|
|
21
23
|
type: 'loading',
|
|
22
24
|
text1: message,
|
|
23
25
|
visibilityTime,
|
|
24
26
|
autoHide,
|
|
27
|
+
topOffset,
|
|
25
28
|
...restOptions
|
|
26
29
|
});
|
|
27
30
|
}
|
|
@@ -139,13 +139,14 @@ const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
139
139
|
onFocus: handleFocus,
|
|
140
140
|
...restProps
|
|
141
141
|
}),
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
isClearable && !!internalValue && !isDisabled && !isReadOnly && /*#__PURE__*/ jsx(UXPressable, {
|
|
143
|
+
p: 4,
|
|
144
144
|
onPress: handleClear,
|
|
145
145
|
children: /*#__PURE__*/ jsx(CloseIcon, {
|
|
146
|
-
|
|
146
|
+
style: styles.clearButton
|
|
147
147
|
})
|
|
148
|
-
})
|
|
148
|
+
}),
|
|
149
|
+
renderContent(endContent)
|
|
149
150
|
]
|
|
150
151
|
}),
|
|
151
152
|
!!renderError && /*#__PURE__*/ jsx(Text, {
|
|
@@ -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 { Platform, 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 UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
10
|
-
const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, minValue, maxValue, formatOptions, startContent, endContent, isRequired, isReadOnly, isDisabled, 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, ...restProps } = props;
|
|
11
13
|
const { getColor } = useColors();
|
|
12
14
|
const inputRef = useRef(null);
|
|
13
15
|
const [internalValue, setInternalValue] = useState(defaultValue ?? NaN);
|
|
@@ -139,6 +141,18 @@ const UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
139
141
|
adjustValueToFractionDigits,
|
|
140
142
|
onBlur
|
|
141
143
|
]);
|
|
144
|
+
const handleClear = useCallback(()=>{
|
|
145
|
+
if (isDisabled || isReadOnly) return;
|
|
146
|
+
setDisplayText('');
|
|
147
|
+
setInternalValue(NaN);
|
|
148
|
+
onChangeText?.('');
|
|
149
|
+
onValueChange?.(NaN);
|
|
150
|
+
}, [
|
|
151
|
+
isDisabled,
|
|
152
|
+
isReadOnly,
|
|
153
|
+
onChangeText,
|
|
154
|
+
onValueChange
|
|
155
|
+
]);
|
|
142
156
|
const displayValue = useMemo(()=>{
|
|
143
157
|
if (isFocused) return displayText;
|
|
144
158
|
if (isNaN(internalValue)) return '';
|
|
@@ -219,6 +233,14 @@ const UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
219
233
|
onFocus: handleFocus,
|
|
220
234
|
...restProps
|
|
221
235
|
}),
|
|
236
|
+
isClearable && !isNaN(internalValue) && !isDisabled && !isReadOnly && /*#__PURE__*/ jsx(UXPressable, {
|
|
237
|
+
p: 4,
|
|
238
|
+
onPress: handleClear,
|
|
239
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {
|
|
240
|
+
style: styles.clearButton,
|
|
241
|
+
color: "secondary"
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
222
244
|
renderContent(endContent)
|
|
223
245
|
]
|
|
224
246
|
}),
|