@particle-network/ui-native 0.1.4-beta.1 → 0.1.4-beta.2
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/UXCheckbox/checkbox.js +31 -17
- package/dist/components/UXCheckbox/icons.d.ts +14 -0
- package/dist/components/UXCheckbox/icons.js +41 -0
- package/dist/components/UXCheckbox/types.d.ts +2 -2
- package/dist/icons/index.js +0 -31
- package/dist/icons/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { useMs } from "../../hooks/index.js";
|
|
4
|
-
import { Icon } from "../../icons/index.js";
|
|
5
4
|
import { disabledOpacity } from "../../theme/index.js";
|
|
6
5
|
import { Flex } from "../layout/Flex/index.js";
|
|
7
6
|
import { Text } from "../Text/index.js";
|
|
8
7
|
import { UXPressable } from "../UXPressable/index.js";
|
|
9
8
|
import { useCheckboxGroup } from "./context.js";
|
|
10
|
-
|
|
9
|
+
import { CheckboxOffIcon, CheckboxOnIcon } from "./icons.js";
|
|
10
|
+
const UXCheckbox = ({ size, color, defaultSelected = false, isSelected, children, value, onValueChange, isDisabled, labelPlacement = 'right', ...props })=>{
|
|
11
11
|
const { ms } = useMs();
|
|
12
12
|
const [internalSelected, setInternalSelected] = useState(defaultSelected ?? isSelected);
|
|
13
13
|
const groupContext = useCheckboxGroup();
|
|
@@ -21,6 +21,19 @@ const UXCheckbox = ({ size, color, defaultSelected = false, isSelected, children
|
|
|
21
21
|
defaultSelected
|
|
22
22
|
]);
|
|
23
23
|
const checkboxColor = color || groupContext?.color || 'primary';
|
|
24
|
+
const displayLabelPlacement = labelPlacement || groupContext?.labelPlacement || 'right';
|
|
25
|
+
const bgColor = useMemo(()=>{
|
|
26
|
+
if ('secondary' === checkboxColor) return 'tertiary';
|
|
27
|
+
return checkboxColor;
|
|
28
|
+
}, [
|
|
29
|
+
checkboxColor
|
|
30
|
+
]);
|
|
31
|
+
const foregroundColor = useMemo(()=>{
|
|
32
|
+
if ('secondary' === checkboxColor) return 'foreground';
|
|
33
|
+
return 'white';
|
|
34
|
+
}, [
|
|
35
|
+
checkboxColor
|
|
36
|
+
]);
|
|
24
37
|
const checkboxIsDisabled = isDisabled || groupContext?.isDisabled;
|
|
25
38
|
const checkboxSize = size || groupContext?.size || 'md';
|
|
26
39
|
const handleSelectChange = ()=>{
|
|
@@ -32,23 +45,24 @@ const UXCheckbox = ({ size, color, defaultSelected = false, isSelected, children
|
|
|
32
45
|
};
|
|
33
46
|
const iconSize = useMemo(()=>{
|
|
34
47
|
if ('sm' === checkboxSize) return ms(14);
|
|
35
|
-
if ('lg' === checkboxSize) return ms(
|
|
48
|
+
if ('lg' === checkboxSize) return ms(18);
|
|
36
49
|
return ms(16);
|
|
37
50
|
}, [
|
|
38
|
-
checkboxSize
|
|
51
|
+
checkboxSize,
|
|
52
|
+
ms
|
|
39
53
|
]);
|
|
40
54
|
const labelVariant = useMemo(()=>{
|
|
41
|
-
if ('sm' === checkboxSize) return '
|
|
42
|
-
if ('lg' === checkboxSize) return '
|
|
43
|
-
return '
|
|
55
|
+
if ('sm' === checkboxSize) return 'body3';
|
|
56
|
+
if ('lg' === checkboxSize) return 'body1';
|
|
57
|
+
return 'body2';
|
|
44
58
|
}, [
|
|
45
59
|
checkboxSize
|
|
46
60
|
]);
|
|
47
|
-
const
|
|
48
|
-
if ('
|
|
49
|
-
return
|
|
61
|
+
const flexDirection = useMemo(()=>{
|
|
62
|
+
if ('left' === displayLabelPlacement) return 'row-reverse';
|
|
63
|
+
return 'row';
|
|
50
64
|
}, [
|
|
51
|
-
|
|
65
|
+
displayLabelPlacement
|
|
52
66
|
]);
|
|
53
67
|
return /*#__PURE__*/ jsx(UXPressable, {
|
|
54
68
|
disabled: checkboxIsDisabled,
|
|
@@ -57,16 +71,16 @@ const UXCheckbox = ({ size, color, defaultSelected = false, isSelected, children
|
|
|
57
71
|
},
|
|
58
72
|
onPress: handleSelectChange,
|
|
59
73
|
children: /*#__PURE__*/ jsxs(Flex, {
|
|
60
|
-
|
|
74
|
+
direction: flexDirection,
|
|
75
|
+
gap: 8,
|
|
61
76
|
items: "center",
|
|
62
77
|
...props,
|
|
63
78
|
children: [
|
|
64
|
-
internalSelected ? /*#__PURE__*/ jsx(
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
internalSelected ? /*#__PURE__*/ jsx(CheckboxOnIcon, {
|
|
80
|
+
color1: bgColor,
|
|
81
|
+
color2: foregroundColor,
|
|
67
82
|
size: iconSize
|
|
68
|
-
}) : /*#__PURE__*/ jsx(
|
|
69
|
-
name: "checkboxOff",
|
|
83
|
+
}) : /*#__PURE__*/ jsx(CheckboxOffIcon, {
|
|
70
84
|
color: "secondary",
|
|
71
85
|
size: iconSize
|
|
72
86
|
}),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UXColor } from '@particle-network/ui-shared';
|
|
3
|
+
interface CheckboxOnIconProps {
|
|
4
|
+
size?: number;
|
|
5
|
+
color1?: UXColor;
|
|
6
|
+
color2?: UXColor;
|
|
7
|
+
}
|
|
8
|
+
interface CheckboxOffIconProps {
|
|
9
|
+
size?: number;
|
|
10
|
+
color?: UXColor;
|
|
11
|
+
}
|
|
12
|
+
export declare const CheckboxOnIcon: ({ size, color1, color2 }: CheckboxOnIconProps) => React.JSX.Element;
|
|
13
|
+
export declare const CheckboxOffIcon: ({ size, color }: CheckboxOffIconProps) => React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import react_native_svg, { Path } from "react-native-svg";
|
|
4
|
+
import { useColors } from "../../hooks/index.js";
|
|
5
|
+
const CheckboxOnIcon = ({ size = 16, color1 = 'default', color2 = 'white' })=>{
|
|
6
|
+
const { getColor } = useColors();
|
|
7
|
+
const color1Value = getColor(color1);
|
|
8
|
+
const color2Value = getColor(color2);
|
|
9
|
+
return /*#__PURE__*/ jsxs(react_native_svg, {
|
|
10
|
+
fill: "none",
|
|
11
|
+
viewBox: "0 0 16 16",
|
|
12
|
+
width: size,
|
|
13
|
+
height: size,
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ jsx(Path, {
|
|
16
|
+
d: "M2.46154 16H13.5385C14.8979 16 16 14.8979 16 13.5385V2.46154C16 1.10207 14.8979 0 13.5385 0H2.46154C1.10207 0 0 1.10207 0 2.46154V13.5385C0 14.8979 1.10207 16 2.46154 16Z",
|
|
17
|
+
fill: color1Value
|
|
18
|
+
}),
|
|
19
|
+
/*#__PURE__*/ jsx(Path, {
|
|
20
|
+
d: "M6.75547 9.24601L4.84436 7.3349C4.68139 7.17193 4.47399 7.09045 4.22214 7.09045C3.97028 7.09045 3.76288 7.17193 3.59991 7.3349C3.43695 7.49786 3.35547 7.70527 3.35547 7.95712C3.35547 8.20897 3.43695 8.41638 3.59991 8.57934L6.13325 11.1127C6.31102 11.2905 6.51843 11.3793 6.75547 11.3793C6.99251 11.3793 7.19991 11.2905 7.37769 11.1127L12.3999 6.09045C12.5629 5.92749 12.6444 5.72008 12.6444 5.46823C12.6444 5.21638 12.5629 5.00897 12.3999 4.84601C12.237 4.68304 12.0295 4.60156 11.7777 4.60156C11.5258 4.60156 11.3184 4.68304 11.1555 4.84601L6.75547 9.24601Z",
|
|
21
|
+
fill: color2Value
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const CheckboxOffIcon = ({ size = 16, color = 'default' })=>{
|
|
27
|
+
const { getColor } = useColors();
|
|
28
|
+
const colorValue = getColor(color);
|
|
29
|
+
return /*#__PURE__*/ jsx(react_native_svg, {
|
|
30
|
+
fill: "none",
|
|
31
|
+
viewBox: "0 0 16 16",
|
|
32
|
+
width: size,
|
|
33
|
+
height: size,
|
|
34
|
+
children: /*#__PURE__*/ jsx(Path, {
|
|
35
|
+
d: "M2.46191 0.615234H13.5381C14.5577 0.615234 15.3848 1.44231 15.3848 2.46191V13.5381C15.3848 14.5577 14.5577 15.3848 13.5381 15.3848H2.46191C1.44231 15.3848 0.615234 14.5577 0.615234 13.5381V2.46191C0.615234 1.44231 1.44231 0.615234 2.46191 0.615234Z",
|
|
36
|
+
stroke: colorValue,
|
|
37
|
+
strokeWidth: 1.23077
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export { CheckboxOffIcon, CheckboxOnIcon };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { UXForegroundColor } from '@particle-network/ui-shared';
|
|
2
1
|
export interface UXCheckboxCommonProps {
|
|
3
|
-
color?:
|
|
2
|
+
color?: 'secondary' | 'primary' | 'success' | 'danger' | 'alert' | 'warning' | 'gold' | 'bullish' | 'bearish';
|
|
4
3
|
size?: 'sm' | 'md' | 'lg';
|
|
5
4
|
isDisabled?: boolean;
|
|
5
|
+
labelPlacement?: 'left' | 'right';
|
|
6
6
|
}
|
package/dist/icons/index.js
CHANGED
|
@@ -6,37 +6,6 @@ const Icon = ({ name, size = 16, color = 'default', ...props })=>{
|
|
|
6
6
|
const { getColor } = useColors();
|
|
7
7
|
const colorValue = getColor(color);
|
|
8
8
|
switch(name){
|
|
9
|
-
case 'checkboxOff':
|
|
10
|
-
return /*#__PURE__*/ jsx(react_native_svg, {
|
|
11
|
-
fill: "none",
|
|
12
|
-
height: size,
|
|
13
|
-
viewBox: "0 0 16 16",
|
|
14
|
-
width: size,
|
|
15
|
-
...props,
|
|
16
|
-
children: /*#__PURE__*/ jsx(Path, {
|
|
17
|
-
d: "M2.46191 0.615234H13.5381C14.5577 0.615234 15.3848 1.44231 15.3848 2.46191V13.5381C15.3848 14.5577 14.5577 15.3848 13.5381 15.3848H2.46191C1.44231 15.3848 0.615234 14.5577 0.615234 13.5381V2.46191C0.615234 1.44231 1.44231 0.615234 2.46191 0.615234Z",
|
|
18
|
-
stroke: colorValue,
|
|
19
|
-
strokeWidth: 1.23077
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
case 'checkboxOn':
|
|
23
|
-
return /*#__PURE__*/ jsxs(react_native_svg, {
|
|
24
|
-
fill: "none",
|
|
25
|
-
height: size,
|
|
26
|
-
viewBox: "0 0 16 16",
|
|
27
|
-
width: size,
|
|
28
|
-
...props,
|
|
29
|
-
children: [
|
|
30
|
-
/*#__PURE__*/ jsx(Path, {
|
|
31
|
-
d: "M2.46154 16H13.5385C14.8979 16 16 14.8979 16 13.5385V2.46154C16 1.10207 14.8979 0 13.5385 0H2.46154C1.10207 0 0 1.10207 0 2.46154V13.5385C0 14.8979 1.10207 16 2.46154 16Z",
|
|
32
|
-
fill: colorValue
|
|
33
|
-
}),
|
|
34
|
-
/*#__PURE__*/ jsx(Path, {
|
|
35
|
-
d: "M6.75547 9.24601L4.84436 7.3349C4.68139 7.17193 4.47399 7.09045 4.22214 7.09045C3.97028 7.09045 3.76288 7.17193 3.59991 7.3349C3.43695 7.49786 3.35547 7.70527 3.35547 7.95712C3.35547 8.20897 3.43695 8.41638 3.59991 8.57934L6.13325 11.1127C6.31102 11.2905 6.51843 11.3793 6.75547 11.3793C6.99251 11.3793 7.19991 11.2905 7.37769 11.1127L12.3999 6.09045C12.5629 5.92749 12.6444 5.72008 12.6444 5.46823C12.6444 5.21638 12.5629 5.00897 12.3999 4.84601C12.237 4.68304 12.0295 4.60156 11.7777 4.60156C11.5258 4.60156 11.3184 4.68304 11.1555 4.84601L6.75547 9.24601Z",
|
|
36
|
-
fill: "#ffffff"
|
|
37
|
-
})
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
9
|
case 'check':
|
|
41
10
|
return /*#__PURE__*/ jsx(react_native_svg, {
|
|
42
11
|
width: size,
|
package/dist/icons/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SvgProps } from 'react-native-svg';
|
|
2
2
|
import type { UXForegroundColor } from '@particle-network/ui-shared';
|
|
3
3
|
export type IconProps = SvgProps & {
|
|
4
|
-
name: '
|
|
4
|
+
name: 'check' | 'close' | 'dot' | 'radioOff' | 'radioOn' | 'question' | 'arrow-right';
|
|
5
5
|
size?: number;
|
|
6
6
|
color?: UXForegroundColor;
|
|
7
7
|
};
|
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.2",
|
|
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/lintstaged-config": "0.1.0",
|
|
93
94
|
"@particle-network/icons": "0.1.3-beta.3",
|
|
94
|
-
"@particle-network/eslint-config": "0.3.0"
|
|
95
|
-
"@particle-network/lintstaged-config": "0.1.0"
|
|
95
|
+
"@particle-network/eslint-config": "0.3.0"
|
|
96
96
|
},
|
|
97
97
|
"overrides": {
|
|
98
98
|
"react-docgen-typescript": "2.2.2",
|