@particle-network/ui-native 0.0.12 → 0.0.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/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/UXListBoxItem.js +2 -1
- 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/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/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 +4 -3
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 };
|
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.14",
|
|
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",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@particle-network/ui-shared": "*",
|
|
55
55
|
"ahooks": "^3.9.4",
|
|
56
|
+
"deepmerge": "^4.3.1",
|
|
56
57
|
"expo-haptics": "^14.1.4",
|
|
57
58
|
"react-native-paper": "^5.14.5",
|
|
58
59
|
"react-native-size-matters": "^0.4.2"
|
|
@@ -63,10 +64,10 @@
|
|
|
63
64
|
"@chromatic-com/storybook": "^4.0.0",
|
|
64
65
|
"@expo/metro-runtime": "~5.0.4",
|
|
65
66
|
"@gorhom/bottom-sheet": "^5.1.2",
|
|
67
|
+
"@particle-network/eslint-config": "*",
|
|
66
68
|
"@react-native-async-storage/async-storage": "2.1.2",
|
|
67
69
|
"@react-native-community/datetimepicker": "8.4.1",
|
|
68
70
|
"@react-native-community/slider": "4.5.6",
|
|
69
|
-
"@particle-network/eslint-config": "*",
|
|
70
71
|
"@rsbuild/core": "^1.5.0",
|
|
71
72
|
"@rsbuild/plugin-react": "^1.3.5",
|
|
72
73
|
"@rslib/core": "^0.12.2",
|