@particle-network/ui-native 0.1.3-beta.7 → 0.1.4-beta.0
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/Text/text.js +3 -2
- package/dist/components/UXChip/styles.js +13 -7
- package/dist/components/UXChip/types.d.ts +1 -1
- package/dist/components/layout/Box/box.js +3 -2
- package/dist/components/layout/Box/useBox.style.js +4 -1
- package/dist/components/layout/Box/useBox.type.d.ts +1 -0
- package/dist/config/config.default.js +1 -1
- package/dist/hooks/useShadow.d.ts +3 -0
- package/dist/hooks/useShadow.js +12 -0
- package/dist/theme/shadow.d.ts +3 -0
- package/dist/theme/shadow.js +9 -0
- package/dist/theme/theme.js +2 -0
- package/dist/types/theme.d.ts +3 -0
- package/package.json +5 -5
|
@@ -6,7 +6,7 @@ import { Box, useBoxStyle } from "../layout/Box/index.js";
|
|
|
6
6
|
import { HStack } from "../layout/HStack.js";
|
|
7
7
|
import { useTextStyles } from "./text.style.js";
|
|
8
8
|
const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
9
|
-
const { variant = 'body2Bold', fontWeight, color = 'default', lineHeight, align, style, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, underlineStyle, fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow, ...restProps } = props;
|
|
9
|
+
const { variant = 'body2Bold', fontWeight, color = 'default', lineHeight, align, style, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, underlineStyle, fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow, shadow, ...restProps } = props;
|
|
10
10
|
const [textWidth, setTextWidth] = useState(0);
|
|
11
11
|
const { getColor } = useColors();
|
|
12
12
|
const boxStyle = useBoxStyle({
|
|
@@ -71,7 +71,8 @@ const text_Text = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
71
71
|
bgOpacity,
|
|
72
72
|
opacity,
|
|
73
73
|
zIndex,
|
|
74
|
-
overflow
|
|
74
|
+
overflow,
|
|
75
|
+
shadow
|
|
75
76
|
});
|
|
76
77
|
const { styles } = useTextStyles({
|
|
77
78
|
variant,
|
|
@@ -2,6 +2,7 @@ import { useMemo } from "react";
|
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
3
|
import { useColors, useMs } from "../../hooks/index.js";
|
|
4
4
|
import { disabledOpacity } from "../../theme/index.js";
|
|
5
|
+
const isCustomColor = (color)=>'string' == typeof color && color.startsWith('#');
|
|
5
6
|
const useStyles = ({ size = 'md', color = 'default', variant = 'flat', isDisabled, bg })=>{
|
|
6
7
|
const { getColor } = useColors();
|
|
7
8
|
const { ms } = useMs();
|
|
@@ -22,8 +23,11 @@ const useStyles = ({ size = 'md', color = 'default', variant = 'flat', isDisable
|
|
|
22
23
|
size
|
|
23
24
|
]);
|
|
24
25
|
const textColor = useMemo(()=>{
|
|
25
|
-
if (
|
|
26
|
-
|
|
26
|
+
if (isCustomColor(color)) {
|
|
27
|
+
if ('solid' === variant) return 'white';
|
|
28
|
+
return color;
|
|
29
|
+
}
|
|
30
|
+
if ('default' === color) return getColor('secondary');
|
|
27
31
|
if ('solid' === variant) return getColor('white');
|
|
28
32
|
return getColor(color);
|
|
29
33
|
}, [
|
|
@@ -33,18 +37,20 @@ const useStyles = ({ size = 'md', color = 'default', variant = 'flat', isDisable
|
|
|
33
37
|
]);
|
|
34
38
|
const backgroundColor = useMemo(()=>{
|
|
35
39
|
if (bg) return getColor(bg);
|
|
40
|
+
if (isCustomColor(color)) {
|
|
41
|
+
if ('solid' === variant) return color;
|
|
42
|
+
return `${color}20`;
|
|
43
|
+
}
|
|
36
44
|
if ('solid' === variant) {
|
|
37
45
|
if ([
|
|
38
|
-
'default'
|
|
39
|
-
'secondary'
|
|
46
|
+
'default'
|
|
40
47
|
].includes(color)) return getColor('bg-200');
|
|
41
48
|
return getColor(color);
|
|
42
49
|
}
|
|
43
50
|
if ('flat' === variant) {
|
|
44
51
|
if ([
|
|
45
|
-
'default'
|
|
46
|
-
|
|
47
|
-
].includes(color)) return getColor('bg-200');
|
|
52
|
+
'default'
|
|
53
|
+
].includes(color)) return getColor('bg-300');
|
|
48
54
|
return `${getColor(color)}20`;
|
|
49
55
|
}
|
|
50
56
|
return 'transparent';
|
|
@@ -2,7 +2,7 @@ import type React from 'react';
|
|
|
2
2
|
import type { UXForegroundColor } from '@particle-network/ui-shared';
|
|
3
3
|
import type { HStackProps } from '../layout/HStack';
|
|
4
4
|
export interface UXChipProps extends HStackProps {
|
|
5
|
-
color?: UXForegroundColor
|
|
5
|
+
color?: UXForegroundColor | `#${string}`;
|
|
6
6
|
size?: 'sm' | 'md' | 'lg';
|
|
7
7
|
variant?: 'solid' | 'flat';
|
|
8
8
|
isDisabled?: boolean;
|
|
@@ -3,7 +3,7 @@ import react, { forwardRef } from "react";
|
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { useBoxStyle } from "./useBox.style.js";
|
|
5
5
|
const Box = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
6
|
-
const { as, style, fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow, ...restProps } = props;
|
|
6
|
+
const { as, style, fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow, shadow, ...restProps } = props;
|
|
7
7
|
const boxStyle = useBoxStyle({
|
|
8
8
|
fullWidth,
|
|
9
9
|
fullHeight,
|
|
@@ -66,7 +66,8 @@ const Box = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
66
66
|
bgOpacity,
|
|
67
67
|
opacity,
|
|
68
68
|
zIndex,
|
|
69
|
-
overflow
|
|
69
|
+
overflow,
|
|
70
|
+
shadow
|
|
70
71
|
});
|
|
71
72
|
if (as) return /*#__PURE__*/ react.cloneElement(as, {
|
|
72
73
|
...restProps,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { useColors, useMs, useRadius, useSpacing } from "../../../hooks/index.js";
|
|
2
|
+
import { useShadow } from "../../../hooks/useShadow.js";
|
|
2
3
|
const useBoxStyle = (props)=>{
|
|
3
|
-
const { fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow } = props;
|
|
4
|
+
const { fullWidth, fullHeight, h, minH, maxH, w, minW, maxW, m, mt, mr, mb, ml, ms, me, mh, mv, p, pt, pr, pb, pl, ps, pe, ph, pv, borderStyle, border, borderTop, borderRight, borderBottom, borderLeft, borderStart, borderEnd, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderStartColor, borderEndColor, radius, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, topStartRadius, topEndRadius, bottomStartRadius, bottomEndRadius, position, top, right, bottom, left, start, end, bg, bgOpacity, opacity, zIndex, overflow, shadow } = props;
|
|
4
5
|
const { ms: uxms } = useMs();
|
|
5
6
|
const { getColor } = useColors();
|
|
6
7
|
const { getSpacing } = useSpacing();
|
|
7
8
|
const { getRadius } = useRadius();
|
|
9
|
+
const { getShadow } = useShadow();
|
|
8
10
|
const borderFunc = (value)=>{
|
|
9
11
|
if ('number' == typeof value) return uxms(value);
|
|
10
12
|
return value;
|
|
@@ -69,6 +71,7 @@ const useBoxStyle = (props)=>{
|
|
|
69
71
|
styleObj.opacity = opacity;
|
|
70
72
|
styleObj.zIndex = zIndex;
|
|
71
73
|
styleObj.overflow = overflow;
|
|
74
|
+
styleObj.boxShadow = getShadow(shadow);
|
|
72
75
|
const boxStyle = styleObj;
|
|
73
76
|
return boxStyle;
|
|
74
77
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useTheme } from "./useTheme.js";
|
|
2
|
+
function useShadow() {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
return {
|
|
5
|
+
getShadow: (shadow)=>{
|
|
6
|
+
if (!shadow) return;
|
|
7
|
+
if (true === shadow) return theme.shadow.default;
|
|
8
|
+
return theme.shadow[shadow];
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export { useShadow };
|
package/dist/theme/theme.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createColors } from "./colors.js";
|
|
2
2
|
import { createRadius } from "./radius.js";
|
|
3
|
+
import { createShadow } from "./shadow.js";
|
|
3
4
|
import { createSpacing } from "./spacing.js";
|
|
4
5
|
function createTheme(theme, dynamicColors, msFactor) {
|
|
5
6
|
return {
|
|
@@ -7,6 +8,7 @@ function createTheme(theme, dynamicColors, msFactor) {
|
|
|
7
8
|
colors: createColors(theme, dynamicColors),
|
|
8
9
|
spacing: createSpacing(msFactor),
|
|
9
10
|
radius: createRadius(msFactor),
|
|
11
|
+
shadow: createShadow(theme),
|
|
10
12
|
msFactor
|
|
11
13
|
};
|
|
12
14
|
}
|
package/dist/types/theme.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-beta.0",
|
|
4
4
|
"main": "./entry.js",
|
|
5
5
|
"react-native": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-native-paper": "^5.14.5",
|
|
47
47
|
"react-native-size-matters": "^0.4.2",
|
|
48
48
|
"react-native-toast-message": "^2.3.3",
|
|
49
|
-
"@particle-network/ui-shared": "0.1.1
|
|
49
|
+
"@particle-network/ui-shared": "0.1.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/core": "^7.24.0",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"unfetch": "^4.2.0",
|
|
89
89
|
"vite": "^6.3.5",
|
|
90
90
|
"zustand": "^5.0.8",
|
|
91
|
-
"@particle-network/eslint-config": "0.
|
|
92
|
-
"@particle-network/lintstaged-config": "0.
|
|
93
|
-
"@particle-network/icons": "0.1.
|
|
91
|
+
"@particle-network/eslint-config": "0.3.0",
|
|
92
|
+
"@particle-network/lintstaged-config": "0.1.0",
|
|
93
|
+
"@particle-network/icons": "0.1.3-beta.1"
|
|
94
94
|
},
|
|
95
95
|
"overrides": {
|
|
96
96
|
"react-docgen-typescript": "2.2.2",
|