@particle-network/ui-native 0.0.11 → 0.0.13
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/index.d.ts +1 -1
- package/dist/components/Text/index.js +0 -1
- package/dist/components/Text/text.js +12 -39
- package/dist/components/Text/text.style.d.ts +24 -0
- package/dist/components/Text/text.style.js +124 -0
- package/dist/components/Text/text.types.d.ts +0 -10
- package/dist/components/Text/text.types.js +0 -77
- package/dist/components/UXButton/button.js +3 -2
- package/dist/components/UXButton/button.styles.d.ts +2 -21
- package/dist/components/UXButton/button.styles.js +71 -45
- package/dist/components/UXButton/button.types.d.ts +15 -6
- package/dist/components/UXCheckbox/checkbox.js +2 -1
- package/dist/components/UXChip/chip.js +3 -1
- package/dist/components/UXChip/styles.d.ts +0 -10
- package/dist/components/UXChip/styles.js +13 -13
- package/dist/components/UXHint/index.js +2 -1
- package/dist/components/UXListBox/UXListBox.d.ts +12 -0
- package/dist/components/UXListBox/UXListBox.js +61 -0
- package/dist/components/UXListBox/UXListBoxItem.d.ts +3 -0
- package/dist/components/UXListBox/UXListBoxItem.js +57 -0
- package/dist/components/UXListBox/UXListBoxSection.d.ts +3 -0
- package/dist/components/UXListBox/UXListBoxSection.js +15 -0
- package/dist/components/UXListBox/index.d.ts +4 -0
- package/dist/components/UXListBox/index.js +4 -0
- package/dist/components/UXListBox/types.d.ts +25 -0
- package/dist/components/UXListBox/types.js +0 -0
- package/dist/components/UXModal/index.js +7 -5
- package/dist/components/UXRadio/radio.js +2 -1
- package/dist/components/UXSwitch/styles.js +2 -1
- package/dist/components/UXSwitch/switch.js +2 -2
- package/dist/components/UXTabs/styles.d.ts +4 -1
- package/dist/components/UXTabs/styles.js +38 -34
- package/dist/components/UXTabs/tab.js +33 -21
- package/dist/components/UXTabs/types.d.ts +16 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input/styles.d.ts +1 -1
- package/dist/components/input/styles.js +19 -19
- package/dist/components/layout/Box/useBox.style.js +6 -6
- package/dist/config/config.default.d.ts +2 -0
- package/dist/config/config.default.js +55 -0
- package/dist/config/config.ux.d.ts +2 -0
- package/dist/config/config.ux.js +61 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +7 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useComponentConfig.d.ts +1 -0
- package/dist/hooks/useComponentConfig.js +7 -0
- package/dist/hooks/useMs.d.ts +3 -0
- package/dist/hooks/useMs.js +10 -0
- package/dist/icons/CheckIcon.d.ts +4 -0
- package/dist/icons/CheckIcon.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/provider/ThemeContext.d.ts +1 -1
- package/dist/provider/ThemeContext.js +5 -2
- package/dist/provider/ThemeProvider.d.ts +4 -2
- package/dist/provider/ThemeProvider.js +18 -6
- package/dist/theme/colors.d.ts +1 -1
- package/dist/theme/colors.js +2 -2
- package/dist/theme/index.d.ts +1 -3
- package/dist/theme/index.js +1 -12
- package/dist/theme/radius.d.ts +1 -1
- package/dist/theme/radius.js +3 -3
- package/dist/theme/spacing.d.ts +1 -1
- package/dist/theme/spacing.js +2 -2
- package/dist/theme/theme.d.ts +3 -0
- package/dist/theme/theme.js +13 -0
- package/dist/types/theme.d.ts +33 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/mergeConfig.d.ts +8 -0
- package/dist/utils/mergeConfig.js +6 -0
- package/package.json +7 -5
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import { sizeMap } from "@particle-network/ui-shared";
|
|
5
|
-
import { useColors, useRadius } from "../../hooks/index.js";
|
|
3
|
+
import { useColors, useComponentConfig, useMs, useRadius } from "../../hooks/index.js";
|
|
6
4
|
import { disabledOpacity } from "../../theme/index.js";
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
md:
|
|
10
|
-
lg: ms(14)
|
|
11
|
-
};
|
|
12
|
-
const radiusMap = {
|
|
13
|
-
sm: 'sm',
|
|
14
|
-
md: 'sm',
|
|
15
|
-
lg: 'md'
|
|
16
|
-
};
|
|
17
|
-
const useStyles = ({ isInvalid, isDisabled, fullWidth, isFocused, color = 'primary', size = 'md', variant = 'flat', radius, width: widthProp, textAlign = 'left' })=>{
|
|
5
|
+
const useStyles = (props)=>{
|
|
6
|
+
const { input: inputConfig } = useComponentConfig();
|
|
7
|
+
const { isInvalid, isDisabled, fullWidth, isFocused, color = 'primary', size = 'md', variant = 'flat', radius = inputConfig.defaultProps?.radius, width: widthProp, textAlign = 'left' } = props;
|
|
18
8
|
const { getColor } = useColors();
|
|
19
9
|
const { getRadius } = useRadius();
|
|
10
|
+
const { ms } = useMs();
|
|
11
|
+
const radiusMap = {
|
|
12
|
+
sm: 'sm',
|
|
13
|
+
md: 'sm',
|
|
14
|
+
lg: 'md'
|
|
15
|
+
};
|
|
20
16
|
const width = useMemo(()=>{
|
|
21
17
|
if (fullWidth) return '100%';
|
|
22
18
|
if (widthProp) return widthProp;
|
|
@@ -25,15 +21,19 @@ const useStyles = ({ isInvalid, isDisabled, fullWidth, isFocused, color = 'prima
|
|
|
25
21
|
fullWidth,
|
|
26
22
|
widthProp
|
|
27
23
|
]);
|
|
28
|
-
const height = useMemo(()=>ms(
|
|
29
|
-
size
|
|
24
|
+
const height = useMemo(()=>ms(inputConfig.size[size]), [
|
|
25
|
+
size,
|
|
26
|
+
inputConfig.size,
|
|
27
|
+
ms
|
|
30
28
|
]);
|
|
31
|
-
const fontSize = useMemo(()=>
|
|
32
|
-
size
|
|
29
|
+
const fontSize = useMemo(()=>inputConfig.fontSize[size], [
|
|
30
|
+
size,
|
|
31
|
+
inputConfig.fontSize
|
|
33
32
|
]);
|
|
34
33
|
const borderRadius = useMemo(()=>getRadius(radius ?? radiusMap[size]), [
|
|
35
34
|
radius,
|
|
36
|
-
size
|
|
35
|
+
size,
|
|
36
|
+
getRadius
|
|
37
37
|
]);
|
|
38
38
|
const borderColor = useMemo(()=>{
|
|
39
39
|
if (isInvalid) return getColor('danger');
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useColors, useRadius, useSpacing } from "../../../hooks/index.js";
|
|
3
|
-
const borderFunc = (value)=>{
|
|
4
|
-
if ('number' == typeof value) return external_react_native_size_matters_ms(value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
1
|
+
import { useColors, useMs, useRadius, useSpacing } from "../../../hooks/index.js";
|
|
7
2
|
const useBoxStyle = (props)=>{
|
|
8
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 { ms: uxms } = useMs();
|
|
9
5
|
const { getColor } = useColors();
|
|
10
6
|
const { getSpacing } = useSpacing();
|
|
11
7
|
const { getRadius } = useRadius();
|
|
8
|
+
const borderFunc = (value)=>{
|
|
9
|
+
if ('number' == typeof value) return uxms(value);
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
12
|
const styleObj = {};
|
|
13
13
|
styleObj.width = fullWidth ? '100%' : getSpacing(w);
|
|
14
14
|
styleObj.height = fullHeight ? '100%' : getSpacing(h);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const defaultComponentConfig = {
|
|
2
|
+
button: {
|
|
3
|
+
defaultProps: {},
|
|
4
|
+
size: {
|
|
5
|
+
sm: 24,
|
|
6
|
+
md: 30,
|
|
7
|
+
lg: 44
|
|
8
|
+
},
|
|
9
|
+
fontSize: {
|
|
10
|
+
sm: 10,
|
|
11
|
+
md: 12,
|
|
12
|
+
lg: 16
|
|
13
|
+
},
|
|
14
|
+
color: {
|
|
15
|
+
default: {
|
|
16
|
+
background: 'bg-300',
|
|
17
|
+
text: 'default'
|
|
18
|
+
},
|
|
19
|
+
secondary: {
|
|
20
|
+
background: 'bg-300',
|
|
21
|
+
text: 'secondary'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
input: {
|
|
26
|
+
defaultProps: {},
|
|
27
|
+
size: {
|
|
28
|
+
sm: 24,
|
|
29
|
+
md: 30,
|
|
30
|
+
lg: 44
|
|
31
|
+
},
|
|
32
|
+
fontSize: {
|
|
33
|
+
sm: 12,
|
|
34
|
+
md: 12,
|
|
35
|
+
lg: 14
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
modal: {
|
|
39
|
+
radius: 24
|
|
40
|
+
},
|
|
41
|
+
tabs: {
|
|
42
|
+
defaultProps: {},
|
|
43
|
+
fontSize: {
|
|
44
|
+
sm: 12,
|
|
45
|
+
md: 14,
|
|
46
|
+
lg: 16
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
chip: {
|
|
50
|
+
defaultProps: {
|
|
51
|
+
radius: 4
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export { defaultComponentConfig };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const uxComponentConfig = {
|
|
2
|
+
button: {
|
|
3
|
+
defaultProps: {
|
|
4
|
+
radius: 'full'
|
|
5
|
+
},
|
|
6
|
+
size: {
|
|
7
|
+
sm: 40,
|
|
8
|
+
md: 44,
|
|
9
|
+
lg: 48
|
|
10
|
+
},
|
|
11
|
+
fontSize: {
|
|
12
|
+
sm: 14,
|
|
13
|
+
md: 16,
|
|
14
|
+
lg: 18
|
|
15
|
+
},
|
|
16
|
+
color: {
|
|
17
|
+
default: {
|
|
18
|
+
background: 'foreground',
|
|
19
|
+
text: 'bg-default'
|
|
20
|
+
},
|
|
21
|
+
secondary: {
|
|
22
|
+
background: 'bg-200',
|
|
23
|
+
text: 'foreground'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
input: {
|
|
28
|
+
defaultProps: {
|
|
29
|
+
radius: 'full'
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
sm: 30,
|
|
33
|
+
md: 40,
|
|
34
|
+
lg: 44
|
|
35
|
+
},
|
|
36
|
+
fontSize: {
|
|
37
|
+
sm: 14,
|
|
38
|
+
md: 14,
|
|
39
|
+
lg: 14
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
modal: {
|
|
43
|
+
radius: 34
|
|
44
|
+
},
|
|
45
|
+
tabs: {
|
|
46
|
+
defaultProps: {
|
|
47
|
+
radius: 'full'
|
|
48
|
+
},
|
|
49
|
+
fontSize: {
|
|
50
|
+
sm: 12,
|
|
51
|
+
md: 14,
|
|
52
|
+
lg: 16
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
chip: {
|
|
56
|
+
defaultProps: {
|
|
57
|
+
radius: 'full'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export { uxComponentConfig };
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useComponentConfig(): import("..").ComponentConfig;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useThemeContext } from "../provider/ThemeContext.js";
|
|
2
|
+
import { defaultComponentConfig } from "../config/config.default.js";
|
|
3
|
+
function useComponentConfig() {
|
|
4
|
+
const { componentConfig } = useThemeContext();
|
|
5
|
+
return componentConfig || defaultComponentConfig;
|
|
6
|
+
}
|
|
7
|
+
export { useComponentConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { moderateScale } from "react-native-size-matters";
|
|
2
|
+
import { useTheme } from "./useTheme.js";
|
|
3
|
+
function useMs() {
|
|
4
|
+
const { msFactor } = useTheme();
|
|
5
|
+
const ms = (value)=>'number' == typeof msFactor ? moderateScale(value, msFactor) : moderateScale(value);
|
|
6
|
+
return {
|
|
7
|
+
ms
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { useMs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } 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 CheckIcon_CheckIcon = ({ size = 16, color = 'default', ...props })=>{
|
|
6
|
+
const { getColor } = useColors();
|
|
7
|
+
return /*#__PURE__*/ jsx(react_native_svg, {
|
|
8
|
+
width: size,
|
|
9
|
+
height: size,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
fill: "none",
|
|
12
|
+
...props,
|
|
13
|
+
children: /*#__PURE__*/ jsx(Path, {
|
|
14
|
+
d: "M19.3281 6.28711C19.7108 5.90439 20.3302 5.9044 20.7129 6.28711C21.0956 6.66983 21.0956 7.28916 20.7129 7.67188L10.042 18.3389C10.0336 18.3479 10.0264 18.3584 10.0176 18.3672C9.82525 18.5574 9.57459 18.6514 9.32422 18.6514C9.07383 18.6513 8.82312 18.5555 8.63281 18.3652L3.28711 13.0186C2.90448 12.6358 2.90442 12.0165 3.28711 11.6338C3.66982 11.2513 4.28923 11.2512 4.67188 11.6338L9.32422 16.2891L19.3281 6.28711Z",
|
|
15
|
+
fill: getColor(color)
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const CheckIcon = CheckIcon_CheckIcon;
|
|
20
|
+
export { CheckIcon as default };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ThemeContextValue } from '../types
|
|
1
|
+
import type { ThemeContextValue } from '../types';
|
|
2
2
|
export declare const ThemeContextProvider: import("react").Provider<ThemeContextValue | undefined>;
|
|
3
3
|
export declare function useThemeContext(): ThemeContextValue;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
+
import { builtinComponentConfig } from "../config/index.js";
|
|
2
3
|
import { createTheme } from "../theme/index.js";
|
|
3
4
|
const ThemeContext = /*#__PURE__*/ createContext(void 0);
|
|
4
5
|
const ThemeContextProvider = ThemeContext.Provider;
|
|
@@ -7,8 +8,10 @@ function useThemeContext() {
|
|
|
7
8
|
if (!context) return {
|
|
8
9
|
theme: createTheme('light'),
|
|
9
10
|
config: {
|
|
10
|
-
theme: 'light'
|
|
11
|
-
|
|
11
|
+
theme: 'light',
|
|
12
|
+
componentConfig: builtinComponentConfig["default"]
|
|
13
|
+
},
|
|
14
|
+
componentConfig: builtinComponentConfig["default"]
|
|
12
15
|
};
|
|
13
16
|
return context;
|
|
14
17
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DynamicColors } from '@particle-network/ui-shared';
|
|
3
|
-
import type { ThemeMode } from '../types';
|
|
3
|
+
import type { ComponentConfig, ThemeMode } from '../types';
|
|
4
4
|
export interface ThemeProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
theme?: ThemeMode;
|
|
7
7
|
dynamicColors?: DynamicColors;
|
|
8
|
+
msFactor?: number;
|
|
9
|
+
componentConfig?: ComponentConfig;
|
|
8
10
|
onThemeChange?: (theme: ThemeMode) => void;
|
|
9
11
|
}
|
|
10
|
-
export declare function ThemeProvider({ children, theme, dynamicColors, onThemeChange }: ThemeProviderProps): React.JSX.Element;
|
|
12
|
+
export declare function ThemeProvider({ children, theme, dynamicColors, msFactor, componentConfig, onThemeChange, }: ThemeProviderProps): React.JSX.Element;
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { builtinComponentConfig } from "../config/index.js";
|
|
4
4
|
import { ThemeContextProvider } from "./ThemeContext.js";
|
|
5
|
-
|
|
5
|
+
import { createTheme } from "../theme/index.js";
|
|
6
|
+
import { mergeComponentConfig } from "../utils/index.js";
|
|
7
|
+
function ThemeProvider({ children, theme = 'light', dynamicColors, msFactor, componentConfig, onThemeChange }) {
|
|
8
|
+
const mergedComponentConfig = useMemo(()=>mergeComponentConfig(builtinComponentConfig["default"], componentConfig), [
|
|
9
|
+
componentConfig
|
|
10
|
+
]);
|
|
6
11
|
const config = useMemo(()=>({
|
|
7
12
|
theme,
|
|
8
|
-
dynamicColors
|
|
13
|
+
dynamicColors,
|
|
14
|
+
msFactor,
|
|
15
|
+
componentConfig: mergedComponentConfig
|
|
9
16
|
}), [
|
|
10
17
|
theme,
|
|
11
|
-
dynamicColors
|
|
18
|
+
dynamicColors,
|
|
19
|
+
msFactor,
|
|
20
|
+
mergedComponentConfig
|
|
12
21
|
]);
|
|
13
|
-
const themeObject = useMemo(()=>createTheme(theme, dynamicColors), [
|
|
22
|
+
const themeObject = useMemo(()=>createTheme(theme, dynamicColors, msFactor), [
|
|
14
23
|
theme,
|
|
15
|
-
dynamicColors
|
|
24
|
+
dynamicColors,
|
|
25
|
+
msFactor
|
|
16
26
|
]);
|
|
17
27
|
const contextValue = useMemo(()=>({
|
|
18
28
|
theme: themeObject,
|
|
19
29
|
config,
|
|
30
|
+
componentConfig: mergedComponentConfig,
|
|
20
31
|
setTheme: onThemeChange
|
|
21
32
|
}), [
|
|
22
33
|
themeObject,
|
|
23
34
|
config,
|
|
35
|
+
mergedComponentConfig,
|
|
24
36
|
onThemeChange
|
|
25
37
|
]);
|
|
26
38
|
return /*#__PURE__*/ jsx(ThemeContextProvider, {
|
package/dist/theme/colors.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare const DEFAULT_DYNAMIC_COLORS: {
|
|
|
3
3
|
bullish: string;
|
|
4
4
|
bearish: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function createColors(theme: 'light' | 'dark', dynamicColors?: DynamicColors): ThemeColors;
|
package/dist/theme/colors.js
CHANGED
|
@@ -3,7 +3,7 @@ const DEFAULT_DYNAMIC_COLORS = {
|
|
|
3
3
|
bullish: '#45B167',
|
|
4
4
|
bearish: '#E84A5A'
|
|
5
5
|
};
|
|
6
|
-
function
|
|
6
|
+
function createColors(theme, dynamicColors) {
|
|
7
7
|
const mergedDynamicColors = {
|
|
8
8
|
...DEFAULT_DYNAMIC_COLORS,
|
|
9
9
|
...dynamicColors
|
|
@@ -14,4 +14,4 @@ function getColors(theme, dynamicColors) {
|
|
|
14
14
|
bearish: mergedDynamicColors.bearish
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export { DEFAULT_DYNAMIC_COLORS,
|
|
17
|
+
export { DEFAULT_DYNAMIC_COLORS, createColors };
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { DynamicColors } from '@particle-network/ui-shared';
|
|
2
|
-
import type { Theme, ThemeMode } from '../types';
|
|
3
|
-
export declare function createTheme(theme: ThemeMode, dynamicColors?: DynamicColors): Theme;
|
|
4
1
|
export * from './colors';
|
|
5
2
|
export * from './opacity';
|
|
6
3
|
export * from './radius';
|
|
7
4
|
export * from './spacing';
|
|
5
|
+
export * from './theme';
|
package/dist/theme/index.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { getColors } from "./colors.js";
|
|
2
|
-
import { createRadius } from "./radius.js";
|
|
3
|
-
import { createSpacing } from "./spacing.js";
|
|
4
1
|
export * from "./colors.js";
|
|
5
2
|
export * from "./opacity.js";
|
|
6
3
|
export * from "./radius.js";
|
|
7
4
|
export * from "./spacing.js";
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
theme,
|
|
11
|
-
colors: getColors(theme, dynamicColors),
|
|
12
|
-
spacing: createSpacing(),
|
|
13
|
-
radius: createRadius()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export { createTheme };
|
|
5
|
+
export * from "./theme.js";
|
package/dist/theme/radius.d.ts
CHANGED
package/dist/theme/radius.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ms } from "react-native-size-matters";
|
|
2
2
|
import { radiusMap } from "@particle-network/ui-shared";
|
|
3
|
-
function createRadius() {
|
|
3
|
+
function createRadius(msFactor) {
|
|
4
4
|
return Object.entries(radiusMap).reduce((acc, [key, value])=>{
|
|
5
|
-
acc[key] = 'full' === key ? value :
|
|
5
|
+
acc[key] = 'full' === key ? value : ms(value, msFactor);
|
|
6
6
|
return acc;
|
|
7
7
|
}, {});
|
|
8
8
|
}
|
package/dist/theme/spacing.d.ts
CHANGED
package/dist/theme/spacing.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ms } from "react-native-size-matters";
|
|
2
2
|
import { spacingMap } from "@particle-network/ui-shared";
|
|
3
|
-
function createSpacing() {
|
|
3
|
+
function createSpacing(msFactor) {
|
|
4
4
|
return Object.entries(spacingMap).reduce((acc, [key, value])=>{
|
|
5
|
-
acc[key] = ms(value);
|
|
5
|
+
acc[key] = ms(value, msFactor);
|
|
6
6
|
return acc;
|
|
7
7
|
}, {});
|
|
8
8
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createColors } from "./colors.js";
|
|
2
|
+
import { createRadius } from "./radius.js";
|
|
3
|
+
import { createSpacing } from "./spacing.js";
|
|
4
|
+
function createTheme(theme, dynamicColors, msFactor) {
|
|
5
|
+
return {
|
|
6
|
+
theme,
|
|
7
|
+
colors: createColors(theme, dynamicColors),
|
|
8
|
+
spacing: createSpacing(msFactor),
|
|
9
|
+
radius: createRadius(msFactor),
|
|
10
|
+
msFactor
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export { createTheme };
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
|
-
import type { DynamicColors, RadiusScale, SpacingScale, ThemeColors } from '@particle-network/ui-shared';
|
|
1
|
+
import type { DynamicColors, RadiusScale, SpacingScale, ThemeColors, UXRadius } from '@particle-network/ui-shared';
|
|
2
2
|
export type ThemeMode = 'light' | 'dark';
|
|
3
|
+
export interface CommonComponentConfig {
|
|
4
|
+
defaultProps?: {
|
|
5
|
+
radius?: UXRadius | number;
|
|
6
|
+
};
|
|
7
|
+
size: {
|
|
8
|
+
sm: number;
|
|
9
|
+
md: number;
|
|
10
|
+
lg: number;
|
|
11
|
+
};
|
|
12
|
+
fontSize: {
|
|
13
|
+
sm: number;
|
|
14
|
+
md: number;
|
|
15
|
+
lg: number;
|
|
16
|
+
};
|
|
17
|
+
color: Record<string, {
|
|
18
|
+
background: string;
|
|
19
|
+
text: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface ComponentConfig {
|
|
23
|
+
button: CommonComponentConfig;
|
|
24
|
+
input: Omit<CommonComponentConfig, 'color'>;
|
|
25
|
+
modal: {
|
|
26
|
+
radius: number;
|
|
27
|
+
};
|
|
28
|
+
tabs: Pick<CommonComponentConfig, 'defaultProps' | 'fontSize'>;
|
|
29
|
+
chip: Pick<CommonComponentConfig, 'defaultProps'>;
|
|
30
|
+
}
|
|
3
31
|
export interface ThemeConfig {
|
|
4
32
|
theme: ThemeMode;
|
|
5
33
|
dynamicColors?: DynamicColors;
|
|
34
|
+
msFactor?: number;
|
|
35
|
+
componentConfig: ComponentConfig;
|
|
6
36
|
}
|
|
7
37
|
export interface Theme {
|
|
8
38
|
theme: ThemeMode;
|
|
9
39
|
colors: ThemeColors;
|
|
10
40
|
spacing: SpacingScale;
|
|
11
41
|
radius: RadiusScale;
|
|
42
|
+
msFactor?: number;
|
|
12
43
|
}
|
|
13
44
|
export interface ThemeContextValue {
|
|
14
45
|
theme: Theme;
|
|
15
46
|
config: ThemeConfig;
|
|
47
|
+
componentConfig?: ComponentConfig;
|
|
16
48
|
setTheme?: (theme: ThemeMode) => void;
|
|
17
49
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 深度合并组件配置
|
|
4
|
+
* @param defaultConfig 默认配置
|
|
5
|
+
* @param userConfig 用户配置
|
|
6
|
+
* @returns 合并后的配置
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeComponentConfig(defaultConfig: ComponentConfig, userConfig?: ComponentConfig): ComponentConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./entry.js",
|
|
6
6
|
"react-native": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"android": "expo start --android",
|
|
22
22
|
"ios": "expo start --ios",
|
|
23
23
|
"web": "storybook dev -p 6006",
|
|
24
|
-
"storybook:build": "storybook build
|
|
24
|
+
"storybook:build": "storybook build",
|
|
25
25
|
"storybook:preview": "serve storybook-static",
|
|
26
26
|
"storybook:generate": "sb-rn-get-stories",
|
|
27
27
|
"type-check": "npx tsc --noEmit -p ./tsconfig.json",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"build": "rslib build",
|
|
30
30
|
"lint": "eslint . --no-error-on-unmatched-pattern --quiet",
|
|
31
31
|
"lint:fix": "eslint . --fix --no-error-on-unmatched-pattern --quiet",
|
|
32
|
-
"clean": "rm -rf .turbo node_modules dist"
|
|
32
|
+
"clean": "rm -rf .turbo node_modules dist",
|
|
33
|
+
"deploy:dev": "sh ./scripts/deploy-dev.sh"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist",
|
|
@@ -52,7 +53,9 @@
|
|
|
52
53
|
"dependencies": {
|
|
53
54
|
"@particle-network/ui-shared": "*",
|
|
54
55
|
"ahooks": "^3.9.4",
|
|
56
|
+
"deepmerge": "^4.3.1",
|
|
55
57
|
"expo-haptics": "^14.1.4",
|
|
58
|
+
"react-native-paper": "^5.14.5",
|
|
56
59
|
"react-native-size-matters": "^0.4.2"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
@@ -61,10 +64,10 @@
|
|
|
61
64
|
"@chromatic-com/storybook": "^4.0.0",
|
|
62
65
|
"@expo/metro-runtime": "~5.0.4",
|
|
63
66
|
"@gorhom/bottom-sheet": "^5.1.2",
|
|
67
|
+
"@particle-network/eslint-config": "*",
|
|
64
68
|
"@react-native-async-storage/async-storage": "2.1.2",
|
|
65
69
|
"@react-native-community/datetimepicker": "8.4.1",
|
|
66
70
|
"@react-native-community/slider": "4.5.6",
|
|
67
|
-
"@particle-network/eslint-config": "*",
|
|
68
71
|
"@rsbuild/core": "^1.5.0",
|
|
69
72
|
"@rsbuild/plugin-react": "^1.3.5",
|
|
70
73
|
"@rslib/core": "^0.12.2",
|
|
@@ -88,7 +91,6 @@
|
|
|
88
91
|
"react-dom": "19.0.0",
|
|
89
92
|
"react-native": "0.79.5",
|
|
90
93
|
"react-native-gesture-handler": "~2.24.0",
|
|
91
|
-
"react-native-paper": "^5.14.5",
|
|
92
94
|
"react-native-reanimated": "~3.17.4",
|
|
93
95
|
"react-native-safe-area-context": "5.4.0",
|
|
94
96
|
"react-native-svg": "15.11.2",
|