@xhsreds/reds-rn-next 0.0.4 → 0.0.8
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/index.js +2 -2
- package/lib/cjs/components/Button/index.js.map +1 -1
- package/lib/cjs/components/Button/interface/index.js +7 -0
- package/lib/cjs/components/Button/interface/index.js.map +1 -1
- package/lib/cjs/components/ConfigProvider/ConfigProvider.js +39 -7
- package/lib/cjs/components/ConfigProvider/ConfigProvider.js.map +1 -1
- package/lib/cjs/components/ConfigProvider/index.js +2 -2
- package/lib/cjs/components/ConfigProvider/interface/index.js +17 -0
- package/lib/cjs/components/ConfigProvider/interface/index.js.map +1 -1
- package/lib/cjs/components/Popover/hook.js.map +1 -1
- package/lib/cjs/components/Popover/interface/index.js +2 -3
- package/lib/cjs/components/Popover/interface/index.js.map +1 -1
- package/lib/cjs/components/Switch/index.js +1 -1
- package/lib/cjs/components/Switch/index.js.map +1 -1
- package/lib/cjs/components/Switch/interface/index.js +2 -2
- package/lib/cjs/components/Switch/interface/index.js.map +1 -1
- package/lib/cjs/index.js +4 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/Button/index.js +2 -2
- package/lib/esm/components/Button/index.js.map +1 -1
- package/lib/esm/components/Button/interface/index.js +7 -1
- package/lib/esm/components/Button/interface/index.js.map +1 -1
- package/lib/esm/components/ConfigProvider/ConfigProvider.js +41 -5
- package/lib/esm/components/ConfigProvider/ConfigProvider.js.map +1 -1
- package/lib/esm/components/ConfigProvider/index.js +1 -1
- package/lib/esm/components/ConfigProvider/interface/index.js +17 -1
- package/lib/esm/components/ConfigProvider/interface/index.js.map +1 -1
- package/lib/esm/components/Popover/hook.js.map +1 -1
- package/lib/esm/components/Popover/interface/index.js +2 -3
- package/lib/esm/components/Popover/interface/index.js.map +1 -1
- package/lib/esm/components/Switch/index.js +2 -2
- package/lib/esm/components/Switch/index.js.map +1 -1
- package/lib/esm/components/Switch/interface/index.js +2 -2
- package/lib/esm/components/Switch/interface/index.js.map +1 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/types/packages/reds-rn/src/components/Button/demo/index.d.ts +2 -0
- package/lib/types/packages/reds-rn/src/components/Button/index.d.ts +3 -0
- package/lib/types/{src → packages/reds-rn/src}/components/Button/interface/index.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/Button/test/index.bench.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/Button/test/index.test.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/ConfigProvider/ConfigProvider.d.ts +4 -0
- package/lib/types/packages/reds-rn/src/components/ConfigProvider/demo/index.d.ts +2 -0
- package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/index.d.ts +1 -1
- package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/interface/index.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/ConfigProvider/test/index.bench.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/ConfigProvider/test/index.test.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/Popover/demo/index.d.ts +2 -0
- package/lib/types/{src → packages/reds-rn/src}/components/Popover/hook.d.ts +2 -1
- package/lib/types/{src → packages/reds-rn/src}/components/Popover/interface/index.d.ts +2 -2
- package/lib/types/packages/reds-rn/src/components/Popover/test/index.bench.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/Popover/test/index.test.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/Switch/demo/index.d.ts +2 -0
- package/lib/types/{src → packages/reds-rn/src}/components/Switch/interface/index.d.ts +3 -3
- package/lib/types/packages/reds-rn/src/components/Switch/test/index.bench.d.ts +1 -0
- package/lib/types/packages/reds-rn/src/components/Switch/test/index.test.d.ts +1 -0
- package/lib/types/{src → packages/reds-rn/src}/index.d.ts +1 -0
- package/lib/types/utils/redsBench.d.ts +3 -0
- package/package.json +3 -3
- package/src/components/Button/demo/index.tsx +6 -6
- package/src/components/Button/index.tsx +3 -1
- package/src/components/Button/interface/index.ts +6 -0
- package/src/components/Button/test/index.bench.tsx +1 -1
- package/src/components/Button/test/index.test.tsx +0 -1
- package/src/components/ConfigProvider/ConfigProvider.tsx +2 -1
- package/src/components/ConfigProvider/demo/index.tsx +8 -8
- package/src/components/ConfigProvider/index.ts +1 -1
- package/src/components/ConfigProvider/interface/index.ts +16 -0
- package/src/components/ConfigProvider/test/index.bench.tsx +1 -1
- package/src/components/Popover/demo/index.tsx +2 -2
- package/src/components/Popover/doc/index.mdx +11 -11
- package/src/components/Popover/hook.ts +2 -1
- package/src/components/Popover/interface/index.ts +2 -3
- package/src/components/Switch/demo/index.tsx +4 -3
- package/src/components/Switch/doc/index.mdx +4 -4
- package/src/components/Switch/index.tsx +2 -2
- package/src/components/Switch/interface/index.ts +4 -5
- package/src/index.ts +2 -0
- package/tsconfig.json +6 -2
- package/lib/cjs/_chunks/DiJl2cva.js +0 -49
- package/lib/cjs/_chunks/DiJl2cva.js.map +0 -1
- package/lib/cjs/components/NN/index.js +0 -83
- package/lib/cjs/components/NN/index.js.map +0 -1
- package/lib/cjs/components/NN/interface/index.js +0 -13
- package/lib/cjs/components/NN/interface/index.js.map +0 -1
- package/lib/cjs/components/NNNN/index.js +0 -83
- package/lib/cjs/components/NNNN/index.js.map +0 -1
- package/lib/cjs/components/NNNN/interface/index.js +0 -13
- package/lib/cjs/components/NNNN/interface/index.js.map +0 -1
- package/lib/cjs/components/PP/index.js +0 -83
- package/lib/cjs/components/PP/index.js.map +0 -1
- package/lib/cjs/components/PP/interface/index.js +0 -14
- package/lib/cjs/components/PP/interface/index.js.map +0 -1
- package/lib/esm/_chunks/Br6Ked0G.js +0 -46
- package/lib/esm/_chunks/Br6Ked0G.js.map +0 -1
- package/lib/esm/components/NN/index.js +0 -79
- package/lib/esm/components/NN/index.js.map +0 -1
- package/lib/esm/components/NN/interface/index.js +0 -11
- package/lib/esm/components/NN/interface/index.js.map +0 -1
- package/lib/esm/components/NNNN/index.js +0 -79
- package/lib/esm/components/NNNN/index.js.map +0 -1
- package/lib/esm/components/NNNN/interface/index.js +0 -11
- package/lib/esm/components/NNNN/interface/index.js.map +0 -1
- package/lib/esm/components/PP/index.js +0 -79
- package/lib/esm/components/PP/index.js.map +0 -1
- package/lib/esm/components/PP/interface/index.js +0 -12
- package/lib/esm/components/PP/interface/index.js.map +0 -1
- package/lib/types/src/components/Button/index.d.ts +0 -4
- package/lib/types/src/components/ConfigProvider/ConfigProvider.d.ts +0 -4
- package/lib/types/src/components/NN/index.d.ts +0 -7
- package/lib/types/src/components/NN/interface/index.d.ts +0 -10
- package/lib/types/src/components/NNNN/index.d.ts +0 -7
- package/lib/types/src/components/NNNN/interface/index.d.ts +0 -10
- package/lib/types/src/components/PP/index.d.ts +0 -7
- package/lib/types/src/components/PP/interface/index.d.ts +0 -11
- package/src/components/Button/demo/index.jsx +0 -50
- /package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/hooks/ConfigCache/ConfigCache.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/hooks/ConfigCache/index.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/hooks/ConfigCache/interface.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/hooks/ConfigContext/ConfigContext.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/ConfigProvider/hooks/themeToken/useThemeToken.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/Popover/component.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/Popover/index.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/Popover/manifest.d.ts +0 -0
- /package/lib/types/{src → packages/reds-rn/src}/components/Switch/index.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { Text, View } from "react-native";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const Button: React.FC<any> = forwardRef<View>((props: any, ref) => {
|
|
5
5
|
return (
|
|
6
6
|
<View
|
|
7
7
|
ref={ref}
|
|
@@ -21,3 +21,5 @@ export default forwardRef<View>((props: any, ref) => {
|
|
|
21
21
|
</View>
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
|
+
|
|
25
|
+
export default Button;
|
|
@@ -16,3 +16,9 @@ export const defaultProps: RedsButton = {
|
|
|
16
16
|
trackOnColor: lightColor.Primary,
|
|
17
17
|
trackOffColor: lightColor.Fill2,
|
|
18
18
|
};
|
|
19
|
+
export const ButtonDefaultProps: RedsButton = {
|
|
20
|
+
defaultValue: false,
|
|
21
|
+
disabled: false,
|
|
22
|
+
trackOnColor: lightColor.Primary,
|
|
23
|
+
trackOffColor: lightColor.Fill2,
|
|
24
|
+
};
|
|
@@ -7,7 +7,7 @@ import Button from "../index";
|
|
|
7
7
|
describe("Button", () => {
|
|
8
8
|
it(":base", async () => {
|
|
9
9
|
let isOn = false;
|
|
10
|
-
const wrapper = render(<Button
|
|
10
|
+
const wrapper = render(<Button></Button>);
|
|
11
11
|
expect(wrapper.UNSAFE_root.props.defaultValue).toBe(false);
|
|
12
12
|
await fireEvent(wrapper.UNSAFE_root.children[0], "press");
|
|
13
13
|
expect(isOn).toBe(true);
|
|
@@ -2,7 +2,6 @@ import { describe, it, expect } from "vitest";
|
|
|
2
2
|
import { render, fireEvent, userEvent } from "@testing-library/react-native";
|
|
3
3
|
import "@testing-library/react-native/extend-expect";
|
|
4
4
|
import { Pressable, Text, View } from "react-native";
|
|
5
|
-
import Button from "../index";
|
|
6
5
|
|
|
7
6
|
describe("Button", () => {
|
|
8
7
|
it(":base", async () => {});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ConfigProviderProps } 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
5
|
|
|
5
|
-
const ConfigProvider = (props: ConfigProviderProps) => {
|
|
6
|
+
const ConfigProvider: React.FC<ConfigProviderProps> = (props: ConfigProviderProps) => {
|
|
6
7
|
const {
|
|
7
8
|
id = "root",
|
|
8
9
|
theme = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useState } from "react";
|
|
2
2
|
import { View, Text, StyleSheet, FlatList, ScrollView } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from "@xhs/reds-rn-next";
|
|
4
4
|
|
|
5
5
|
const styles = StyleSheet.create({
|
|
6
6
|
container: {
|
|
@@ -20,30 +20,30 @@ const styles = StyleSheet.create({
|
|
|
20
20
|
const Desc = ({ children = "" }) => {
|
|
21
21
|
return <Text>{children}</Text>;
|
|
22
22
|
};
|
|
23
|
-
const Br = (props) => <View style={{ height: props.height || 20 }}></View>;
|
|
23
|
+
const Br = (props: { height?: number }) => <View style={{ height: props.height || 20 }}></View>;
|
|
24
24
|
|
|
25
25
|
export default function App() {
|
|
26
26
|
const [value, setValue] = useState(false);
|
|
27
27
|
const [valueStr, setValueStr] = useState(value.toString());
|
|
28
|
-
const onClick = (
|
|
29
|
-
const onChange = (v) => setValueStr(v.toString());
|
|
28
|
+
const onClick = (_e: any) => setValue((v) => !v);
|
|
29
|
+
const onChange = (v: boolean) => setValueStr(v.toString());
|
|
30
30
|
return (
|
|
31
31
|
<View style={styles.container}>
|
|
32
32
|
<Desc>默认用法</Desc>
|
|
33
|
-
<
|
|
33
|
+
<Button></Button>
|
|
34
34
|
<Br />
|
|
35
35
|
|
|
36
36
|
<Desc>设置默认值</Desc>
|
|
37
|
-
<
|
|
37
|
+
<Button></Button>
|
|
38
38
|
<Br />
|
|
39
39
|
|
|
40
40
|
<Desc>修改开关颜色</Desc>
|
|
41
|
-
<
|
|
41
|
+
<Button></Button>
|
|
42
42
|
<Br />
|
|
43
43
|
|
|
44
44
|
<Desc>受控用法</Desc>
|
|
45
45
|
<Text>当前值:{valueStr}</Text>
|
|
46
|
-
<
|
|
46
|
+
<Button></Button>
|
|
47
47
|
<Br />
|
|
48
48
|
</View>
|
|
49
49
|
);
|
|
@@ -52,3 +52,19 @@ export const defaultProps: RedsConfigProvider = {
|
|
|
52
52
|
inherit: true,
|
|
53
53
|
token: {},
|
|
54
54
|
};
|
|
55
|
+
export const ConfigProviderDefaultProps: RedsConfigProvider = {
|
|
56
|
+
id: "root",
|
|
57
|
+
parentId: "root",
|
|
58
|
+
theme: {
|
|
59
|
+
colorMode: "light",
|
|
60
|
+
inherit: true,
|
|
61
|
+
token: {
|
|
62
|
+
lightColor: {},
|
|
63
|
+
darkColor: {},
|
|
64
|
+
alwaysColor: {},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
colorMode: "light",
|
|
68
|
+
inherit: true,
|
|
69
|
+
token: {},
|
|
70
|
+
};
|
|
@@ -7,7 +7,7 @@ import ConfigProvider from "../index";
|
|
|
7
7
|
describe("ConfigProvider", () => {
|
|
8
8
|
it(":base", async () => {
|
|
9
9
|
let isOn = false;
|
|
10
|
-
const wrapper = render(<ConfigProvider
|
|
10
|
+
const wrapper = render(<ConfigProvider>123</ConfigProvider>);
|
|
11
11
|
expect(wrapper.UNSAFE_root.props.defaultValue).toBe(false);
|
|
12
12
|
await fireEvent(wrapper.UNSAFE_root.children[0], "press");
|
|
13
13
|
expect(isOn).toBe(true);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useState, forwardRef } from "react";
|
|
2
2
|
import { View, Text, StyleSheet, FlatList, ScrollView } from "react-native";
|
|
3
|
-
import { Popover, Button } from "@xhs/reds-rn-next";
|
|
3
|
+
import { Popover, Button, RedsPopover } from "@xhs/reds-rn-next";
|
|
4
4
|
|
|
5
5
|
const styles = StyleSheet.create({
|
|
6
6
|
container: {
|
|
@@ -62,7 +62,7 @@ export default function App() {
|
|
|
62
62
|
|
|
63
63
|
<Br />
|
|
64
64
|
|
|
65
|
-
<Popover content={placement} placement={placement} visible>
|
|
65
|
+
<Popover content={placement} placement={placement as RedsPopover["placement"]} visible>
|
|
66
66
|
<Button>{"气泡位置"}</Button>
|
|
67
67
|
</Popover>
|
|
68
68
|
</View>
|
|
@@ -12,17 +12,17 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
|
12
12
|
|
|
13
13
|
### Props
|
|
14
14
|
|
|
15
|
-
| 属性 | 描述 | 类型
|
|
16
|
-
| -------------------- | ---------------------- |
|
|
17
|
-
| visible | 是否显示气泡 | boolean
|
|
18
|
-
| placement | 气泡方向 | "top" | "bottom"
|
|
19
|
-
| content | 弹出内容 | string
|
|
20
|
-
| opacity | 遮罩透明度 | number
|
|
21
|
-
| mode | 主题色 | "light" | "dark"
|
|
22
|
-
| trigger | 触发方式 | "click" | "touch"
|
|
23
|
-
| z-index | 层级 | number
|
|
24
|
-
| close-on-click-again | 再次点击关闭 | boolean
|
|
25
|
-
| children | popover 作用的目标节点 | ReactNode
|
|
15
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
16
|
+
| -------------------- | ---------------------- | --------------------------------------------------------------------------------------------------- | --------- |
|
|
17
|
+
| visible | 是否显示气泡 | boolean | undefined |
|
|
18
|
+
| placement | 气泡方向 | "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end" | top |
|
|
19
|
+
| content | 弹出内容 | string | |
|
|
20
|
+
| opacity | 遮罩透明度 | number | 0 |
|
|
21
|
+
| mode | 主题色 | "light" | "dark" | |
|
|
22
|
+
| trigger | 触发方式 | "click" | "touch" | click |
|
|
23
|
+
| z-index | 层级 | number | 1000 |
|
|
24
|
+
| close-on-click-again | 再次点击关闭 | boolean | true |
|
|
25
|
+
| children | popover 作用的目标节点 | ReactNode | |
|
|
26
26
|
|
|
27
27
|
### Events
|
|
28
28
|
|
|
@@ -2,8 +2,9 @@ import { useRef } from "react";
|
|
|
2
2
|
import { Platform, View } from "react-native";
|
|
3
3
|
import type { MeasureOnSuccessCallback, NativeMethods, LayoutChangeEvent } from "react-native";
|
|
4
4
|
import { useFloating as useFloatingUI, shift, limitShift, flip, offset, arrow } from "@floating-ui/react-native";
|
|
5
|
+
import { RedsPopover } from "./interface";
|
|
5
6
|
|
|
6
|
-
export const useFloating = ({ placement, needModal }: { placement: "
|
|
7
|
+
export const useFloating = ({ placement, needModal }: { placement: RedsPopover["placement"]; needModal: boolean }) => {
|
|
7
8
|
const arrowRef = useRef(null);
|
|
8
9
|
const floatingHeight = useRef(0);
|
|
9
10
|
const referenceX = useRef(0);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
export interface RedsPopover {
|
|
3
3
|
visible?: boolean;
|
|
4
|
-
placement?: "top" | "bottom";
|
|
4
|
+
placement?: "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
|
|
5
5
|
content?: string;
|
|
6
6
|
opacity?: number;
|
|
7
7
|
mode?: "light" | "dark";
|
|
@@ -14,12 +14,11 @@ export interface RedsPopover {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface RedsPopoverEvent {}
|
|
17
|
-
export const
|
|
17
|
+
export const PopoverDefaultProps: RedsPopover = {
|
|
18
18
|
visible: undefined,
|
|
19
19
|
placement: "top",
|
|
20
20
|
content: "",
|
|
21
21
|
opacity: 0,
|
|
22
|
-
mode: "light",
|
|
23
22
|
trigger: "click",
|
|
24
23
|
zIndex: 1000,
|
|
25
24
|
closeOnClickAgain: true,
|
|
@@ -20,19 +20,20 @@ const styles = StyleSheet.create({
|
|
|
20
20
|
const Desc = ({ children = "" }) => {
|
|
21
21
|
return <Text>{children}</Text>;
|
|
22
22
|
};
|
|
23
|
-
const Br = (props) => <View style={{ height: props.height || 20 }}></View>;
|
|
23
|
+
const Br = (props: { height?: number }) => <View style={{ height: props.height || 20 }}></View>;
|
|
24
24
|
|
|
25
25
|
export default function App() {
|
|
26
26
|
const [value, setValue] = useState(false);
|
|
27
27
|
const [valueStr, setValueStr] = useState(value.toString());
|
|
28
|
-
const onClick = (e) => setValue((v) => !v);
|
|
29
|
-
const onChange = (v) => {
|
|
28
|
+
const onClick = (e: any) => setValue((v) => !v);
|
|
29
|
+
const onChange = (v: boolean) => {
|
|
30
30
|
console.log(v);
|
|
31
31
|
setValueStr(v.toString());
|
|
32
32
|
};
|
|
33
33
|
return (
|
|
34
34
|
<View style={styles.container}>
|
|
35
35
|
<Desc>默认用法</Desc>
|
|
36
|
+
<Text>{"children"}</Text>
|
|
36
37
|
<Switch></Switch>
|
|
37
38
|
<Br />
|
|
38
39
|
|
|
@@ -18,7 +18,7 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
|
|
|
18
18
|
|
|
19
19
|
### Events
|
|
20
20
|
|
|
21
|
-
| 事件 | 描述 | 类型
|
|
22
|
-
| ------ | ------------------ |
|
|
23
|
-
| change | 当值发生变化时触发 | (value: boolean) =>
|
|
24
|
-
| click | 被点击时触发 | (value: GestureResponderEvent) =>
|
|
21
|
+
| 事件 | 描述 | 类型 | 默认值 |
|
|
22
|
+
| ------ | ------------------ | ------------------------------------- | ------ |
|
|
23
|
+
| change | 当值发生变化时触发 | (value: boolean) => any | |
|
|
24
|
+
| click | 被点击时触发 | (value: GestureResponderEvent) => any | |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect, useMemo } from "react";
|
|
2
2
|
import { View, TouchableWithoutFeedback, StyleSheet, Animated, GestureResponderEvent } from "react-native";
|
|
3
|
-
import { RedsSwitch,
|
|
3
|
+
import { RedsSwitch, SwitchDefaultProps } from "./interface/index";
|
|
4
4
|
import { alwaysColor } from "@xhs/reds-token-next";
|
|
5
5
|
|
|
6
6
|
const Switch = ({ value: isOn, defaultValue, onChange, onClick, trackOnColor, trackOffColor }: RedsSwitch) => {
|
|
@@ -37,7 +37,7 @@ const Switch = ({ value: isOn, defaultValue, onChange, onClick, trackOnColor, tr
|
|
|
37
37
|
);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
Switch.defaultProps =
|
|
40
|
+
Switch.defaultProps = SwitchDefaultProps;
|
|
41
41
|
|
|
42
42
|
const styles = StyleSheet.create({
|
|
43
43
|
switchContainer: {
|
|
@@ -6,16 +6,15 @@ export interface RedsSwitch {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
trackOnColor?: string;
|
|
8
8
|
trackOffColor?: string;
|
|
9
|
-
onChange?: (value: boolean) =>
|
|
10
|
-
onClick?: (value: GestureResponderEvent) =>
|
|
9
|
+
onChange?: (value: boolean) => any;
|
|
10
|
+
onClick?: (value: GestureResponderEvent) => any;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export interface RedsSwitchEvent {}
|
|
14
|
+
export const SwitchDefaultProps: RedsSwitch = {
|
|
14
15
|
value: undefined,
|
|
15
16
|
defaultValue: false,
|
|
16
17
|
disabled: false,
|
|
17
18
|
trackOnColor: lightColor.Primary,
|
|
18
19
|
trackOffColor: lightColor.Fill2,
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
export interface RedsSwitchEvent {}
|
package/src/index.ts
CHANGED
|
@@ -2,4 +2,6 @@ import Button from "./components/Button";
|
|
|
2
2
|
import Popover from "./components/Popover";
|
|
3
3
|
import Switch from "./components/Switch";
|
|
4
4
|
import ConfigProvider, { useThemeColor } from "./components/ConfigProvider";
|
|
5
|
+
|
|
6
|
+
export * from "./components/Popover/interface";
|
|
5
7
|
export { Button, Popover, Switch, ConfigProvider, useThemeColor };
|
package/tsconfig.json
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "./lib",
|
|
5
|
-
"
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@xhs/reds-rn-next": ["src/index"],
|
|
8
|
+
"~root/utils/*": ["../../utils/*"]
|
|
9
|
+
}
|
|
6
10
|
},
|
|
7
11
|
"include": ["src"],
|
|
8
|
-
"exclude": ["node_modules", "lib"
|
|
12
|
+
"exclude": ["node_modules", "lib"]
|
|
9
13
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _rollupPluginBabelHelpers = require('./CAyGJuk1.js');
|
|
4
|
-
var components_ConfigProvider_hooks_ConfigCache_ConfigCache = require('../components/ConfigProvider/hooks/ConfigCache/ConfigCache.js');
|
|
5
|
-
var components_ConfigProvider_hooks_ConfigContext_ConfigContext = require('../components/ConfigProvider/hooks/ConfigContext/ConfigContext.js');
|
|
6
|
-
|
|
7
|
-
var ConfigProvider = function ConfigProvider(props) {
|
|
8
|
-
var _theme$token, _theme$token2, _theme$token3, _theme$token4;
|
|
9
|
-
var _props$id = props.id,
|
|
10
|
-
id = _props$id === void 0 ? "root" : _props$id,
|
|
11
|
-
_props$theme = props.theme,
|
|
12
|
-
theme = _props$theme === void 0 ? {
|
|
13
|
-
colorMode: "light",
|
|
14
|
-
inherit: true
|
|
15
|
-
} : _props$theme,
|
|
16
|
-
_props$parentId = props.parentId,
|
|
17
|
-
parentId = _props$parentId === void 0 ? "root" : _props$parentId,
|
|
18
|
-
children = props.children;
|
|
19
|
-
var themeCache = {
|
|
20
|
-
colorMode: theme.colorMode || "light",
|
|
21
|
-
token: {
|
|
22
|
-
lightColor: _rollupPluginBabelHelpers._objectSpread2({}, (_theme$token = theme.token) === null || _theme$token === void 0 ? void 0 : _theme$token.lightColor),
|
|
23
|
-
darkColor: _rollupPluginBabelHelpers._objectSpread2({}, (_theme$token2 = theme.token) === null || _theme$token2 === void 0 ? void 0 : _theme$token2.darkColor),
|
|
24
|
-
alwaysColor: _rollupPluginBabelHelpers._objectSpread2({}, (_theme$token3 = theme.token) === null || _theme$token3 === void 0 ? void 0 : _theme$token3.alwaysColor),
|
|
25
|
-
components: _rollupPluginBabelHelpers._objectSpread2({}, (_theme$token4 = theme.token) === null || _theme$token4 === void 0 ? void 0 : _theme$token4.components)
|
|
26
|
-
},
|
|
27
|
-
inherit: theme.inherit
|
|
28
|
-
};
|
|
29
|
-
components_ConfigProvider_hooks_ConfigCache_ConfigCache.configCache.addNewConfigCache({
|
|
30
|
-
id: id,
|
|
31
|
-
themeCache: themeCache,
|
|
32
|
-
parentId: parentId
|
|
33
|
-
});
|
|
34
|
-
var configProviderContextValue = {
|
|
35
|
-
id: id
|
|
36
|
-
};
|
|
37
|
-
return /* @__PURE__ */React.createElement(components_ConfigProvider_hooks_ConfigContext_ConfigContext.ConfigProviderContext.Provider, {
|
|
38
|
-
value: configProviderContextValue
|
|
39
|
-
}, children);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var ConfigProvider$1 = /*#__PURE__*/Object.freeze({
|
|
43
|
-
__proto__: null,
|
|
44
|
-
default: ConfigProvider
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
exports.ConfigProvider = ConfigProvider$1;
|
|
48
|
-
exports.ConfigProvider$1 = ConfigProvider;
|
|
49
|
-
//# sourceMappingURL=DiJl2cva.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DiJl2cva.js","sources":["../../../src/components/ConfigProvider/ConfigProvider.tsx"],"sourcesContent":["import { ConfigProviderProps } from \"./interface\";\nimport { configCache } from \"./hooks/ConfigCache/ConfigCache\";\nimport { ConfigProviderContext, IConfigProviderContext } from \"./hooks/ConfigContext/ConfigContext\";\n\nconst ConfigProvider = (props: ConfigProviderProps) => {\n const {\n id = \"root\",\n theme = {\n colorMode: \"light\",\n inherit: true,\n },\n parentId = \"root\",\n children,\n } = props;\n\n const themeCache = {\n colorMode: theme.colorMode || \"light\",\n token: {\n lightColor: {\n ...theme.token?.lightColor,\n },\n darkColor: {\n ...theme.token?.darkColor,\n },\n alwaysColor: {\n ...theme.token?.alwaysColor,\n },\n components: {\n ...theme.token?.components,\n },\n },\n inherit: theme.inherit,\n };\n\n configCache.addNewConfigCache({\n id,\n themeCache,\n parentId,\n });\n\n const configProviderContextValue: IConfigProviderContext = {\n id: id,\n };\n\n return <ConfigProviderContext.Provider value={configProviderContextValue}>{children}</ConfigProviderContext.Provider>;\n};\n\nexport default ConfigProvider;\n"],"names":["ConfigProvider","props","_theme$token","_theme$token2","_theme$token3","_theme$token4","_props$id","id","_props$theme","theme","colorMode","inherit","_props$parentId","parentId","children","themeCache","token","lightColor","_objectSpread","darkColor","alwaysColor","components","configCache","addNewConfigCache","configProviderContextValue","ConfigProviderContext","Provider","value"],"mappings":";;;;;;AAIA,IAAMA,cAAA,GAAiB,SAAjBA,cAAAA,CAAkBC,KAA+B,EAAA;AAAA,EAAA,IAAAC,YAAA,EAAAC,aAAA,EAAAC,aAAA,EAAAC,aAAA,CAAA;AAC/C,EAAA,IAAAC,SAAA,GAQFL,KAAA,CAPFM,EAAK;AAALA,IAAAA,EAAK,GAAAD,SAAA,KAAA,KAAA,CAAA,GAAA,MAAA,GAAAA,SAAA;IAAAE,YAAA,GAOHP,KAAA,CANFQ,KAAQ;IAARA,KAAQ,GAAAD,YAAA,KAAA,KAAA,CAAA,GAAA;AACNE,MAAAA,SAAW,EAAA,OAAA;AACXC,MAAAA,OAAS,EAAA,IAAA;AACX,KAAA,GAAAH,YAAA;IAAAI,eAAA,GAGEX,KAAA,CAFFY,QAAW;AAAXA,IAAAA,QAAW,GAAAD,eAAA,KAAA,KAAA,CAAA,GAAA,MAAA,GAAAA,eAAA;IACXE,QAAA,GACEb,KAAA,CADFa,QAAA,CAAA;AAGF,EAAA,IAAMC,UAAa,GAAA;AACjBL,IAAAA,SAAA,EAAWD,MAAMC,SAAa,IAAA,OAAA;AAC9BM,IAAAA,KAAO,EAAA;AACLC,MAAAA,UAAY,EAAAC,wCAAA,CAAAhB,EAAAA,EAAAA,CAAAA,YAAA,GACPO,MAAMO,KAAO,MAAA,IAAA,IAAAd,YAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAbA,YAAA,CAAae,UAAA,CAClB;AACAE,MAAAA,SAAW,EAAAD,wCAAA,CAAAf,EAAAA,EAAAA,CAAAA,aAAA,GACNM,MAAMO,KAAO,MAAA,IAAA,IAAAb,aAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAbA,aAAA,CAAagB,SAAA,CAClB;AACAC,MAAAA,WAAa,EAAAF,wCAAA,CAAAd,EAAAA,EAAAA,CAAAA,aAAA,GACRK,MAAMO,KAAO,MAAA,IAAA,IAAAZ,aAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAbA,aAAA,CAAagB,WAAA,CAClB;AACAC,MAAAA,UAAY,EAAAH,wCAAA,CAAAb,EAAAA,EAAAA,CAAAA,aAAA,GACPI,MAAMO,KAAO,MAAAX,IAAAA,IAAAA,aAAA,KAAbA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,aAAA,CAAagB,UAAA,CAAA;KAEpB;IACAV,SAASF,KAAM,CAAAE,OAAAA;GACjB,CAAA;EAEAW,mEAAA,CAAYC,iBAAkB,CAAA;AAC5BhB,IAAAA,EAAA,EAAAA,EAAA;AACAQ,IAAAA,UAAA,EAAAA,UAAA;AACAF,IAAAA,QAAA,EAAAA,QAAAA;AACF,GAAC,CAAA,CAAA;AAED,EAAA,IAAMW,0BAAqD,GAAA;AACzDjB,IAAAA,EAAA,EAAAA,EAAAA;GACF,CAAA;EAEA,0CAAQkB,iFAAsB,CAAAC,QAAA,EAAtB;AAA+BC,IAAAA,KAAA,EAAOH,0BAAAA;KAA6BV,QAAS,CAAA,CAAA;AACtF;;;;;;;;;;"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_chunks/CAyGJuk1.js');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var reactNative = require('react-native');
|
|
8
|
-
var components_NN_interface_index = require('./interface/index.js');
|
|
9
|
-
var redsTokenNext = require('@xhs/reds-token-next');
|
|
10
|
-
|
|
11
|
-
var NN = function NN(_ref) {
|
|
12
|
-
var cValue = _ref.value,
|
|
13
|
-
defaultValue = _ref.defaultValue,
|
|
14
|
-
onChange = _ref.onChange,
|
|
15
|
-
onClick = _ref.onClick,
|
|
16
|
-
trackOnColor = _ref.trackOnColor,
|
|
17
|
-
trackOffColor = _ref.trackOffColor;
|
|
18
|
-
var isControlled = cValue !== void 0;
|
|
19
|
-
var _useState = React.useState(defaultValue),
|
|
20
|
-
_useState2 = _rollupPluginBabelHelpers._slicedToArray(_useState, 2),
|
|
21
|
-
value = _useState2[0],
|
|
22
|
-
setValue = _useState2[1];
|
|
23
|
-
var animatedValue = React.useRef(new reactNative.Animated.Value(defaultValue ? 18 : 2)).current;
|
|
24
|
-
var thumbTranslateX = React.useMemo(function () {
|
|
25
|
-
return animatedValue.interpolate({
|
|
26
|
-
inputRange: [2, 18],
|
|
27
|
-
outputRange: [2, 18]
|
|
28
|
-
});
|
|
29
|
-
}, []);
|
|
30
|
-
React.useEffect(function () {
|
|
31
|
-
isControlled && setValue(cValue);
|
|
32
|
-
onChange === null || onChange === void 0 || onChange(!!value);
|
|
33
|
-
reactNative.Animated.timing(animatedValue, {
|
|
34
|
-
toValue: value ? 18 : 2,
|
|
35
|
-
duration: 200,
|
|
36
|
-
useNativeDriver: true
|
|
37
|
-
}).start();
|
|
38
|
-
}, [value, cValue]);
|
|
39
|
-
var toggleNN = function toggleNN(e) {
|
|
40
|
-
onClick === null || onClick === void 0 || onClick(e);
|
|
41
|
-
!isControlled && setValue(function (v) {
|
|
42
|
-
return !v;
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
return /* @__PURE__ */React.createElement(reactNative.TouchableWithoutFeedback, {
|
|
46
|
-
onPress: function onPress(e) {
|
|
47
|
-
return toggleNN(e);
|
|
48
|
-
}
|
|
49
|
-
}, /* @__PURE__ */React.createElement(reactNative.View, {
|
|
50
|
-
style: [styles.container, {
|
|
51
|
-
backgroundColor: value ? trackOnColor : trackOffColor
|
|
52
|
-
}]
|
|
53
|
-
}, /* @__PURE__ */React.createElement(reactNative.Animated.View, {
|
|
54
|
-
style: [styles.thumb, {
|
|
55
|
-
transform: [{
|
|
56
|
-
translateX: thumbTranslateX
|
|
57
|
-
}]
|
|
58
|
-
}]
|
|
59
|
-
})));
|
|
60
|
-
};
|
|
61
|
-
NN.defaultProps = components_NN_interface_index.defaultProps;
|
|
62
|
-
var styles = reactNative.StyleSheet.create({
|
|
63
|
-
container: {
|
|
64
|
-
width: 40,
|
|
65
|
-
height: 24,
|
|
66
|
-
borderRadius: 15,
|
|
67
|
-
justifyContent: "center",
|
|
68
|
-
alignItems: "center"
|
|
69
|
-
},
|
|
70
|
-
thumb: {
|
|
71
|
-
width: 20,
|
|
72
|
-
height: 20,
|
|
73
|
-
borderRadius: 10,
|
|
74
|
-
backgroundColor: redsTokenNext.alwaysColor.White,
|
|
75
|
-
justifyContent: "center",
|
|
76
|
-
alignItems: "center",
|
|
77
|
-
position: "absolute",
|
|
78
|
-
left: 0
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
exports.default = NN;
|
|
83
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/NN/index.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, useMemo } from \"react\";\nimport { View, TouchableWithoutFeedback, StyleSheet, Animated, GestureResponderEvent } from \"react-native\";\nimport { RedsNN, defaultProps } from \"./interface/index\";\nimport { alwaysColor } from \"@xhs/reds-token-next\";\n\nconst NN = ({ value: cValue, defaultValue, onChange, onClick, trackOnColor, trackOffColor }: RedsNN) => {\n const isControlled = cValue !== undefined;\n const [value, setValue] = useState(defaultValue);\n\n const animatedValue = useRef(new Animated.Value(defaultValue ? 18 : 2)).current;\n\n const thumbTranslateX = useMemo(() => animatedValue.interpolate({ inputRange: [2, 18], outputRange: [2, 18] }), []);\n\n useEffect(() => {\n isControlled && setValue(cValue);\n onChange?.(!!value);\n Animated.timing(animatedValue, {\n toValue: value ? 18 : 2,\n duration: 200,\n useNativeDriver: true,\n }).start();\n }, [value, cValue]);\n\n const toggleNN = (e: GestureResponderEvent) => {\n onClick?.(e);\n !isControlled && setValue((v) => !v);\n };\n\n return (\n <TouchableWithoutFeedback onPress={(e) => toggleNN(e)}>\n <View style={[styles.container, { backgroundColor: value ? trackOnColor : trackOffColor }]}>\n <Animated.View style={[styles.thumb, { transform: [{ translateX: thumbTranslateX }] }]}></Animated.View>\n </View>\n </TouchableWithoutFeedback>\n );\n};\n\nNN.defaultProps = defaultProps;\n\nconst styles = StyleSheet.create({\n container: {\n width: 40,\n height: 24,\n borderRadius: 15,\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n thumb: {\n width: 20,\n height: 20,\n borderRadius: 10,\n backgroundColor: alwaysColor.White,\n justifyContent: \"center\",\n alignItems: \"center\",\n position: \"absolute\",\n left: 0,\n },\n});\n\nexport default NN;\n"],"names":["NN","_ref","cValue","value","defaultValue","onChange","onClick","trackOnColor","trackOffColor","isControlled","_useState","useState","_useState2","_slicedToArray","setValue","animatedValue","useRef","Animated","Value","current","thumbTranslateX","useMemo","interpolate","inputRange","outputRange","useEffect","timing","toValue","duration","useNativeDriver","start","toggleNN","e","v","TouchableWithoutFeedback","onPress","React","createElement","View","style","styles","container","backgroundColor","thumb","transform","translateX","defaultProps","StyleSheet","create","width","height","borderRadius","justifyContent","alignItems","alwaysColor","White","position","left"],"mappings":";;;;;;;;;;AAKA,IAAMA,EAAA,GAAK,SAALA,EAAAA,CAAAC,IAAA,EAAkG;AAAA,EAAA,IAAnFC,MAAA,GAAAD,IAAA,CAAPE,KAAO;IAAQC,oBAAAA;IAAcC,QAAU,GAAAJ,IAAA,CAAVI,QAAU;IAAAC,OAAA,GAAAL,IAAA,CAAAK,OAAA;I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A;IACdT,iBAAiBY,yBAAY,CAAAC,KAAA;AAC7BH,IAAAA,cAAgB,EAAA,QAAA;AAChBC,IAAAA,UAAY,EAAA,QAAA;AACZG,IAAAA,QAAU,EAAA,UAAA;AACVC,IAAAA,IAAM,EAAA,CAAA;AACR,GAAA;AACF,CAAC,CAAA;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var redsTokenNext = require('@xhs/reds-token-next');
|
|
4
|
-
|
|
5
|
-
var defaultProps = {
|
|
6
|
-
defaultValue: false,
|
|
7
|
-
disabled: false,
|
|
8
|
-
trackOnColor: redsTokenNext.lightColor.Primary,
|
|
9
|
-
trackOffColor: redsTokenNext.lightColor.Fill2
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.defaultProps = defaultProps;
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/NN/interface/index.ts"],"sourcesContent":["import { GestureResponderEvent } from \"react-native\";\nimport { lightColor } from \"@xhs/reds-token-next\";\nexport interface RedsNN {\n value?: boolean;\n defaultValue?: boolean;\n disabled?: boolean;\n trackOnColor?: string;\n trackOffColor?: string;\n onChange?: (value: boolean) => void;\n onClick?: (value: Event) => void;\n}\n\nexport const defaultProps: RedsNN = {\n defaultValue: false,\n disabled: false,\n trackOnColor: lightColor.Primary,\n trackOffColor: lightColor.Fill2,\n};\n"],"names":["defaultProps","defaultValue","disabled","trackOnColor","lightColor","Primary","trackOffColor","Fill2"],"mappings":";;;;AAYO,IAAMA,YAAuB,GAAA;AAClCC,EAAAA,YAAc,EAAA,KAAA;AACdC,EAAAA,QAAU,EAAA,KAAA;EACVC,cAAcC,wBAAW,CAAAC,OAAA;EACzBC,eAAeF,wBAAW,CAAAG,KAAAA;AAC5B;;;;"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_chunks/CAyGJuk1.js');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var reactNative = require('react-native');
|
|
8
|
-
var components_NNNN_interface_index = require('./interface/index.js');
|
|
9
|
-
var redsTokenNext = require('@xhs/reds-token-next');
|
|
10
|
-
|
|
11
|
-
var NNNN = function NNNN(_ref) {
|
|
12
|
-
var cValue = _ref.value,
|
|
13
|
-
defaultValue = _ref.defaultValue,
|
|
14
|
-
onChange = _ref.onChange,
|
|
15
|
-
onClick = _ref.onClick,
|
|
16
|
-
trackOnColor = _ref.trackOnColor,
|
|
17
|
-
trackOffColor = _ref.trackOffColor;
|
|
18
|
-
var isControlled = cValue !== void 0;
|
|
19
|
-
var _useState = React.useState(defaultValue),
|
|
20
|
-
_useState2 = _rollupPluginBabelHelpers._slicedToArray(_useState, 2),
|
|
21
|
-
value = _useState2[0],
|
|
22
|
-
setValue = _useState2[1];
|
|
23
|
-
var animatedValue = React.useRef(new reactNative.Animated.Value(defaultValue ? 18 : 2)).current;
|
|
24
|
-
var thumbTranslateX = React.useMemo(function () {
|
|
25
|
-
return animatedValue.interpolate({
|
|
26
|
-
inputRange: [2, 18],
|
|
27
|
-
outputRange: [2, 18]
|
|
28
|
-
});
|
|
29
|
-
}, []);
|
|
30
|
-
React.useEffect(function () {
|
|
31
|
-
isControlled && setValue(cValue);
|
|
32
|
-
onChange === null || onChange === void 0 || onChange(!!value);
|
|
33
|
-
reactNative.Animated.timing(animatedValue, {
|
|
34
|
-
toValue: value ? 18 : 2,
|
|
35
|
-
duration: 200,
|
|
36
|
-
useNativeDriver: true
|
|
37
|
-
}).start();
|
|
38
|
-
}, [value, cValue]);
|
|
39
|
-
var toggleNNNN = function toggleNNNN(e) {
|
|
40
|
-
onClick === null || onClick === void 0 || onClick(e);
|
|
41
|
-
!isControlled && setValue(function (v) {
|
|
42
|
-
return !v;
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
return /* @__PURE__ */React.createElement(reactNative.TouchableWithoutFeedback, {
|
|
46
|
-
onPress: function onPress(e) {
|
|
47
|
-
return toggleNNNN(e);
|
|
48
|
-
}
|
|
49
|
-
}, /* @__PURE__ */React.createElement(reactNative.View, {
|
|
50
|
-
style: [styles.container, {
|
|
51
|
-
backgroundColor: value ? trackOnColor : trackOffColor
|
|
52
|
-
}]
|
|
53
|
-
}, /* @__PURE__ */React.createElement(reactNative.Animated.View, {
|
|
54
|
-
style: [styles.thumb, {
|
|
55
|
-
transform: [{
|
|
56
|
-
translateX: thumbTranslateX
|
|
57
|
-
}]
|
|
58
|
-
}]
|
|
59
|
-
})));
|
|
60
|
-
};
|
|
61
|
-
NNNN.defaultProps = components_NNNN_interface_index.defaultProps;
|
|
62
|
-
var styles = reactNative.StyleSheet.create({
|
|
63
|
-
container: {
|
|
64
|
-
width: 40,
|
|
65
|
-
height: 24,
|
|
66
|
-
borderRadius: 15,
|
|
67
|
-
justifyContent: "center",
|
|
68
|
-
alignItems: "center"
|
|
69
|
-
},
|
|
70
|
-
thumb: {
|
|
71
|
-
width: 20,
|
|
72
|
-
height: 20,
|
|
73
|
-
borderRadius: 10,
|
|
74
|
-
backgroundColor: redsTokenNext.alwaysColor.White,
|
|
75
|
-
justifyContent: "center",
|
|
76
|
-
alignItems: "center",
|
|
77
|
-
position: "absolute",
|
|
78
|
-
left: 0
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
exports.default = NNNN;
|
|
83
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/NNNN/index.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, useMemo } from \"react\";\nimport { View, TouchableWithoutFeedback, StyleSheet, Animated, GestureResponderEvent } from \"react-native\";\nimport { RedsNNNN, defaultProps } from \"./interface/index\";\nimport { alwaysColor } from \"@xhs/reds-token-next\";\n\nconst NNNN = ({ value: cValue, defaultValue, onChange, onClick, trackOnColor, trackOffColor }: RedsNNNN) => {\n const isControlled = cValue !== undefined;\n const [value, setValue] = useState(defaultValue);\n\n const animatedValue = useRef(new Animated.Value(defaultValue ? 18 : 2)).current;\n\n const thumbTranslateX = useMemo(() => animatedValue.interpolate({ inputRange: [2, 18], outputRange: [2, 18] }), []);\n\n useEffect(() => {\n isControlled && setValue(cValue);\n onChange?.(!!value);\n Animated.timing(animatedValue, {\n toValue: value ? 18 : 2,\n duration: 200,\n useNativeDriver: true,\n }).start();\n }, [value, cValue]);\n\n const toggleNNNN = (e: GestureResponderEvent) => {\n onClick?.(e);\n !isControlled && setValue((v) => !v);\n };\n\n return (\n <TouchableWithoutFeedback onPress={(e) => toggleNNNN(e)}>\n <View style={[styles.container, { backgroundColor: value ? trackOnColor : trackOffColor }]}>\n <Animated.View style={[styles.thumb, { transform: [{ translateX: thumbTranslateX }] }]}></Animated.View>\n </View>\n </TouchableWithoutFeedback>\n );\n};\n\nNNNN.defaultProps = defaultProps;\n\nconst styles = StyleSheet.create({\n container: {\n width: 40,\n height: 24,\n borderRadius: 15,\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n thumb: {\n width: 20,\n height: 20,\n borderRadius: 10,\n backgroundColor: alwaysColor.White,\n justifyContent: \"center\",\n alignItems: \"center\",\n position: \"absolute\",\n left: 0,\n },\n});\n\nexport default NNNN;\n"],"names":["NNNN","_ref","cValue","value","defaultValue","onChange","onClick","trackOnColor","trackOffColor","isControlled","_useState","useState","_useState2","_slicedToArray","setValue","animatedValue","useRef","Animated","Value","current","thumbTranslateX","useMemo","interpolate","inputRange","outputRange","useEffect","timing","toValue","duration","useNativeDriver","start","toggleNNNN","e","v","TouchableWithoutFeedback","onPress","React","createElement","View","style","styles","container","backgroundColor","thumb","transform","translateX","defaultProps","StyleSheet","create","width","height","borderRadius","justifyContent","alignItems","alwaysColor","White","position","left"],"mappings":";;;;;;;;;;AAKA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,YAAc,EAAA,EAAA;AACdC,IAAAA,cAAgB,EAAA,QAAA;AAChBC,IAAAA,UAAY,EAAA,QAAA;GACd;AACAV,EAAAA,KAAO,EAAA;AACLM,IAAAA,KAAO,EAAA,EAAA;AACPC,IAAAA,MAAQ,EAAA,EAAA;AACRC,IAAAA,YAAc,EAAA,EAAA;IACdT,iBAAiBY,yBAAY,CAAAC,KAAA;AAC7BH,IAAAA,cAAgB,EAAA,QAAA;AAChBC,IAAAA,UAAY,EAAA,QAAA;AACZG,IAAAA,QAAU,EAAA,UAAA;AACVC,IAAAA,IAAM,EAAA,CAAA;AACR,GAAA;AACF,CAAC,CAAA;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var redsTokenNext = require('@xhs/reds-token-next');
|
|
4
|
-
|
|
5
|
-
var defaultProps = {
|
|
6
|
-
defaultValue: false,
|
|
7
|
-
disabled: false,
|
|
8
|
-
trackOnColor: redsTokenNext.lightColor.Primary,
|
|
9
|
-
trackOffColor: redsTokenNext.lightColor.Fill2
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.defaultProps = defaultProps;
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/NNNN/interface/index.ts"],"sourcesContent":["import { GestureResponderEvent } from \"react-native\";\nimport { lightColor } from \"@xhs/reds-token-next\";\nexport interface RedsNNNN {\n value?: boolean;\n defaultValue?: boolean;\n disabled?: boolean;\n trackOnColor?: string;\n trackOffColor?: string;\n onChange?: (value: boolean) => void;\n onClick?: (value: Event) => void;\n}\n\nexport const defaultProps: RedsNNNN = {\n defaultValue: false,\n disabled: false,\n trackOnColor: lightColor.Primary,\n trackOffColor: lightColor.Fill2,\n};\n"],"names":["defaultProps","defaultValue","disabled","trackOnColor","lightColor","Primary","trackOffColor","Fill2"],"mappings":";;;;AAYO,IAAMA,YAAyB,GAAA;AACpCC,EAAAA,YAAc,EAAA,KAAA;AACdC,EAAAA,QAAU,EAAA,KAAA;EACVC,cAAcC,wBAAW,CAAAC,OAAA;EACzBC,eAAeF,wBAAW,CAAAG,KAAAA;AAC5B;;;;"}
|