@xhsreds/reds-rn-next 0.1.5 → 0.1.6

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.
Files changed (194) hide show
  1. package/benchmarks/out.json +1652 -1025
  2. package/coverage/.tmp/coverage-0.json +1 -1
  3. package/coverage/.tmp/coverage-1.json +1 -1
  4. package/coverage/.tmp/coverage-10.json +1 -1
  5. package/coverage/.tmp/coverage-11.json +1 -1
  6. package/coverage/.tmp/coverage-12.json +1 -1
  7. package/coverage/.tmp/coverage-13.json +1 -1
  8. package/coverage/.tmp/coverage-14.json +1 -1
  9. package/coverage/.tmp/coverage-15.json +1 -1
  10. package/coverage/.tmp/coverage-16.json +1 -1
  11. package/coverage/.tmp/coverage-17.json +1 -1
  12. package/coverage/.tmp/coverage-18.json +1 -1
  13. package/coverage/.tmp/coverage-19.json +1 -1
  14. package/coverage/.tmp/coverage-2.json +1 -1
  15. package/coverage/.tmp/coverage-20.json +1 -1
  16. package/coverage/.tmp/coverage-21.json +1 -1
  17. package/coverage/.tmp/coverage-22.json +1 -1
  18. package/coverage/.tmp/coverage-23.json +1 -1
  19. package/coverage/.tmp/coverage-24.json +1 -1
  20. package/coverage/.tmp/coverage-25.json +1 -1
  21. package/coverage/.tmp/coverage-26.json +1 -1
  22. package/coverage/.tmp/coverage-27.json +1 -1
  23. package/coverage/.tmp/coverage-28.json +1 -1
  24. package/coverage/.tmp/coverage-29.json +1 -1
  25. package/coverage/.tmp/coverage-3.json +1 -1
  26. package/coverage/.tmp/coverage-30.json +1 -1
  27. package/coverage/.tmp/coverage-31.json +1 -1
  28. package/coverage/.tmp/coverage-32.json +1 -1
  29. package/coverage/.tmp/coverage-33.json +1 -1
  30. package/coverage/.tmp/coverage-6.json +1 -1
  31. package/coverage/.tmp/coverage-7.json +1 -1
  32. package/coverage/.tmp/coverage-8.json +1 -1
  33. package/coverage/.tmp/coverage-9.json +1 -1
  34. package/lib/cjs/_chunks/B0pRAs4D.js.map +1 -1
  35. package/lib/cjs/_chunks/{C61-qTj5.js → BkoO2fb2.js} +7 -22
  36. package/lib/cjs/_chunks/BkoO2fb2.js.map +1 -0
  37. package/lib/cjs/_chunks/DHiiOK0R.js.map +1 -1
  38. package/lib/cjs/_chunks/DhVoC10x.js.map +1 -1
  39. package/lib/cjs/_chunks/{K-GkcnsQ.js → DtxkCz1y.js} +2 -1
  40. package/lib/cjs/_chunks/DtxkCz1y.js.map +1 -0
  41. package/lib/cjs/components/Alert/Alert.js +2 -2
  42. package/lib/cjs/components/Alert/index.js +2 -2
  43. package/lib/cjs/components/AvatarGroup/AvatarGroup.js +2 -2
  44. package/lib/cjs/components/AvatarGroup/index.js +2 -2
  45. package/lib/cjs/components/ConfigProvider/ConfigProvider.js +15 -14
  46. package/lib/cjs/components/ConfigProvider/ConfigProvider.js.map +1 -1
  47. package/lib/cjs/components/ConfigProvider/index.js +2 -2
  48. package/lib/cjs/components/ConfigProvider/interface/index.js +1 -1
  49. package/lib/cjs/components/Icon/Icon.js +8 -4
  50. package/lib/cjs/components/Icon/Icon.js.map +1 -1
  51. package/lib/cjs/components/Icon/index.js +5 -0
  52. package/lib/cjs/components/Icon/index.js.map +1 -1
  53. package/lib/cjs/components/ImagePreview/ImagePreview.js +2 -2
  54. package/lib/cjs/components/ImagePreview/index.js +2 -2
  55. package/lib/cjs/components/List/ListItem/ListItem.js +2 -2
  56. package/lib/cjs/components/List/index.js +2 -2
  57. package/lib/cjs/components/NavigationBar/NavigationBar.js +5 -0
  58. package/lib/cjs/components/NavigationBar/NavigationBar.js.map +1 -1
  59. package/lib/cjs/components/NavigationBar/index.js +5 -0
  60. package/lib/cjs/components/NavigationBar/index.js.map +1 -1
  61. package/lib/cjs/components/PullRefresh/PullRefresh.js +2 -2
  62. package/lib/cjs/components/PullRefresh/PullRefresh.js.map +1 -1
  63. package/lib/cjs/components/TabBar/TabBar.js +8 -5
  64. package/lib/cjs/components/TabBar/TabBar.js.map +1 -1
  65. package/lib/cjs/components/TabBar/index.js +5 -2
  66. package/lib/cjs/components/TabBar/index.js.map +1 -1
  67. package/lib/cjs/components/TabBar/interface/index.js +1 -1
  68. package/lib/cjs/components/Tabs/Tabs.js +5 -1
  69. package/lib/cjs/components/Tabs/Tabs.js.map +1 -1
  70. package/lib/cjs/components/Tabs/styles.js +1 -1
  71. package/lib/cjs/components/Tabs/styles.js.map +1 -1
  72. package/lib/cjs/components/Toast/Toast.js +2 -2
  73. package/lib/cjs/components/Toast/api.js +4 -4
  74. package/lib/cjs/components/Toast/index.js +4 -4
  75. package/lib/cjs/index.js +2 -2
  76. package/lib/esm/_chunks/{DKABHJAn.js → BefIgmcR.js} +7 -22
  77. package/lib/esm/_chunks/BefIgmcR.js.map +1 -0
  78. package/lib/esm/_chunks/CGzZESdM.js.map +1 -1
  79. package/lib/esm/_chunks/CZmJhm-r.js.map +1 -1
  80. package/lib/esm/_chunks/DkKS5ieS.js.map +1 -1
  81. package/lib/esm/_chunks/{DUTFT_ka.js → PrCkQ_W3.js} +2 -1
  82. package/lib/esm/_chunks/PrCkQ_W3.js.map +1 -0
  83. package/lib/esm/components/Alert/Alert.js +2 -2
  84. package/lib/esm/components/Alert/index.js +2 -2
  85. package/lib/esm/components/AvatarGroup/AvatarGroup.js +2 -2
  86. package/lib/esm/components/AvatarGroup/index.js +2 -2
  87. package/lib/esm/components/ConfigProvider/ConfigProvider.js +15 -14
  88. package/lib/esm/components/ConfigProvider/ConfigProvider.js.map +1 -1
  89. package/lib/esm/components/ConfigProvider/index.js +2 -2
  90. package/lib/esm/components/ConfigProvider/interface/index.js +1 -1
  91. package/lib/esm/components/Icon/Icon.js +8 -4
  92. package/lib/esm/components/Icon/Icon.js.map +1 -1
  93. package/lib/esm/components/Icon/index.js +5 -0
  94. package/lib/esm/components/Icon/index.js.map +1 -1
  95. package/lib/esm/components/ImagePreview/ImagePreview.js +2 -2
  96. package/lib/esm/components/ImagePreview/index.js +2 -2
  97. package/lib/esm/components/List/ListItem/ListItem.js +2 -2
  98. package/lib/esm/components/List/index.js +2 -2
  99. package/lib/esm/components/NavigationBar/NavigationBar.js +5 -0
  100. package/lib/esm/components/NavigationBar/NavigationBar.js.map +1 -1
  101. package/lib/esm/components/NavigationBar/index.js +5 -0
  102. package/lib/esm/components/NavigationBar/index.js.map +1 -1
  103. package/lib/esm/components/PullRefresh/PullRefresh.js +2 -2
  104. package/lib/esm/components/PullRefresh/PullRefresh.js.map +1 -1
  105. package/lib/esm/components/TabBar/TabBar.js +8 -5
  106. package/lib/esm/components/TabBar/TabBar.js.map +1 -1
  107. package/lib/esm/components/TabBar/index.js +5 -2
  108. package/lib/esm/components/TabBar/index.js.map +1 -1
  109. package/lib/esm/components/TabBar/interface/index.js +1 -1
  110. package/lib/esm/components/Tabs/Tabs.js +5 -1
  111. package/lib/esm/components/Tabs/Tabs.js.map +1 -1
  112. package/lib/esm/components/Tabs/styles.js +1 -1
  113. package/lib/esm/components/Tabs/styles.js.map +1 -1
  114. package/lib/esm/components/Toast/Toast.js +2 -2
  115. package/lib/esm/components/Toast/api.js +4 -4
  116. package/lib/esm/components/Toast/index.js +4 -4
  117. package/lib/esm/index.js +2 -2
  118. package/lib/types/components/ActionSheets/test/spectrum.bench.d.ts +1 -0
  119. package/lib/types/components/Avatar/test/spectrum.bench.d.ts +1 -0
  120. package/lib/types/components/AvatarGroup/test/spectrum.bench.d.ts +1 -0
  121. package/lib/types/components/Badge/test/spectrum.bench.d.ts +1 -0
  122. package/lib/types/components/BottomBar/test/spectrum.bench.d.ts +1 -0
  123. package/lib/types/components/Button/test/spectrum.bench.d.ts +1 -0
  124. package/lib/types/components/ConfigProvider/ConfigProvider.d.ts +2 -2
  125. package/lib/types/components/ConfigProvider/hooks/ConfigCache/ConfigCache.d.ts +1 -1
  126. package/lib/types/components/ConfigProvider/hooks/ConfigCache/interface.d.ts +1 -1
  127. package/lib/types/components/ConfigProvider/interface/index.d.ts +9 -13
  128. package/lib/types/components/Divider/test/spectrum.bench.d.ts +1 -0
  129. package/lib/types/components/Empty/test/spectrum.bench.d.ts +1 -0
  130. package/lib/types/components/Image/test/spectrum.bench.d.ts +1 -0
  131. package/lib/types/components/List/test/spectrum.bench.d.ts +1 -0
  132. package/lib/types/components/NavigationBar/test/spectrum.bench.d.ts +1 -0
  133. package/lib/types/components/Picker/test/spectrum.bench.d.ts +1 -0
  134. package/lib/types/components/ProgressIndicator/test/spectrum.bench.d.ts +1 -0
  135. package/lib/types/components/PullRefresh/interface/index.d.ts +2 -2
  136. package/lib/types/components/Sheets/test/spectrum.bench.d.ts +1 -0
  137. package/lib/types/components/Silder/test/spectrum.bench.d.ts +1 -0
  138. package/lib/types/components/Skeleton/test/spectrum.bench.d.ts +1 -0
  139. package/lib/types/components/Switch/test/spectrum.bench.d.ts +1 -0
  140. package/lib/types/components/TabBar/TabBar.d.ts +1 -0
  141. package/lib/types/components/TabBar/interface/index.d.ts +3 -1
  142. package/lib/types/components/Tag/test/spectrum.bench.d.ts +1 -0
  143. package/lib/types/components/Toast/test/spectrum.bench.d.ts +1 -0
  144. package/package.json +5 -4
  145. package/src/components/ActionSheets/doc/index.mdx +7 -5
  146. package/src/components/ActionSheets/test/spectrum.bench.tsx +15 -0
  147. package/src/components/Avatar/test/spectrum.bench.tsx +13 -0
  148. package/src/components/AvatarGroup/test/spectrum.bench.tsx +30 -0
  149. package/src/components/Badge/test/spectrum.bench.tsx +13 -0
  150. package/src/components/BottomBar/test/spectrum.bench.tsx +15 -0
  151. package/src/components/Button/test/spectrum.bench.tsx +13 -0
  152. package/src/components/ConfigProvider/ConfigProvider.tsx +10 -26
  153. package/src/components/ConfigProvider/demo/base.tsx +19 -28
  154. package/src/components/ConfigProvider/doc/index.mdx +8 -8
  155. package/src/components/ConfigProvider/hooks/ConfigCache/interface.ts +1 -1
  156. package/src/components/ConfigProvider/interface/index.ts +13 -21
  157. package/src/components/ConfigProvider/test/base.tsx +17 -25
  158. package/src/components/ConfigProvider/test/index.test.tsx +62 -74
  159. package/src/components/DatePicker/doc/index.mdx +1 -5
  160. package/src/components/DatePicker/interface/index.ts +1 -3
  161. package/src/components/Divider/test/spectrum.bench.tsx +13 -0
  162. package/src/components/DropDown/doc/index.mdx +39 -0
  163. package/src/components/Empty/test/spectrum.bench.tsx +19 -0
  164. package/src/components/Icon/Icon.tsx +4 -2
  165. package/src/components/Image/test/spectrum.bench.tsx +33 -0
  166. package/src/components/List/test/spectrum.bench.tsx +15 -0
  167. package/src/components/NavigationBar/test/spectrum.bench.tsx +13 -0
  168. package/src/components/Picker/test/spectrum.bench.tsx +10 -0
  169. package/src/components/ProgressIndicator/test/spectrum.bench.tsx +13 -0
  170. package/src/components/PullRefresh/PullRefresh.tsx +2 -2
  171. package/src/components/PullRefresh/demo/index.tsx +1 -1
  172. package/src/components/PullRefresh/doc/index.mdx +10 -10
  173. package/src/components/PullRefresh/interface/index.ts +2 -2
  174. package/src/components/Sheets/test/spectrum.bench.tsx +17 -0
  175. package/src/components/Silder/test/spectrum.bench.tsx +18 -0
  176. package/src/components/Skeleton/test/spectrum.bench.tsx +25 -0
  177. package/src/components/Switch/test/spectrum.bench.tsx +14 -0
  178. package/src/components/TabBar/TabBar.tsx +4 -4
  179. package/src/components/TabBar/demo/index.tsx +6 -6
  180. package/src/components/TabBar/doc/index.mdx +9 -8
  181. package/src/components/TabBar/interface/index.ts +3 -1
  182. package/src/components/TabBar/test/index.bench.tsx +1 -1
  183. package/src/components/TabBar/test/index.test.tsx +7 -7
  184. package/src/components/Tabs/Tabs.tsx +7 -1
  185. package/src/components/Tabs/demo/index.tsx +55 -19
  186. package/src/components/Tabs/interface/index.ts +0 -1
  187. package/src/components/Tabs/styles.ts +1 -1
  188. package/src/components/Tag/test/spectrum.bench.tsx +13 -0
  189. package/src/components/Toast/test/spectrum.bench.tsx +13 -0
  190. package/vitest.config.ts +5 -0
  191. package/lib/cjs/_chunks/C61-qTj5.js.map +0 -1
  192. package/lib/cjs/_chunks/K-GkcnsQ.js.map +0 -1
  193. package/lib/esm/_chunks/DKABHJAn.js.map +0 -1
  194. package/lib/esm/_chunks/DUTFT_ka.js.map +0 -1
