@xhsreds/reds-rn-next 0.0.3 → 0.0.4
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/coverage/coverage-final.json +13 -13
- package/lib/cjs/components/Button/interface/index.js +0 -2
- package/lib/cjs/components/Button/interface/index.js.map +1 -1
- package/lib/cjs/components/ConfigProvider/hooks/themeToken/useThemeToken.js +9 -1
- package/lib/cjs/components/ConfigProvider/hooks/themeToken/useThemeToken.js.map +1 -1
- package/lib/cjs/components/ConfigProvider/interface/index.js +18 -0
- package/lib/cjs/components/ConfigProvider/interface/index.js.map +1 -1
- package/lib/cjs/components/{Bu → NN}/index.js +6 -6
- package/lib/cjs/components/{Bu → NN}/index.js.map +1 -1
- package/lib/cjs/components/{Bu → NN}/interface/index.js +0 -2
- package/lib/cjs/components/NN/interface/index.js.map +1 -0
- package/lib/cjs/components/NNNN/index.js +83 -0
- package/lib/cjs/components/NNNN/index.js.map +1 -0
- package/lib/cjs/components/NNNN/interface/index.js +13 -0
- package/lib/cjs/components/NNNN/interface/index.js.map +1 -0
- package/lib/cjs/components/PP/index.js +83 -0
- package/lib/cjs/components/PP/index.js.map +1 -0
- package/lib/cjs/components/PP/interface/index.js +14 -0
- package/lib/cjs/components/PP/interface/index.js.map +1 -0
- package/lib/cjs/components/Popover/interface/index.js +12 -0
- package/lib/cjs/components/Popover/interface/index.js.map +1 -1
- package/lib/cjs/components/Switch/index.js.map +1 -1
- package/lib/cjs/components/Switch/interface/index.js +1 -2
- package/lib/cjs/components/Switch/interface/index.js.map +1 -1
- package/lib/cjs/index.js +1 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/_chunks/{Djn5ftvm.js → BHmvJnIm.js} +2 -2
- package/lib/esm/_chunks/{Djn5ftvm.js.map → BHmvJnIm.js.map} +1 -1
- package/lib/esm/_chunks/{npmn1D5V.js → Br6Ked0G.js} +2 -2
- package/lib/esm/_chunks/{npmn1D5V.js.map → Br6Ked0G.js.map} +1 -1
- package/lib/esm/components/Button/index.js +1 -1
- package/lib/esm/components/Button/interface/index.js +0 -2
- package/lib/esm/components/Button/interface/index.js.map +1 -1
- package/lib/esm/components/ConfigProvider/ConfigProvider.js +2 -2
- package/lib/esm/components/ConfigProvider/hooks/ConfigCache/ConfigCache.js +1 -1
- package/lib/esm/components/ConfigProvider/hooks/ConfigCache/index.js +1 -1
- package/lib/esm/components/ConfigProvider/hooks/themeToken/useThemeToken.js +10 -2
- package/lib/esm/components/ConfigProvider/hooks/themeToken/useThemeToken.js.map +1 -1
- package/lib/esm/components/ConfigProvider/index.js +2 -2
- package/lib/esm/components/ConfigProvider/interface/index.js +17 -0
- package/lib/esm/components/ConfigProvider/interface/index.js.map +1 -1
- package/lib/esm/components/{Bu → NN}/index.js +6 -6
- package/lib/esm/components/{Bu → NN}/index.js.map +1 -1
- package/lib/esm/components/{Bu → NN}/interface/index.js +0 -2
- package/lib/esm/components/NN/interface/index.js.map +1 -0
- package/lib/esm/components/NNNN/index.js +79 -0
- package/lib/esm/components/NNNN/index.js.map +1 -0
- package/lib/esm/components/NNNN/interface/index.js +11 -0
- package/lib/esm/components/NNNN/interface/index.js.map +1 -0
- package/lib/esm/components/PP/index.js +79 -0
- package/lib/esm/components/PP/index.js.map +1 -0
- package/lib/esm/components/PP/interface/index.js +12 -0
- package/lib/esm/components/PP/interface/index.js.map +1 -0
- package/lib/esm/components/Popover/component.js +1 -1
- package/lib/esm/components/Popover/hook.js +1 -1
- package/lib/esm/components/Popover/index.js +1 -1
- package/lib/esm/components/Popover/interface/index.js +11 -0
- package/lib/esm/components/Popover/interface/index.js.map +1 -1
- package/lib/esm/components/Switch/index.js +1 -1
- package/lib/esm/components/Switch/index.js.map +1 -1
- package/lib/esm/components/Switch/interface/index.js +1 -2
- package/lib/esm/components/Switch/interface/index.js.map +1 -1
- package/lib/esm/index.js +3 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/types/src/components/Button/interface/index.d.ts +2 -3
- package/lib/types/src/components/ConfigProvider/hooks/themeToken/useThemeToken.d.ts +1 -1
- package/lib/types/src/components/ConfigProvider/interface/index.d.ts +11 -0
- package/lib/types/src/components/NN/index.d.ts +7 -0
- package/lib/types/src/components/NN/interface/index.d.ts +10 -0
- package/lib/types/src/components/NNNN/index.d.ts +7 -0
- package/lib/types/src/components/NNNN/interface/index.d.ts +10 -0
- package/lib/types/src/components/PP/index.d.ts +7 -0
- package/lib/types/src/components/{Bu → PP}/interface/index.d.ts +4 -4
- package/lib/types/src/components/Popover/interface/index.d.ts +7 -3
- package/lib/types/src/components/Switch/interface/index.d.ts +4 -2
- package/lib/types/src/index.d.ts +1 -2
- package/package.json +2 -2
- package/src/components/Button/doc/index.mdx +7 -7
- package/src/components/Button/interface/index.ts +2 -5
- package/src/components/ConfigProvider/doc/index.mdx +1 -1
- package/src/components/ConfigProvider/hooks/themeToken/useThemeToken.ts +10 -1
- package/src/components/ConfigProvider/interface/index.ts +26 -0
- package/src/components/Popover/doc/index.mdx +15 -14
- package/src/components/Popover/interface/index.ts +16 -4
- package/src/components/Switch/doc/index.mdx +11 -11
- package/src/components/Switch/index.tsx +0 -1
- package/src/components/Switch/interface/index.ts +5 -5
- package/src/index.ts +1 -2
- package/lib/cjs/components/Bu/interface/index.js.map +0 -1
- package/lib/esm/components/Bu/interface/index.js.map +0 -1
- package/lib/types/src/components/Bu/index.d.ts +0 -7
- package/src/components/Bu/demo/index.tsx +0 -50
- package/src/components/Bu/doc/index.mdx +0 -26
- package/src/components/Bu/index.tsx +0 -60
- package/src/components/Bu/interface/index.ts +0 -21
- package/src/components/Bu/test/index.bench.tsx +0 -12
- package/src/components/Bu/test/index.test.tsx +0 -18
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
2
|
export interface RedsPopover {
|
|
4
3
|
visible?: boolean;
|
|
5
4
|
placement?: "top" | "bottom";
|
|
6
5
|
content?: string;
|
|
7
6
|
opacity?: number;
|
|
8
7
|
mode?: "light" | "dark";
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
closeOnClickAgain?: boolean;
|
|
11
8
|
trigger?: "click" | "touch";
|
|
12
9
|
zIndex?: number;
|
|
13
|
-
|
|
10
|
+
closeOnClickAgain?: boolean;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
onClickMask?: (evnet: Event) => void;
|
|
13
|
+
onVisibleChange?: (value: boolean) => void;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
export interface RedsPopoverEvent {}
|
|
17
|
+
export const defaultProps: RedsPopover = {
|
|
18
|
+
visible: undefined,
|
|
19
|
+
placement: "top",
|
|
20
|
+
content: "",
|
|
21
|
+
opacity: 0,
|
|
22
|
+
mode: "light",
|
|
23
|
+
trigger: "click",
|
|
24
|
+
zIndex: 1000,
|
|
25
|
+
closeOnClickAgain: true,
|
|
26
|
+
};
|
|
@@ -8,17 +8,17 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
|
8
8
|
|
|
9
9
|
### Props
|
|
10
10
|
|
|
11
|
-
| 属性 | 描述 | 类型 | 默认值
|
|
12
|
-
| --------------- | ---------------- | ------- |
|
|
13
|
-
| value | 当前的状态 | boolean |
|
|
14
|
-
| default-value | 默认状态 | boolean | false
|
|
15
|
-
| disabled | 是否显示气泡 | boolean | false
|
|
16
|
-
| track-on-color | 开关开启时的颜色 | string |
|
|
17
|
-
| track-off-color | 开关关闭时的颜色 | string |
|
|
11
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
12
|
+
| --------------- | ---------------- | ------- | ------------------ |
|
|
13
|
+
| value | 当前的状态 | boolean | undefined |
|
|
14
|
+
| default-value | 默认状态 | boolean | false |
|
|
15
|
+
| disabled | 是否显示气泡 | boolean | false |
|
|
16
|
+
| track-on-color | 开关开启时的颜色 | string | lightColor.Primary |
|
|
17
|
+
| track-off-color | 开关关闭时的颜色 | string | lightColor.Fill2 |
|
|
18
18
|
|
|
19
19
|
### Events
|
|
20
20
|
|
|
21
|
-
| 事件 | 描述 | 类型
|
|
22
|
-
| ------ | ------------------ |
|
|
23
|
-
| change | 当值发生变化时触发 | (value: boolean) => void
|
|
24
|
-
| click | 被点击时触发 | (value:
|
|
21
|
+
| 事件 | 描述 | 类型 | 默认值 |
|
|
22
|
+
| ------ | ------------------ | -------------------------------------- | ------ |
|
|
23
|
+
| change | 当值发生变化时触发 | (value: boolean) => void | |
|
|
24
|
+
| click | 被点击时触发 | (value: GestureResponderEvent) => void | |
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { GestureResponderEvent } from "react-native";
|
|
2
2
|
import { lightColor } from "@xhs/reds-token-next";
|
|
3
|
-
|
|
4
3
|
export interface RedsSwitch {
|
|
5
4
|
value?: boolean;
|
|
6
5
|
defaultValue?: boolean;
|
|
7
6
|
disabled?: boolean;
|
|
8
|
-
onClick?: (event: GestureResponderEvent) => void;
|
|
9
|
-
onChange?: (value: boolean) => void;
|
|
10
7
|
trackOnColor?: string;
|
|
11
8
|
trackOffColor?: string;
|
|
9
|
+
onChange?: (value: boolean) => void;
|
|
10
|
+
onClick?: (value: GestureResponderEvent) => void;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export const defaultProps: RedsSwitch = {
|
|
14
|
+
value: undefined,
|
|
15
15
|
defaultValue: false,
|
|
16
16
|
disabled: false,
|
|
17
|
-
onClick: (event: GestureResponderEvent) => {},
|
|
18
|
-
onChange: (value: boolean) => {},
|
|
19
17
|
trackOnColor: lightColor.Primary,
|
|
20
18
|
trackOffColor: lightColor.Fill2,
|
|
21
19
|
};
|
|
20
|
+
|
|
21
|
+
export interface RedsSwitchEvent {}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Bu from "./components/Bu";
|
|
2
1
|
import Button from "./components/Button";
|
|
3
2
|
import Popover from "./components/Popover";
|
|
4
3
|
import Switch from "./components/Switch";
|
|
5
4
|
import ConfigProvider, { useThemeColor } from "./components/ConfigProvider";
|
|
6
|
-
export { Button, Popover, Switch, ConfigProvider, useThemeColor
|
|
5
|
+
export { Button, Popover, Switch, ConfigProvider, useThemeColor };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/Bu/interface/index.ts"],"sourcesContent":["import { GestureResponderEvent } from \"react-native\";\nimport { lightColor } from \"@xhs/reds-token-next\";\n\nexport interface RedsBu {\n value?: boolean;\n defaultValue?: boolean;\n disabled?: boolean;\n onClick?: (event: GestureResponderEvent) => void;\n onChange?: (value: boolean) => void;\n trackOnColor?: string;\n trackOffColor?: string;\n}\n\nexport const defaultProps: RedsBu = {\n defaultValue: false,\n disabled: false,\n onClick: (event: GestureResponderEvent) => {},\n onChange: (value: boolean) => {},\n trackOnColor: lightColor.Primary,\n trackOffColor: lightColor.Fill2,\n};\n"],"names":["defaultProps","defaultValue","disabled","onClick","event","onChange","value","trackOnColor","lightColor","Primary","trackOffColor","Fill2"],"mappings":";;;;AAaO,IAAMA,YAAuB,GAAA;AAClCC,EAAAA,YAAc,EAAA,KAAA;AACdC,EAAAA,QAAU,EAAA,KAAA;AACVC,EAAAA,OAAA,EAAS,SAAAA,OAAAA,CAACC,KAAiC,EAAA,EAAC;AAC5CC,EAAAA,QAAA,EAAU,SAAAA,QAAAA,CAACC,KAAmB,EAAA,EAAC;EAC/BC,cAAcC,wBAAW,CAAAC,OAAA;EACzBC,eAAeF,wBAAW,CAAAG,KAAAA;AAC5B;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/Bu/interface/index.ts"],"sourcesContent":["import { GestureResponderEvent } from \"react-native\";\nimport { lightColor } from \"@xhs/reds-token-next\";\n\nexport interface RedsBu {\n value?: boolean;\n defaultValue?: boolean;\n disabled?: boolean;\n onClick?: (event: GestureResponderEvent) => void;\n onChange?: (value: boolean) => void;\n trackOnColor?: string;\n trackOffColor?: string;\n}\n\nexport const defaultProps: RedsBu = {\n defaultValue: false,\n disabled: false,\n onClick: (event: GestureResponderEvent) => {},\n onChange: (value: boolean) => {},\n trackOnColor: lightColor.Primary,\n trackOffColor: lightColor.Fill2,\n};\n"],"names":["defaultProps","defaultValue","disabled","onClick","event","onChange","value","trackOnColor","lightColor","Primary","trackOffColor","Fill2"],"mappings":";;AAaO,IAAMA,YAAuB,GAAA;AAClCC,EAAAA,YAAc,EAAA,KAAA;AACdC,EAAAA,QAAU,EAAA,KAAA;AACVC,EAAAA,OAAA,EAAS,SAAAA,OAAAA,CAACC,KAAiC,EAAA,EAAC;AAC5CC,EAAAA,QAAA,EAAU,SAAAA,QAAAA,CAACC,KAAmB,EAAA,EAAC;EAC/BC,cAAcC,UAAW,CAAAC,OAAA;EACzBC,eAAeF,UAAW,CAAAG,KAAAA;AAC5B;;;;"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useState } from "react";
|
|
2
|
-
import { View, Text, StyleSheet, FlatList, ScrollView } from "react-native";
|
|
3
|
-
import { Bu } from "@xhs/reds-rn-next";
|
|
4
|
-
|
|
5
|
-
const styles = StyleSheet.create({
|
|
6
|
-
container: {
|
|
7
|
-
flex: 1,
|
|
8
|
-
justifyContent: "center",
|
|
9
|
-
paddingTop: 100,
|
|
10
|
-
paddingBottom: 100,
|
|
11
|
-
},
|
|
12
|
-
scrollView: {
|
|
13
|
-
backgroundColor: "pink",
|
|
14
|
-
},
|
|
15
|
-
root: {
|
|
16
|
-
flex: 1,
|
|
17
|
-
backgroundColor: "blue",
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
const Desc = ({ children = "" }) => {
|
|
21
|
-
return <Text>{children}</Text>;
|
|
22
|
-
};
|
|
23
|
-
const Br = (props: { height?: any }) => <View style={{ height: props.height || 20 }}></View>;
|
|
24
|
-
|
|
25
|
-
export default function App() {
|
|
26
|
-
const [value, setValue] = useState(false);
|
|
27
|
-
const [valueStr, setValueStr] = useState(value.toString());
|
|
28
|
-
const onClick = (e) => setValue((v) => !v);
|
|
29
|
-
const onChange = (v) => setValueStr(v.toString());
|
|
30
|
-
return (
|
|
31
|
-
<View style={styles.container}>
|
|
32
|
-
<Desc>默认用法</Desc>
|
|
33
|
-
<Bu></Bu>
|
|
34
|
-
<Br />
|
|
35
|
-
|
|
36
|
-
<Desc>设置默认值</Desc>
|
|
37
|
-
<Bu defaultValue={true}></Bu>
|
|
38
|
-
<Br />
|
|
39
|
-
|
|
40
|
-
<Desc>修改开关颜色</Desc>
|
|
41
|
-
<Bu trackOnColor={"#1b8bcd"} trackOffColor={"#da36c9"}></Bu>
|
|
42
|
-
<Br />
|
|
43
|
-
|
|
44
|
-
<Desc>受控用法</Desc>
|
|
45
|
-
<Text>当前值:{valueStr}</Text>
|
|
46
|
-
<Bu value={value} onClick={onClick} onChange={onChange}></Bu>
|
|
47
|
-
<Br />
|
|
48
|
-
</View>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
2
|
-
|
|
3
|
-
## 演示
|
|
4
|
-
|
|
5
|
-
### 基础用法
|
|
6
|
-
|
|
7
|
-
::BaseDemo::
|
|
8
|
-
|
|
9
|
-
## API
|
|
10
|
-
|
|
11
|
-
### Props
|
|
12
|
-
|
|
13
|
-
| 属性 | 描述 | 类型 | 默认值 |
|
|
14
|
-
| --------------- | ---------------- | ------- | --------------------- |
|
|
15
|
-
| value | 当前的状态 | boolean | |
|
|
16
|
-
| default-value | 默认状态 | boolean | false |
|
|
17
|
-
| disabled | 是否显示气泡 | boolean | false |
|
|
18
|
-
| track-on-color | 开关开启时的颜色 | string | rgba(255, 36, 66, 1) |
|
|
19
|
-
| track-off-color | 开关关闭时的颜色 | string | rgba(48, 48, 52, 0.1) |
|
|
20
|
-
|
|
21
|
-
### Events
|
|
22
|
-
|
|
23
|
-
| 事件 | 描述 | 类型 | 默认值 |
|
|
24
|
-
| ------ | ------------------ | ------------------------ | ------ |
|
|
25
|
-
| change | 当值发生变化时触发 | (value: boolean) => void | |
|
|
26
|
-
| click | 被点击时触发 | (value: Event) => void | |
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useMemo } from "react";
|
|
2
|
-
import { View, TouchableWithoutFeedback, StyleSheet, Animated, GestureResponderEvent } from "react-native";
|
|
3
|
-
import { RedsBu, defaultProps } from "./interface/index";
|
|
4
|
-
import { alwaysColor } from "@xhs/reds-token-next";
|
|
5
|
-
|
|
6
|
-
const Bu = ({ value: cValue, defaultValue, onChange, onClick, trackOnColor, trackOffColor }: RedsBu) => {
|
|
7
|
-
const isControlled = cValue !== undefined;
|
|
8
|
-
const [value, setValue] = useState(defaultValue);
|
|
9
|
-
|
|
10
|
-
const animatedValue = useRef(new Animated.Value(defaultValue ? 18 : 2)).current;
|
|
11
|
-
|
|
12
|
-
const thumbTranslateX = useMemo(() => animatedValue.interpolate({ inputRange: [2, 18], outputRange: [2, 18] }), []);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
isControlled && setValue(cValue);
|
|
16
|
-
onChange?.(!!value);
|
|
17
|
-
Animated.timing(animatedValue, {
|
|
18
|
-
toValue: value ? 18 : 2,
|
|
19
|
-
duration: 200,
|
|
20
|
-
useNativeDriver: true,
|
|
21
|
-
}).start();
|
|
22
|
-
}, [value, cValue]);
|
|
23
|
-
|
|
24
|
-
const toggleBu = (e: GestureResponderEvent) => {
|
|
25
|
-
onClick?.(e);
|
|
26
|
-
!isControlled && setValue((v) => !v);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<TouchableWithoutFeedback onPress={(e) => toggleBu(e)}>
|
|
31
|
-
<View style={[styles.container, { backgroundColor: value ? trackOnColor : trackOffColor }]}>
|
|
32
|
-
<Animated.View style={[styles.thumb, { transform: [{ translateX: thumbTranslateX }] }]}></Animated.View>
|
|
33
|
-
</View>
|
|
34
|
-
</TouchableWithoutFeedback>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
Bu.defaultProps = defaultProps;
|
|
39
|
-
|
|
40
|
-
const styles = StyleSheet.create({
|
|
41
|
-
container: {
|
|
42
|
-
width: 40,
|
|
43
|
-
height: 24,
|
|
44
|
-
borderRadius: 15,
|
|
45
|
-
justifyContent: "center",
|
|
46
|
-
alignItems: "center",
|
|
47
|
-
},
|
|
48
|
-
thumb: {
|
|
49
|
-
width: 20,
|
|
50
|
-
height: 20,
|
|
51
|
-
borderRadius: 10,
|
|
52
|
-
backgroundColor: alwaysColor.White,
|
|
53
|
-
justifyContent: "center",
|
|
54
|
-
alignItems: "center",
|
|
55
|
-
position: "absolute",
|
|
56
|
-
left: 0,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export default Bu;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { GestureResponderEvent } from "react-native";
|
|
2
|
-
import { lightColor } from "@xhs/reds-token-next";
|
|
3
|
-
|
|
4
|
-
export interface RedsBu {
|
|
5
|
-
value?: boolean;
|
|
6
|
-
defaultValue?: boolean;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
onClick?: (event: GestureResponderEvent) => void;
|
|
9
|
-
onChange?: (value: boolean) => void;
|
|
10
|
-
trackOnColor?: string;
|
|
11
|
-
trackOffColor?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const defaultProps: RedsBu = {
|
|
15
|
-
defaultValue: false,
|
|
16
|
-
disabled: false,
|
|
17
|
-
onClick: (event: GestureResponderEvent) => {},
|
|
18
|
-
onChange: (value: boolean) => {},
|
|
19
|
-
trackOnColor: lightColor.Primary,
|
|
20
|
-
trackOffColor: lightColor.Fill2,
|
|
21
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { describe } from "vitest";
|
|
3
|
-
import { redsBench } from "~root/utils/redsBench";
|
|
4
|
-
import { Bu } from "@xhs/reds-rn-next";
|
|
5
|
-
import { render, fireEvent } from "@testing-library/react-native";
|
|
6
|
-
import { Text } from "react-native";
|
|
7
|
-
|
|
8
|
-
describe("render", () => {
|
|
9
|
-
redsBench("base", async () => {
|
|
10
|
-
render(<Bu></Bu>);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { render, fireEvent, userEvent } from "@testing-library/react-native";
|
|
3
|
-
import "@testing-library/react-native/extend-expect";
|
|
4
|
-
import { Pressable, Text, View } from "react-native";
|
|
5
|
-
import Bu from "../index";
|
|
6
|
-
|
|
7
|
-
describe("Bu", () => {
|
|
8
|
-
it(":base", async () => {
|
|
9
|
-
let isOn = false;
|
|
10
|
-
const wrapper = render(<Bu onChange={(v) => (isOn = v)}></Bu>);
|
|
11
|
-
expect(wrapper.UNSAFE_root.props.defaultValue).toBe(false);
|
|
12
|
-
await fireEvent(wrapper.UNSAFE_root.children[0], "press");
|
|
13
|
-
expect(isOn).toBe(true);
|
|
14
|
-
|
|
15
|
-
await fireEvent(wrapper.UNSAFE_root.children[0], "press");
|
|
16
|
-
expect(isOn).toBe(false);
|
|
17
|
-
});
|
|
18
|
-
});
|