@particle-network/ui-native 0.5.1-beta.13 → 0.5.1-beta.14
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/UXHint/index.js +16 -7
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/range-input.d.ts +4 -0
- package/dist/components/input/range-input.js +106 -0
- package/dist/components/input/types.d.ts +44 -0
- package/package.json +5 -5
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import CircleQuestionIcon from "@particle-network/icons/native/CircleQuestionIcon";
|
|
4
4
|
import { useMs } from "../../hooks/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Center } from "../layout/index.js";
|
|
6
6
|
import { UXTooltip } from "../UXTooltip/index.js";
|
|
7
7
|
const UXHint = (props)=>{
|
|
8
8
|
const { content, children, iconStyle, iconColor = 'secondary', style, ...restProps } = props;
|
|
@@ -10,14 +10,23 @@ const UXHint = (props)=>{
|
|
|
10
10
|
return /*#__PURE__*/ jsx(UXTooltip, {
|
|
11
11
|
content: content || children,
|
|
12
12
|
...restProps,
|
|
13
|
-
children: /*#__PURE__*/ jsx(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
children: /*#__PURE__*/ jsx(Center, {
|
|
14
|
+
style: [
|
|
15
|
+
{
|
|
16
|
+
minWidth: ms(16),
|
|
17
|
+
minHeight: ms(16)
|
|
18
|
+
},
|
|
19
|
+
style
|
|
20
|
+
],
|
|
17
21
|
children: /*#__PURE__*/ jsx(CircleQuestionIcon, {
|
|
18
22
|
color: iconColor,
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
style: [
|
|
24
|
+
{
|
|
25
|
+
width: ms(14),
|
|
26
|
+
height: ms(14)
|
|
27
|
+
},
|
|
28
|
+
iconStyle
|
|
29
|
+
]
|
|
21
30
|
})
|
|
22
31
|
})
|
|
23
32
|
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { HStack } from "../layout/HStack.js";
|
|
4
|
+
import { Text } from "../Text/index.js";
|
|
5
|
+
import { UXNumberInput } from "./number-input.js";
|
|
6
|
+
const UXRangeInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
7
|
+
const { value, defaultValue, onValueChange, minValue, maxValue, minInputProps = {}, maxInputProps = {}, separator = '-', gap = 8, containerStyle, ...restProps } = props;
|
|
8
|
+
const minInputRef = useRef(null);
|
|
9
|
+
const maxInputRef = useRef(null);
|
|
10
|
+
const [internalValue, setInternalValue] = useState(defaultValue || {
|
|
11
|
+
min: void 0,
|
|
12
|
+
max: void 0
|
|
13
|
+
});
|
|
14
|
+
const currentValue = void 0 !== value ? value : internalValue;
|
|
15
|
+
const handleMinChange = useCallback((newMin)=>{
|
|
16
|
+
const minValue = isNaN(newMin) ? 0 : newMin;
|
|
17
|
+
const newValue = {
|
|
18
|
+
min: minValue,
|
|
19
|
+
max: currentValue.max
|
|
20
|
+
};
|
|
21
|
+
if (void 0 !== currentValue.max && !isNaN(currentValue.max) && minValue > currentValue.max) newValue.max = minValue;
|
|
22
|
+
if (void 0 === value) setInternalValue(newValue);
|
|
23
|
+
onValueChange?.(newValue);
|
|
24
|
+
}, [
|
|
25
|
+
currentValue.max,
|
|
26
|
+
value,
|
|
27
|
+
onValueChange
|
|
28
|
+
]);
|
|
29
|
+
const handleMaxChange = useCallback((newMax)=>{
|
|
30
|
+
const maxValue = isNaN(newMax) ? 0 : newMax;
|
|
31
|
+
const newValue = {
|
|
32
|
+
min: currentValue.min,
|
|
33
|
+
max: maxValue
|
|
34
|
+
};
|
|
35
|
+
if (void 0 !== currentValue.min && !isNaN(currentValue.min) && maxValue < currentValue.min) newValue.min = maxValue;
|
|
36
|
+
if (void 0 === value) setInternalValue(newValue);
|
|
37
|
+
onValueChange?.(newValue);
|
|
38
|
+
}, [
|
|
39
|
+
currentValue.min,
|
|
40
|
+
value,
|
|
41
|
+
onValueChange
|
|
42
|
+
]);
|
|
43
|
+
const minInputMaxValue = useMemo(()=>{
|
|
44
|
+
if (void 0 !== currentValue.max && !isNaN(currentValue.max)) return currentValue.max;
|
|
45
|
+
return maxValue;
|
|
46
|
+
}, [
|
|
47
|
+
currentValue.max,
|
|
48
|
+
maxValue
|
|
49
|
+
]);
|
|
50
|
+
const maxInputMinValue = useMemo(()=>{
|
|
51
|
+
if (void 0 !== currentValue.min && !isNaN(currentValue.min)) return currentValue.min;
|
|
52
|
+
return minValue;
|
|
53
|
+
}, [
|
|
54
|
+
currentValue.min,
|
|
55
|
+
minValue
|
|
56
|
+
]);
|
|
57
|
+
return /*#__PURE__*/ jsxs(HStack, {
|
|
58
|
+
ref: ref,
|
|
59
|
+
gap: gap,
|
|
60
|
+
style: containerStyle,
|
|
61
|
+
items: "center",
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsx(UXNumberInput, {
|
|
64
|
+
...restProps,
|
|
65
|
+
...minInputProps,
|
|
66
|
+
ref: minInputRef,
|
|
67
|
+
value: currentValue.min,
|
|
68
|
+
minValue: minValue,
|
|
69
|
+
maxValue: minInputMaxValue,
|
|
70
|
+
placeholder: minInputProps.placeholder || 'Min',
|
|
71
|
+
containerStyle: [
|
|
72
|
+
{
|
|
73
|
+
flex: 1
|
|
74
|
+
},
|
|
75
|
+
minInputProps.containerStyle
|
|
76
|
+
],
|
|
77
|
+
onValueChange: handleMinChange
|
|
78
|
+
}),
|
|
79
|
+
separator && /*#__PURE__*/ jsx(Text, {
|
|
80
|
+
color: "tertiary",
|
|
81
|
+
style: {
|
|
82
|
+
marginHorizontal: 4
|
|
83
|
+
},
|
|
84
|
+
children: separator
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ jsx(UXNumberInput, {
|
|
87
|
+
...restProps,
|
|
88
|
+
...maxInputProps,
|
|
89
|
+
ref: maxInputRef,
|
|
90
|
+
value: currentValue.max,
|
|
91
|
+
minValue: maxInputMinValue,
|
|
92
|
+
maxValue: maxValue,
|
|
93
|
+
placeholder: maxInputProps.placeholder || 'Max',
|
|
94
|
+
containerStyle: [
|
|
95
|
+
{
|
|
96
|
+
flex: 1
|
|
97
|
+
},
|
|
98
|
+
maxInputProps.containerStyle
|
|
99
|
+
],
|
|
100
|
+
onValueChange: handleMaxChange
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
UXRangeInput.displayName = 'UXRangeInput';
|
|
106
|
+
export { UXRangeInput };
|
|
@@ -65,3 +65,47 @@ export interface UXNumberInputProps extends UXInputCommonProps {
|
|
|
65
65
|
allowNegative?: boolean;
|
|
66
66
|
onValueChange?: (value: number) => void;
|
|
67
67
|
}
|
|
68
|
+
export interface UXRangeInputValue {
|
|
69
|
+
min?: number;
|
|
70
|
+
max?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface UXRangeInputProps extends Omit<UXNumberInputProps, 'value' | 'defaultValue' | 'onValueChange' | 'minValue' | 'maxValue'> {
|
|
73
|
+
/**
|
|
74
|
+
* The current value of the range input (controlled)
|
|
75
|
+
*/
|
|
76
|
+
value?: UXRangeInputValue;
|
|
77
|
+
/**
|
|
78
|
+
* The default value of the range input (uncontrolled)
|
|
79
|
+
*/
|
|
80
|
+
defaultValue?: UXRangeInputValue;
|
|
81
|
+
/**
|
|
82
|
+
* The minimum value allowed for both inputs
|
|
83
|
+
*/
|
|
84
|
+
minValue?: number;
|
|
85
|
+
/**
|
|
86
|
+
* The maximum value allowed for both inputs
|
|
87
|
+
*/
|
|
88
|
+
maxValue?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Props for the minimum input
|
|
91
|
+
*/
|
|
92
|
+
minInputProps?: Partial<UXNumberInputProps>;
|
|
93
|
+
/**
|
|
94
|
+
* Props for the maximum input
|
|
95
|
+
*/
|
|
96
|
+
maxInputProps?: Partial<UXNumberInputProps>;
|
|
97
|
+
/**
|
|
98
|
+
* Separator between the two inputs
|
|
99
|
+
* @default '-'
|
|
100
|
+
*/
|
|
101
|
+
separator?: ReactNode;
|
|
102
|
+
/**
|
|
103
|
+
* Gap between the inputs (in pixels)
|
|
104
|
+
* @default 8
|
|
105
|
+
*/
|
|
106
|
+
gap?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Callback fired when the value changes
|
|
109
|
+
*/
|
|
110
|
+
onValueChange?: (value: UXRangeInputValue) => void;
|
|
111
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-native",
|
|
3
|
-
"version": "0.5.1-beta.
|
|
3
|
+
"version": "0.5.1-beta.14",
|
|
4
4
|
"main": "./entry.js",
|
|
5
5
|
"react-native": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react-native-size-matters": "^0.4.2",
|
|
46
46
|
"react-native-toast-message": "^2.3.3",
|
|
47
47
|
"react-native-worklets": "0.5.1",
|
|
48
|
-
"@particle-network/
|
|
49
|
-
"@particle-network/
|
|
48
|
+
"@particle-network/icons": "0.5.1-beta.9",
|
|
49
|
+
"@particle-network/ui-shared": "0.4.1-beta.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/core": "^7.24.0",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"unfetch": "^4.2.0",
|
|
90
90
|
"vite": "^6.3.5",
|
|
91
91
|
"zustand": "^5.0.8",
|
|
92
|
-
"@particle-network/
|
|
92
|
+
"@particle-network/lintstaged-config": "0.1.0",
|
|
93
93
|
"@particle-network/eslint-config": "0.3.0",
|
|
94
|
-
"@particle-network/
|
|
94
|
+
"@particle-network/icons": "0.5.1-beta.9"
|
|
95
95
|
},
|
|
96
96
|
"overrides": {
|
|
97
97
|
"react-docgen-typescript": "2.2.2",
|