@@ -6,6 +6,7 @@ declare const TabBar: {
6
6
  defaultProps: {
7
7
  list: DataType[];
8
8
  type: string;
9
+ value: undefined;
9
10
  badge: boolean;
10
11
  };
11
12
  };
@@ -3,7 +3,8 @@ export interface RedsTabBar {
3
3
  list: DataType[];
4
4
  customTabBar?: DataType;
5
5
  type: "text" | "icon";
6
- activeTab: string;
6
+ active: string;
7
+ value?: boolean;
7
8
  badge?: boolean;
8
9
  containerStyles?: any;
9
10
  onChange?: (value: string) => any;
@@ -30,5 +31,6 @@ export interface RedsTabBarEvent {
30
31
  export declare const TabBarDefaultProps: {
31
32
  list: DataType[];
32
33
  type: string;
34
+ value: undefined;
33
35
  badge: boolean;
34
36
  };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@xhsreds/reds-rn-next",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "author": "贾斌(呀哈) <jiabin@xiaohongshu.com>",
5
5
  "license": "ISC",
6
6
  "dependencies": {
7
7
  "@floating-ui/react-native": "~0.10.6",
8
8
  "dayjs": "^1.10.7",
9
- "@xhsreds/reds-token-next": "0.1.4"
9
+ "@xhsreds/reds-token-next": "0.1.5"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "@xhs/reder-icon-svg": "~1.0.1",
@@ -15,9 +15,10 @@
15
15
  "react-native-svg": "*"
16
16
  },
17
17
  "devDependencies": {
18
- "react-native": "0.72.5",
19
18
  "react": "~18.2.0",
20
- "react-native-svg": "~15.4.0"
19
+ "react-native": "0.72.5",
20
+ "react-native-svg": "~15.4.0",
21
+ "@xhs/spectrum": "1.2.4-feat-support-0.72-alpha.23"
21
22
  },
22
23
  "module": "./lib/esm/index.js",
23
24
  "main": "./lib/cjs/index.js",
@@ -1,5 +1,7 @@
1
1
  import BaseDemo from "!!raw-loader!../demo/index.tsx";
2
2
 
3
+ ActionSheets size属性继承自sheets组件 容器高度由sheets内部容器高度撑开
4
+
3
5
  ## 演示
4
6
 
5
7
  ### 基础用法
@@ -10,11 +12,11 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
10
12
 
11
13
  ### Props
12
14
 
13
- | 属性 | 描述 | 类型 | 默认值 |
14
- | ----------- | ------------ | ------------ | ------ |
15
- | data | 列表数据 | ActionItem[] | `[]` |
16
- | description | 描述 | string | |
17
- | visible | 是否展示列表 | boolean | false |
15
+ | 属性 | 描述 | 类型 | 默认值 |
16
+ | ----------- | -------------------- | ------------ | ------ |
17
+ | data | ActionSheets列表数据 | ActionItem[] | `[]` |
18
+ | description | 描述 | string | |
19
+ | visible | 是否展示列表 | boolean | false |
18
20
 
19
21
  ### Events
20
22
 
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { describe } from "vitest";
3
+ // @ts-ignore
4
+ import { redsBench } from "~root/utils/redsBench";
5
+ import { ActionSheet2 } from "@xhs/spectrum";
6
+ import { render, fireEvent } from "@testing-library/react-native";
7
+ import { Text } from "react-native";
8
+
9
+ describe("render", () => {
10
+ redsBench("base", async () => {
11
+ ActionSheet2.show({
12
+ options: [{ text: "操作按钮" }, { text: "操作按钮" }, { text: "操作按钮" }],
13
+ });
14
+ });
15
+ });
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { describe } from "vitest";
3
+ // @ts-ignore
4
+ import { redsBench } from "~root/utils/redsBench";
5
+ import { Avatar } from "@xhs/spectrum";
6
+ import { render, fireEvent } from "@testing-library/react-native";
7
+ import { Text } from "react-native";
8
+
9
+ describe("render", () => {
10
+ redsBench("base", async () => {
11
+ render(<Avatar type={"default"} size={48} style={{ marginHorizontal: 20 }} />);
12
+ });
13
+ });
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { describe } from "vitest";
3
+ // @ts-ignore
4
+ import { redsBench } from "~root/utils/redsBench";
5
+ import { AvatarGroup } from "@xhs/spectrum";
6
+ import { render, fireEvent } from "@testing-library/react-native";
7
+ import { Text } from "react-native";
8
+
9
+ describe("render", () => {
10
+ const imgs = [
11
+ {
12
+ uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
13
+ },
14
+ {
15
+ uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
16
+ },
17
+ {
18
+ uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
19
+ },
20
+ {
21
+ uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
22
+ },
23
+ {
24
+ uri: "https://picasso-static.xiaohongshu.com/fe-platform/81bb94fcff424f3ca02d620e7460d5a8315b0158.png",
25
+ },
26
+ ];
27
+ redsBench("base", async () => {
28
+ render(<AvatarGroup num={5} size={28} style={{ marginVertical: 8 }} src={imgs}></AvatarGroup>);
29
+ });
30
+ });
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { describe } from "vitest";
3
+ // @ts-ignore
4
+ import { redsBench } from "~root/utils/redsBench";
5
+ import { Badge } from "@xhs/spectrum";
6
+ import { render, fireEvent } from "@testing-library/react-native";
7
+ import { Text } from "react-native";
8
+
9
+ describe("render", () => {
10
+ redsBench("base", async () => {
11
+ render(<Badge mt={-4} mr={-4} />);
12
+ });
13
+ });
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { describe } from "vitest";
3
+ // @ts-ignore
4
+ import { redsBench } from "~root/utils/redsBench";
5
+ import { BottomBar } from "@xhs/spectrum";
6
+ import { render, fireEvent } from "@testing-library/react-native";
7
+ import { Text } from "react-native";
8
+ const handleClick = () => {
9
+ console.log("按钮点击");
10
+ };
11
+ describe("render", () => {
12
+ redsBench("base", async () => {
13
+ render(<BottomBar text="按钮" onPress={handleClick} />);
14
+ });
15
+ });
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { describe } from "vitest";
3
+ // @ts-ignore
4
+ import { redsBench } from "~root/utils/redsBench";
5
+ import { Button } from "@xhs/spectrum";
6
+ import { render, fireEvent } from "@testing-library/react-native";
7
+ import { Text } from "react-native";
8
+
9
+ describe("render", () => {
10
+ redsBench("base", async () => {
11
+ render(<Button>主按钮</Button>);
12
+ });
13
+ });
@@ -1,36 +1,20 @@
1
- import { ConfigProviderProps } from "./interface";
1
+ import { ConfigProviderProps, RedsConfigProvider } from "./interface";
2
2
  import { configCache } from "./hooks/ConfigCache/ConfigCache";
3
3
  import { ConfigProviderContext, IConfigProviderContext } from "./hooks/ConfigContext/ConfigContext";
4
- import React from "react";
4
+ import React, { ReactNode } from "react";
5
5
 
6
- const ConfigProvider: React.FC<ConfigProviderProps> = (props: ConfigProviderProps) => {
7
- const {
8
- id = "root",
9
- theme = {
10
- colorMode: "light",
11
- inherit: true,
12
- },
13
- parentId = "root",
14
- children,
15
- } = props;
6
+ const ConfigProvider: React.FC<RedsConfigProvider> = (props: RedsConfigProvider) => {
7
+ const { id = "root", token = {}, parentId = "root", colorMode = "light", children, inherit = true } = props;
16
8
 
17
9
  const themeCache = {
18
- colorMode: theme.colorMode || "light",
10
+ colorMode: colorMode || "light",
19
11
  token: {
20
- lightColor: {
21
- ...theme.token?.lightColor,
22
- },
23
- darkColor: {
24
- ...theme.token?.darkColor,
25
- },
26
- alwaysColor: {
27
- ...theme.token?.alwaysColor,
28
- },
29
- components: {
30
- ...theme.token?.components,
31
- },
12
+ lightColor: token?.lightColor ?? {},
13
+ darkColor: token?.darkColor ?? {},
14
+ alwaysColor: token?.alwaysColor ?? {},
15
+ components: token?.components ?? {},
32
16
  },
33
- inherit: theme.inherit,
17
+ inherit: inherit,
34
18
  };
35
19
 
36
20
  configCache.addNewConfigCache({
@@ -40,10 +40,10 @@ export default () => {
40
40
  // 主题定制
41
41
  const [colorMode2, setColorMode2] = useState<ColorMode>("light");
42
42
  const [infoLightColor, setInfoLightColor] = useState<string>("red");
43
- const [infoDarkColor, setInfoDarkColor] = useState<string>("black");
43
+ const [infoDarkColor, setInfoDarkColor] = useState<string>("yellow");
44
44
  const changeInfoToken = () => {
45
45
  setInfoLightColor((preInfoLightColor) => (preInfoLightColor === "red" ? "blue" : "red"));
46
- setInfoDarkColor((preInfoDarkColor) => (preInfoDarkColor === "black" ? "white" : "black"));
46
+ setInfoDarkColor((preInfoDarkColor) => (preInfoDarkColor === "yellow" ? "white" : "yellow"));
47
47
  };
48
48
  const changeColorMode2 = () => {
49
49
  setColorMode2((preColorMode) => (preColorMode === "light" ? "dark" : "light"));
@@ -66,12 +66,7 @@ export default () => {
66
66
  <TouchableOpacity onPress={changeColorMode}>
67
67
  <Text>切换主题</Text>
68
68
  </TouchableOpacity>
69
- <ConfigProvider
70
- id="1"
71
- theme={{
72
- colorMode: colorMode,
73
- }}
74
- >
69
+ <ConfigProvider id="1" colorMode={colorMode}>
75
70
  <App />
76
71
  </ConfigProvider>
77
72
  <TouchableOpacity onPress={changeColorMode2}>
@@ -82,15 +77,13 @@ export default () => {
82
77
  </TouchableOpacity>
83
78
  <ConfigProvider
84
79
  id="2"
85
- theme={{
86
- colorMode: colorMode2,
87
- token: {
88
- lightColor: {
89
- Info: infoLightColor,
90
- },
91
- darkColor: {
92
- Info: infoDarkColor,
93
- },
80
+ colorMode={colorMode2}
81
+ token={{
82
+ lightColor: {
83
+ Info: infoLightColor,
84
+ },
85
+ darkColor: {
86
+ Info: infoDarkColor,
94
87
  },
95
88
  }}
96
89
  >
@@ -104,17 +97,15 @@ export default () => {
104
97
  </TouchableOpacity>
105
98
  <ConfigProvider
106
99
  id="3"
107
- theme={{
108
- colorMode: colorMode3,
109
- token: {
110
- components: {
111
- Button: {
112
- lightColor: {
113
- Info: infoLightColor3,
114
- },
115
- darkColor: {
116
- Info: infoDarkColor3,
117
- },
100
+ colorMode={colorMode3}
101
+ token={{
102
+ components: {
103
+ Button: {
104
+ lightColor: {
105
+ Info: infoLightColor3,
106
+ },
107
+ darkColor: {
108
+ Info: infoDarkColor3,
118
109
  },
119
110
  },
120
111
  },
@@ -10,13 +10,13 @@ import BaseDemo from "!!raw-loader!../demo/base.tsx";
10
10
 
11
11
  ### Props
12
12
 
13
- | 属性 | 描述 | 类型 | 默认值 |
14
- | --------- | ------------------------------- | ------------ | ------------------------------------------------------------------------------------------------ |
15
- | id | 主题 ID | string | root |
16
- | parentId | 父级主题 ID | string | root |
17
- | theme | 主题定制 | IThemeConfig | `{"colorMode":"light","inherit":true,"token":{"lightColor":{},"darkColor":{},"alwaysColor":{}}}` |
18
- | colorMode | IThemeConfig colorMode 主题模式 | string | light |
19
- | inherit | IThemeConfig inherit Token 继承 | boolean | true |
20
- | token | IThemeConfig token Token 定制 | Object | `{}` |
13
+ | 属性 | 描述 | 类型 | 默认值 |
14
+ | --------- | ------------------------------- | ----------- | ------ |
15
+ | id | 主题 ID | string | root |
16
+ | parentId | 父级主题 ID | string | root |
17
+ | colorMode | IThemeConfig colorMode 主题模式 | string | light |
18
+ | inherit | IThemeConfig inherit Token 继承 | boolean | true |
19
+ | token | IThemeConfig token Token 定制 | IThemeToken | |
20
+ | children | 主题包裹组件 | ReactNode | |
21
21
 
22
22
  ### Events
@@ -8,7 +8,7 @@ export type TypographyToken = keyof typeof typography;
8
8
 
9
9
  export type ThemeColor = { [key in LightToken | DarkToken]: ValueOf<typeof lightColor | typeof darkColor> };
10
10
 
11
- export type ColorMode = "light" | "dark";
11
+ export type ColorMode = "light" | "dark" | string;
12
12
  export type Component =
13
13
  | "Button"
14
14
  | "Popover"
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from "react";
1
2
  type ColorMode = "light" | "dark";
2
3
  type Component = "Button" | "Popover" | "Text" | "Tag" | "Switch" | "Toast";
3
4
 
@@ -26,45 +27,36 @@ export interface ConfigProviderProps {
26
27
  theme?: IThemeConfig;
27
28
  parentId?: string;
28
29
  }
30
+ export interface IThemeToken {
31
+ lightColor?: Record<string, string>;
32
+ darkColor?: Record<string, string>;
33
+ alwaysColor?: Record<string, string>;
34
+ components?: ComponentsToken;
35
+ }
29
36
  export interface RedsConfigProvider {
30
37
  id?: string;
31
38
  parentId?: string;
32
- theme?: IThemeConfig;
33
39
  colorMode?: string;
34
40
  inherit?: boolean;
35
- token: Object;
41
+ token?: IThemeToken;
42
+ children?: ReactNode;
36
43
  }
37
44
 
38
45
  export interface RedsConfigProviderEvent {}
39
46
  export const defaultProps: RedsConfigProvider = {
40
47
  id: "root",
41
48
  parentId: "root",
42
- theme: {
43
- colorMode: "light",
44
- inherit: true,
45
- token: {
46
- lightColor: {},
47
- darkColor: {},
48
- alwaysColor: {},
49
- },
49
+ token: {
50
+ lightColor: {},
51
+ darkColor: {},
52
+ alwaysColor: {},
50
53
  },
51
54
  colorMode: "light",
52
55
  inherit: true,
53
- token: {},
54
56
  };
55
57
  export const ConfigProviderDefaultProps = {
56
58
  id: "root",
57
59
  parentId: "root",
58
- theme: {
59
- colorMode: "light",
60
- inherit: true,
61
- token: {
62
- lightColor: {},
63
- darkColor: {},
64
- alwaysColor: {},
65
- },
66
- },
67
60
  colorMode: "light",
68
61
  inherit: true,
69
- token: {},
70
62
  };
@@ -73,11 +73,7 @@ export default () => {
73
73
  <TouchableOpacity testID={"themeChangeButton"} onPress={changeColorMode}>
74
74
  <Text>切换主题</Text>
75
75
  </TouchableOpacity>
76
- <ConfigProvider
77
- theme={{
78
- colorMode: colorMode,
79
- }}
80
- >
76
+ <ConfigProvider colorMode={colorMode}>
81
77
  <App />
82
78
  </ConfigProvider>
83
79
  <TouchableOpacity testID={"themeChangeCustomButton"} onPress={changeColorMode2}>
@@ -87,15 +83,13 @@ export default () => {
87
83
  <Text>主题定制</Text>
88
84
  </TouchableOpacity>
89
85
  <ConfigProvider
90
- theme={{
91
- colorMode: colorMode2,
92
- token: {
93
- lightColor: {
94
- Info: infoLightColor,
95
- },
96
- darkColor: {
97
- Info: infoDarkColor,
98
- },
86
+ colorMode={colorMode2}
87
+ token={{
88
+ lightColor: {
89
+ Info: infoLightColor,
90
+ },
91
+ darkColor: {
92
+ Info: infoDarkColor,
99
93
  },
100
94
  }}
101
95
  >
@@ -108,17 +102,15 @@ export default () => {
108
102
  <Text>组件级主题切换</Text>
109
103
  </TouchableOpacity>
110
104
  <ConfigProvider
111
- theme={{
112
- colorMode: colorMode3,
113
- token: {
114
- components: {
115
- Button: {
116
- lightColor: {
117
- Info: infoLightColor3,
118
- },
119
- darkColor: {
120
- Info: infoDarkColor3,
121
- },
105
+ colorMode={colorMode3}
106
+ token={{
107
+ components: {
108
+ Button: {
109
+ lightColor: {
110
+ Info: infoLightColor3,
111
+ },
112
+ darkColor: {
113
+ Info: infoDarkColor3,
122
114
  },
123
115
  },
124
116
  },