@xhsreds/reds-rn-next 0.10.1-beta202511211532 → 0.10.1-beta202512021041

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 (100) hide show
  1. package/coverage/.tmp/coverage-1.json +1 -1
  2. package/coverage/.tmp/coverage-10.json +1 -1
  3. package/coverage/.tmp/coverage-11.json +1 -1
  4. package/coverage/.tmp/coverage-12.json +1 -1
  5. package/coverage/.tmp/coverage-13.json +1 -1
  6. package/coverage/.tmp/coverage-14.json +1 -1
  7. package/coverage/.tmp/coverage-15.json +1 -1
  8. package/coverage/.tmp/coverage-16.json +1 -1
  9. package/coverage/.tmp/coverage-17.json +1 -1
  10. package/coverage/.tmp/coverage-18.json +1 -1
  11. package/coverage/.tmp/coverage-19.json +1 -1
  12. package/coverage/.tmp/coverage-2.json +1 -1
  13. package/coverage/.tmp/coverage-21.json +1 -1
  14. package/coverage/.tmp/coverage-22.json +1 -1
  15. package/coverage/.tmp/coverage-25.json +1 -1
  16. package/coverage/.tmp/coverage-26.json +1 -1
  17. package/coverage/.tmp/coverage-27.json +1 -1
  18. package/coverage/.tmp/coverage-28.json +1 -1
  19. package/coverage/.tmp/coverage-3.json +1 -1
  20. package/coverage/.tmp/coverage-31.json +1 -1
  21. package/coverage/.tmp/coverage-32.json +1 -1
  22. package/coverage/.tmp/coverage-33.json +1 -1
  23. package/coverage/.tmp/coverage-34.json +1 -1
  24. package/coverage/.tmp/coverage-35.json +1 -1
  25. package/coverage/.tmp/coverage-36.json +1 -1
  26. package/coverage/.tmp/coverage-37.json +1 -1
  27. package/coverage/.tmp/coverage-38.json +1 -1
  28. package/coverage/.tmp/coverage-39.json +1 -1
  29. package/coverage/.tmp/coverage-4.json +1 -1
  30. package/coverage/.tmp/coverage-40.json +1 -1
  31. package/coverage/.tmp/coverage-41.json +1 -1
  32. package/coverage/.tmp/coverage-42.json +1 -1
  33. package/coverage/.tmp/coverage-43.json +1 -1
  34. package/coverage/.tmp/coverage-5.json +1 -1
  35. package/coverage/.tmp/coverage-6.json +1 -1
  36. package/coverage/.tmp/coverage-7.json +1 -1
  37. package/coverage/.tmp/coverage-8.json +1 -1
  38. package/coverage/.tmp/coverage-9.json +1 -1
  39. package/lib/cjs/_chunks/hA3qoGpS.js.map +1 -1
  40. package/lib/cjs/components/ActionablePopover/ActionablePopover.js +2 -2
  41. package/lib/cjs/components/ActionablePopover/ActionablePopover.js.map +1 -1
  42. package/lib/cjs/components/BottomBar/styles.js +1 -1
  43. package/lib/cjs/components/BottomBar/styles.js.map +1 -1
  44. package/lib/cjs/components/Divider/Divider.js +33 -12
  45. package/lib/cjs/components/Divider/Divider.js.map +1 -1
  46. package/lib/cjs/components/Divider/index.js +3 -3
  47. package/lib/cjs/components/Divider/styles.js +36 -30
  48. package/lib/cjs/components/Divider/styles.js.map +1 -1
  49. package/lib/cjs/components/List/ListItem/ListItem.js +4 -2
  50. package/lib/cjs/components/List/ListItem/ListItem.js.map +1 -1
  51. package/lib/cjs/components/PickerView/Wheel.js +57 -16
  52. package/lib/cjs/components/PickerView/Wheel.js.map +1 -1
  53. package/lib/cjs/components/Stepper/Stepper.js +1 -1
  54. package/lib/cjs/components/Stepper/Stepper.js.map +1 -1
  55. package/lib/cjs/components/Stepper/styles.js +2 -2
  56. package/lib/cjs/components/Stepper/styles.js.map +1 -1
  57. package/lib/esm/_chunks/C0MWVrjO.js.map +1 -1
  58. package/lib/esm/components/ActionablePopover/ActionablePopover.js +1 -1
  59. package/lib/esm/components/ActionablePopover/ActionablePopover.js.map +1 -1
  60. package/lib/esm/components/BottomBar/styles.js +1 -1
  61. package/lib/esm/components/BottomBar/styles.js.map +1 -1
  62. package/lib/esm/components/Divider/Divider.js +35 -14
  63. package/lib/esm/components/Divider/Divider.js.map +1 -1
  64. package/lib/esm/components/Divider/index.js +3 -3
  65. package/lib/esm/components/Divider/styles.js +36 -30
  66. package/lib/esm/components/Divider/styles.js.map +1 -1
  67. package/lib/esm/components/List/ListItem/ListItem.js +5 -3
  68. package/lib/esm/components/List/ListItem/ListItem.js.map +1 -1
  69. package/lib/esm/components/PickerView/Wheel.js +57 -16
  70. package/lib/esm/components/PickerView/Wheel.js.map +1 -1
  71. package/lib/esm/components/Stepper/Stepper.js +1 -1
  72. package/lib/esm/components/Stepper/Stepper.js.map +1 -1
  73. package/lib/esm/components/Stepper/styles.js +2 -2
  74. package/lib/esm/components/Stepper/styles.js.map +1 -1
  75. package/lib/src/components/BottomBar/styles.d.ts +1 -1
  76. package/lib/src/components/Divider/styles.d.ts +3 -2
  77. package/lib/src/components/List/ListItem/ListItem.d.ts +2 -0
  78. package/lib/src/components/Stepper/interface/index.d.ts +1 -0
  79. package/lib/src/components/Stepper/styles.d.ts +2 -2
  80. package/lib/types/components/BottomBar/styles.d.ts +1 -1
  81. package/lib/types/components/Divider/styles.d.ts +3 -2
  82. package/lib/types/components/List/ListItem/ListItem.d.ts +2 -0
  83. package/lib/types/components/Stepper/interface/index.d.ts +1 -0
  84. package/lib/types/components/Stepper/styles.d.ts +2 -2
  85. package/package.json +2 -2
  86. package/src/components/ActionablePopover/ActionablePopover.tsx +10 -1
  87. package/src/components/BottomBar/styles.ts +1 -1
  88. package/src/components/Divider/Divider.tsx +29 -9
  89. package/src/components/Divider/demo/index.tsx +12 -6
  90. package/src/components/Divider/styles.ts +33 -30
  91. package/src/components/List/ListItem/ListItem.tsx +12 -1
  92. package/src/components/List/demo/index.tsx +2 -0
  93. package/src/components/PickerView/Wheel.tsx +59 -12
  94. package/src/components/Stepper/Stepper.tsx +1 -1
  95. package/src/components/Stepper/demo/index.tsx +1 -1
  96. package/src/components/Stepper/doc/index.mdx +1 -0
  97. package/src/components/Stepper/interface/index.ts +1 -0
  98. package/src/components/Stepper/styles.ts +2 -2
  99. package/src/i18n/@types/resources.d.ts +18 -18
  100. package/src/i18n/index.json +31 -31
@@ -15,6 +15,8 @@ export interface RedsListItem {
15
15
  contentStyle?: ViewStyle;
16
16
  badgeActionContent?: string;
17
17
  badgeTitleContent?: string;
18
+ style?: any;
19
+ lineStyle?: any;
18
20
  }
19
21
  declare const ListItem: React.FC<RedsListItem>;
20
22
  export default ListItem;
@@ -5,6 +5,7 @@ export interface RedsStepper {
5
5
  disable?: boolean;
6
6
  onChange?: (value: number) => any;
7
7
  isControl?: boolean;
8
+ style?: any;
8
9
  }
9
10
  export interface RedsStepperEvent {
10
11
  }
@@ -3,7 +3,8 @@ export declare const getStyles: (themeColor: any, typography: any) => {
3
3
  display: "flex";
4
4
  flexDirection: "row";
5
5
  alignItems: "center";
6
- justifyContent: "center";
6
+ justifyContent: "space-between";
7
+ width: number;
7
8
  };
8
9
  opacity: {
9
10
  opacity: number;
@@ -19,7 +20,6 @@ export declare const getStyles: (themeColor: any, typography: any) => {
19
20
  lineHeight: number;
20
21
  };
21
22
  text: {
22
- paddingHorizontal: number;
23
23
  fontWeight: any;
24
24
  fontSize: any;
25
25
  color: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xhsreds/reds-rn-next",
3
- "version": "0.10.1-beta202511211532",
3
+ "version": "0.10.1-beta202512021041",
4
4
  "author": "贾斌(呀哈) <jiabin@xiaohongshu.com>",
5
5
  "license": "ISC",
6
6
  "dependencies": {
@@ -26,7 +26,7 @@
26
26
  "react-native-fs": "2.20.0",
27
27
  "react-native-svg": "13.14.0",
28
28
  "@xhs/react-native-harmony": "*",
29
- "@xhsreds/reds-token-next": "0.10.1-beta202511211532"
29
+ "@xhsreds/reds-token-next": "0.10.1-beta202512021041"
30
30
  },
31
31
  "peerDependenciesMeta": {
32
32
  "ozone-schema-web": {
@@ -1,5 +1,14 @@
1
1
  import React, { useState, useMemo, isValidElement, useEffect, useRef } from "react";
2
- import { Text, View, TouchableWithoutFeedback, GestureResponderEvent, Animated, Image, Dimensions } from "react-native";
2
+ import {
3
+ Text,
4
+ View,
5
+ TouchableWithoutFeedback,
6
+ GestureResponderEvent,
7
+ Animated,
8
+ Image,
9
+ Dimensions,
10
+ Platform,
11
+ } from "react-native";
3
12
  import { RedsActionablePopover, ActionablePopoverData } from "./interface/index";
4
13
  import { ModalWrapper } from "./component";
5
14
  import useMounted from "../../pvCount/useUnmountedProcess";
@@ -5,7 +5,7 @@ export const getStyles = (themeColor: any) => {
5
5
  bottomBar: {
6
6
  width: "100%",
7
7
  padding: 8,
8
- backgroundColor: "inherit",
8
+ backgroundColor: themeColor.Bg,
9
9
  },
10
10
  fixed: {
11
11
  position: "absolute",
@@ -1,28 +1,48 @@
1
- import React from "react";
1
+ import React, { useState, useMemo } from "react";
2
2
  import { View, Text } from "react-native";
3
3
  import { RedsDivider, DividerDefaultProps } from "./interface";
4
4
  import { getStyles } from "./styles";
5
5
  import useMounted from "../../pvCount/useUnmountedProcess";
6
+ import { useThemeColor, useThemeTypography } from "../ConfigProvider";
6
7
 
7
8
  const Divider = (props: RedsDivider) => {
9
+ const [textWidth, setTextWidth] = useState(0);
10
+ const [containerWidth, setContainerWidth] = useState(0);
11
+ const themeColor = useThemeColor("Divider");
12
+ const typography = useThemeTypography("Divider");
8
13
  useMounted("Divider");
9
14
  const finalProps: RedsDivider = {
10
15
  ...DividerDefaultProps,
11
16
  ...props,
12
- direction: props.direction as RedsDivider["direction"],
13
- orientation: props.orientation as RedsDivider["orientation"],
17
+ direction: (props.direction || DividerDefaultProps.direction) as RedsDivider["direction"],
18
+ orientation: (props.orientation || DividerDefaultProps.orientation) as RedsDivider["orientation"],
14
19
  };
15
20
 
16
- const styles = getStyles(finalProps);
17
- const isPrimary = finalProps.direction === "primary" || finalProps.direction === "secondary";
21
+ const styles = useMemo(() => {
22
+ return getStyles(finalProps, textWidth, containerWidth, themeColor, typography);
23
+ }, [textWidth, containerWidth, themeColor, typography]);
24
+
25
+ const handleLayout = (e: any) => {
26
+ setTextWidth(e.nativeEvent.layout.width);
27
+ };
28
+
29
+ const handlerContainerWidth = (e: any) => {
30
+ setContainerWidth(e.nativeEvent.layout.width);
31
+ };
18
32
 
19
33
  return (
20
- <View style={[styles.divider, styles[finalProps.direction!]]}>
34
+ <View style={[styles.divider, styles[finalProps.direction!]]} onLayout={handlerContainerWidth}>
21
35
  {finalProps.orientation && finalProps.direction !== "vertical" && (
22
36
  <View style={styles.textContainer}>
23
- {isPrimary && <View style={styles.before} />}
24
- {props.children && <Text style={styles.text}>{props.children}</Text>}
25
- {isPrimary && <View style={styles.after} />}
37
+ <View style={styles.before} />
38
+ {props.children ? (
39
+ <Text style={styles.text} onLayout={handleLayout}>
40
+ {props.children}
41
+ </Text>
42
+ ) : (
43
+ <Text style={styles.noTextBorderStyle}></Text>
44
+ )}
45
+ <View style={styles.after} />
26
46
  </View>
27
47
  )}
28
48
  </View>
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from "react";
2
- import { View, Text, StyleSheet } from "react-native";
2
+ import { View, Text, StyleSheet, ScrollView } from "react-native";
3
3
  import { Divider } from "@xhs/reds-rn-next";
4
4
 
5
5
  const styles = StyleSheet.create({
@@ -21,23 +21,29 @@ const Br = (props: { height?: number }) => <View style={{ height: props.height |
21
21
 
22
22
  export default function App() {
23
23
  return (
24
- <View>
24
+ <ScrollView>
25
+ <Br />
26
+ <Br />
25
27
  <Desc>默认用法</Desc>
26
28
  <Divider>测试</Divider>
27
29
  <Br />
28
- <Desc>direction 类型用法</Desc>
30
+ <Desc>direction="primary"</Desc>
29
31
  <Divider direction="primary" orientation={"center"}>
30
32
  测试
31
33
  </Divider>
32
34
  <Br />
33
- <Divider direction="secondary">测试 </Divider>
35
+ <Desc>direction="secondary"</Desc>
36
+ <Divider direction="secondary" orientation={"center"}>
37
+ 测试
38
+ </Divider>
34
39
  <Br />
35
40
 
41
+ <Desc>direction="vertical"</Desc>
36
42
  <View style={styles.itemBox}>
37
43
  <Divider direction="vertical">测试</Divider>
38
44
  </View>
45
+ <Desc>direction="horizontal"</Desc>
39
46
  <Divider direction="horizontal">测试</Divider>
40
- <Divider direction="horizontal"></Divider>
41
47
  <Br />
42
48
  <Br />
43
49
 
@@ -67,6 +73,6 @@ export default function App() {
67
73
  <Desc>margin 数组:horizontal / [上下,左右] vertical / [左右]</Desc>
68
74
  <Divider margin={[10, 20]} stroke={2} direction="horizontal" />
69
75
  <Divider margin={[10, 0]} stroke={2} direction="vertical" />
70
- </View>
76
+ </ScrollView>
71
77
  );
72
78
  }
@@ -1,38 +1,30 @@
1
1
  import { StyleSheet, ViewStyle, TextStyle, DimensionValue } from "react-native";
2
2
  import { RedsDivider, DividerDefaultProps } from "./interface";
3
- import { useThemeColor, useThemeTypography } from "../ConfigProvider";
4
3
 
5
4
  const baseDivider: ViewStyle = {
6
5
  position: "relative",
7
6
  };
8
7
 
9
- const baseText: TextStyle = {
10
- paddingVertical: 0,
11
- paddingHorizontal: 16,
12
- position: "absolute",
13
- backgroundColor: "#fff",
14
- lineHeight: 18,
15
- };
16
-
17
- const getStyles = (p: RedsDivider) => {
8
+ const getStyles = (p: RedsDivider, textWidth: number, containerWidth: number, themeColor: any, typography: any) => {
18
9
  const props = { ...DividerDefaultProps, ...p };
19
- const themeColor = useThemeColor("Divider");
20
- const typography = useThemeTypography("Divider");
21
10
  const isHorizontal = props.direction === "horizontal";
11
+ const hasTextContent = p.children;
12
+
13
+ const remainingWidth = containerWidth - textWidth;
14
+
22
15
  const beforeAfterCommon: ViewStyle = {
23
16
  borderStyle: "solid",
24
- borderTopWidth: 0.5,
17
+ borderTopWidth: props.stroke || 0.5,
25
18
  borderColor: props.color || themeColor.Separator2,
26
- width: 8,
27
19
  };
28
20
 
29
21
  const dividerStyle: ViewStyle = {
30
22
  ...baseDivider,
31
- borderBottomWidth: isHorizontal ? (props.stroke ? props.stroke : StyleSheet.hairlineWidth) : 0,
32
- borderLeftWidth: isHorizontal ? 0 : props.stroke ? props.stroke : StyleSheet.hairlineWidth,
33
- borderBottomColor: isHorizontal ? props.color || themeColor.Separator2 : undefined,
34
- borderLeftColor: isHorizontal ? undefined : props.color || themeColor.Separator2,
35
- borderStyle: "solid",
23
+ // borderBottomWidth: isHorizontal && hasTextContent ? 0 : (isHorizontal ? (props.stroke ? props.stroke : StyleSheet.hairlineWidth) : 0),
24
+ // borderLeftWidth: isHorizontal ? 0 : props.stroke ? props.stroke : StyleSheet.hairlineWidth,
25
+ // borderBottomColor: isHorizontal && !hasTextContent ? props.color || themeColor.Separator2 : undefined,
26
+ // borderLeftColor: isHorizontal ? undefined : props.color || themeColor.Separator2,
27
+ // borderStyle: "solid",
36
28
  marginVertical: (props.margin && props.margin[0] && Number(props.margin[0])) || (isHorizontal ? 20 : 0),
37
29
  marginHorizontal: (props.margin && props.margin[1] && Number(props.margin[1])) || (isHorizontal ? 0 : 12),
38
30
  marginLeft:
@@ -47,17 +39,11 @@ const getStyles = (p: RedsDivider) => {
47
39
  width: (isHorizontal ? props.size : "auto") as DimensionValue,
48
40
  };
49
41
 
50
- const textContainer: TextStyle = {
51
- paddingVertical: 0,
52
- paddingHorizontal: 16,
53
- position: "absolute",
54
- lineHeight: 18,
55
- left: props.orientation === "left" ? 24 : undefined,
56
- right: props.orientation === "right" ? 24 : undefined,
57
- alignSelf: props.orientation === "center" ? "center" : undefined,
42
+ const textContainer: ViewStyle = {
58
43
  flexDirection: "row",
59
44
  alignItems: "center",
60
- top: (isHorizontal && -9) || 0,
45
+ width: "100%",
46
+ // 移除 position absolute,改为正常布局
61
47
  };
62
48
 
63
49
  const textStyle: TextStyle = {
@@ -78,13 +64,29 @@ const getStyles = (p: RedsDivider) => {
78
64
 
79
65
  const beforeStyle: ViewStyle = {
80
66
  ...beforeAfterCommon,
81
- marginRight: 8,
67
+ marginRight: props.children ? 8 : 0,
68
+ ...(isHorizontal
69
+ ? props.orientation === "center"
70
+ ? { flex: 1 }
71
+ : { width: props.orientation === "left" ? remainingWidth * 0.15 : remainingWidth * 0.85 }
72
+ : { width: 8 }),
82
73
  borderColor: props.direction === "secondary" ? "rgba(51, 51, 51, .3)" : props.color || themeColor.Separator2,
83
74
  };
84
75
 
85
76
  const afterStyle: ViewStyle = {
86
77
  ...beforeAfterCommon,
87
- marginLeft: 8,
78
+ marginLeft: props.children ? 8 : 0,
79
+ ...(isHorizontal
80
+ ? props.orientation === "center"
81
+ ? { flex: 1 }
82
+ : { width: props.orientation === "right" ? remainingWidth * 0.15 : remainingWidth * 0.85 }
83
+ : { width: 8 }),
84
+ borderColor: props.direction === "secondary" ? "rgba(51, 51, 51, .3)" : props.color || themeColor.Separator2,
85
+ };
86
+
87
+ const noTextBorderStyle: ViewStyle = {
88
+ ...beforeAfterCommon,
89
+ width: "auto",
88
90
  borderColor: props.direction === "secondary" ? "rgba(51, 51, 51, .3)" : props.color || themeColor.Separator2,
89
91
  };
90
92
 
@@ -104,6 +106,7 @@ const getStyles = (p: RedsDivider) => {
104
106
  text: textStyle,
105
107
  before: beforeStyle,
106
108
  after: afterStyle,
109
+ noTextBorderStyle: noTextBorderStyle,
107
110
  });
108
111
  };
109
112
 
@@ -21,6 +21,8 @@ export interface RedsListItem {
21
21
  contentStyle?: ViewStyle;
22
22
  badgeActionContent?: string;
23
23
  badgeTitleContent?: string;
24
+ style?: any;
25
+ lineStyle?: any;
24
26
  }
25
27
 
26
28
  const ListItem: React.FC<RedsListItem> = ({
@@ -38,6 +40,8 @@ const ListItem: React.FC<RedsListItem> = ({
38
40
  children,
39
41
  badgeActionContent,
40
42
  badgeTitleContent,
43
+ style,
44
+ lineStyle,
41
45
  }) => {
42
46
  useMounted("ListItem");
43
47
  const styles = createStyles();
@@ -66,6 +70,7 @@ const ListItem: React.FC<RedsListItem> = ({
66
70
  styles.listItem,
67
71
  children ? {} : { height: listItemSizeToHeight[size] },
68
72
  size === "expand" && styles.expand,
73
+ style,
69
74
  ]}
70
75
  >
71
76
  {children ? (
@@ -75,7 +80,13 @@ const ListItem: React.FC<RedsListItem> = ({
75
80
  {prefix && (
76
81
  <View style={[styles.prefix, { height: listItemSizeToHeight[size] }, prefixStyle]}>{prefix}</View>
77
82
  )}
78
- <View style={[styles.contentBox, lineItem ? styles.hr : {}, { height: listItemSizeToHeight[size] }]}>
83
+ <View
84
+ style={[
85
+ styles.contentBox,
86
+ lineItem ? { ...styles.hr, ...lineStyle } : {},
87
+ { height: listItemSizeToHeight[size] },
88
+ ]}
89
+ >
79
90
  <View
80
91
  style={[styles.contentContainer, { marginBottom: 12, marginTop: 12 }, prefix ? { height: 48 } : {}]}
81
92
  >
@@ -51,6 +51,8 @@ export default function ListDemo() {
51
51
  onClick={() => {
52
52
  console.log("click item");
53
53
  }}
54
+ // style={{ backgroundColor: 'blue'}}
55
+ lineStyle={{ borderBottomColor: "red" }}
54
56
  />
55
57
  <ListItem title="标题" actionText="描述" />
56
58
  </List>
@@ -15,31 +15,71 @@ const Wheel = (props: RedsWheel) => {
15
15
  */
16
16
  const scrollerRef = useRef();
17
17
 
18
- /**
19
- * themeColor
20
- */
21
- const themeColor = useThemeColor();
18
+ const [scrollEnded, setScrollEnded] = useState(false);
19
+
20
+ const [scrollHeight, setScrollHeight] = useState(0);
22
21
 
23
22
  const [lastValue, setLastValue] = useState(value);
24
23
 
24
+ const onScrollEndDrag = () => {
25
+ setScrollEnded(true);
26
+ };
27
+
25
28
  /**
26
29
  * 初始化滚动高度
27
30
  */
28
31
  useEffect(() => {
29
32
  if (value !== lastValue) {
30
33
  const idx = getSelectIndex(column, value);
31
- handleScroll(idx);
34
+ setIndex(idx);
32
35
  }
33
36
  }, [column, value]);
34
37
 
35
- const handleScroll = (idx: number) => {
36
- const newVal = column?.[idx]?.value;
37
- scrollTo(idx * itemHeight);
38
+ /**
39
+ * themeColor
40
+ */
41
+ const themeColor = useThemeColor();
42
+
43
+ /**
44
+ * index
45
+ */
46
+ const [index, setIndex] = useState<any>();
47
+
48
+ const timer = useRef<any>();
49
+
50
+ /**
51
+ * 初始化滚动高度
52
+ */
53
+ useEffect(() => {
54
+ value && setIndex(getSelectIndex(column, value));
55
+ }, [column, value]);
56
+
57
+ useEffect(() => {
58
+ const newVal = column?.[index]?.value;
59
+ scrollTo(index * itemHeight);
38
60
  if (newVal) {
39
- setLastValue(newVal);
40
61
  onSelect(newVal, props.index);
62
+ setLastValue(newVal);
41
63
  }
42
- };
64
+ }, [index, props.index]);
65
+
66
+ useEffect(() => {
67
+ if (scrollEnded) {
68
+ // @ts-ignore
69
+ if (scrollHeight != null) {
70
+ timer.current = setTimeout(() => {
71
+ const selectIndex = Math.round(scrollHeight / itemHeight);
72
+ if (selectIndex >= 0 && selectIndex < column.length) {
73
+ setIndex(selectIndex);
74
+ }
75
+ }, 0);
76
+ }
77
+ setScrollEnded(false);
78
+ }
79
+ return () => {
80
+ timer.current && clearTimeout(timer.current);
81
+ };
82
+ }, [scrollEnded]);
43
83
 
44
84
  /**
45
85
  * 滚动ScrollView
@@ -84,13 +124,17 @@ const Wheel = (props: RedsWheel) => {
84
124
  e.persist?.();
85
125
  let contentOffset = e.nativeEvent.contentOffset;
86
126
  const selectIndex = Math.round(contentOffset.y / itemHeight);
127
+ setIndex(selectIndex);
87
128
  const newVal = column?.[selectIndex]?.value;
88
129
  setLastValue(newVal);
89
- onSelect(newVal, props.index);
130
+ };
131
+
132
+ const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
133
+ setScrollHeight(e.nativeEvent.contentOffset.y);
90
134
  };
91
135
 
92
136
  const handleClick = (index: number) => {
93
- handleScroll(index);
137
+ setIndex(index);
94
138
  };
95
139
 
96
140
  /**
@@ -127,6 +171,9 @@ const Wheel = (props: RedsWheel) => {
127
171
  decelerationRate="fast"
128
172
  snapToInterval={itemHeight}
129
173
  onMomentumScrollEnd={onMomentumScrollEnd}
174
+ onScrollEndDrag={onScrollEndDrag}
175
+ onScroll={onScroll}
176
+ scrollEventThrottle={16}
130
177
  testID={`wheel${props.index}`}
131
178
  {...accessibility}
132
179
  >
@@ -84,7 +84,7 @@ const Stepper = (props: RedsStepper) => {
84
84
  }, [colorMode]);
85
85
 
86
86
  return (
87
- <View style={styles.container}>
87
+ <View style={[styles.container, props.style]}>
88
88
  <TouchableWithoutFeedback onPress={() => handleNumber("min")}>
89
89
  <View style={[styles.icon, minus]}>
90
90
  <Image source={{ uri: minusImage }} style={[styles.minus]} />
@@ -21,7 +21,7 @@ export default function App() {
21
21
  return (
22
22
  <View style={styles.container}>
23
23
  <Text>基础用法</Text>
24
- <Stepper value={value} onChange={handleChange} />
24
+ <Stepper value={value} onChange={handleChange} style={{ width: 200 }} />
25
25
 
26
26
  <Text>基础用法(非受控)</Text>
27
27
  <Stepper isControl={false} />
@@ -17,6 +17,7 @@ import BaseDemo from "!!raw-loader!../demo/index.tsx";
17
17
  | min | 最小值 | number | |
18
18
  | disable | disable | boolean | false |
19
19
  | isControl | 是否受控 | boolean | true |
20
+ | style | style | any | |
20
21
 
21
22
  ### Events
22
23
 
@@ -7,6 +7,7 @@ export interface RedsStepper {
7
7
  disable?: boolean;
8
8
  onChange?: (value: number) => any;
9
9
  isControl?: boolean;
10
+ style?: any;
10
11
  }
11
12
 
12
13
  export interface RedsStepperEvent {}
@@ -5,7 +5,8 @@ export const getStyles = (themeColor: any, typography: any) => {
5
5
  display: "flex",
6
6
  flexDirection: "row",
7
7
  alignItems: "center",
8
- justifyContent: "center",
8
+ justifyContent: "space-between",
9
+ width: 72,
9
10
  },
10
11
  opacity: {
11
12
  opacity: 0.5,
@@ -21,7 +22,6 @@ export const getStyles = (themeColor: any, typography: any) => {
21
22
  lineHeight: 20,
22
23
  },
23
24
  text: {
24
- paddingHorizontal: 8,
25
25
  fontWeight: typography.B1LooseFontWeight,
26
26
  fontSize: typography.T3FontSize,
27
27
  color: themeColor.Title,
@@ -1,31 +1,31 @@
1
1
  interface Resources {
2
2
  componentKey: {
3
- sureKey: "确定";
4
- satisfyKey: "满意";
5
- confirmKey: "确认";
6
- uploadingKey: "上传中";
3
+ sureKey: "確定";
4
+ satisfyKey: "滿意";
5
+ confirmKey: "確認";
6
+ uploadingKey: "上傳中";
7
7
  resetKey: "重置";
8
- NoDataKey: "暂无数据";
8
+ NoDataKey: "暫無數據";
9
9
  liveStreamingKey: "直播";
10
10
  generallyKey: "一般";
11
- uploadFailedKey: "上传失败";
11
+ uploadFailedKey: "上傳失敗";
12
12
  submitKey: "提交";
13
- requestSuccessfulKey: "请求成功";
13
+ requestSuccessfulKey: "請求成功";
14
14
  cancelKey: "取消";
15
- PullDownToRefreshKey: "下拉刷新";
16
- selectAllKey: "全选";
17
- requestDataKey: "请求数据中";
15
+ PullDownToRefreshKey: "下拉重繪";
16
+ selectAllKey: "全選";
17
+ requestDataKey: "請求數據中";
18
18
  closeKey: "收起";
19
- veryBadKey: "极差";
20
- searchKey: "搜索";
21
- expandKey: "展开";
22
- IDCardPhotoKey: "身份证人像面";
19
+ veryBadKey: "極差";
20
+ searchKey: "蒐索";
21
+ expandKey: "展開";
22
+ IDCardPhotoKey: "身份證人像面";
23
23
  finishKey: "完成";
24
- surpriseKey: "惊喜";
25
- releaseRefreshKey: "松开刷新";
24
+ surpriseKey: "驚喜";
25
+ releaseRefreshKey: "鬆開重繪";
26
26
  nationalEmblemSideOfIDCardKey: "身份证国徽面";
27
- buttonKey: "按钮";
28
- jumpKey: "跳转";
27
+ buttonKey: "按鈕";
28
+ jumpKey: "跳轉";
29
29
  disappointmentKey: "失望";
30
30
  };
31
31
  }
@@ -1,35 +1,4 @@
1
1
  {
2
- "zh_cn": {
3
- "componentKey": {
4
- "sureKey": "确定",
5
- "satisfyKey": "满意",
6
- "confirmKey": "确认",
7
- "uploadingKey": "上传中",
8
- "resetKey": "重置",
9
- "NoDataKey": "暂无数据",
10
- "liveStreamingKey": "直播",
11
- "generallyKey": "一般",
12
- "uploadFailedKey": "上传失败",
13
- "submitKey": "提交",
14
- "requestSuccessfulKey": "请求成功",
15
- "cancelKey": "取消",
16
- "PullDownToRefreshKey": "下拉刷新",
17
- "selectAllKey": "全选",
18
- "requestDataKey": "请求数据中",
19
- "closeKey": "收起",
20
- "veryBadKey": "极差",
21
- "searchKey": "搜索",
22
- "expandKey": "展开",
23
- "IDCardPhotoKey": "身份证人像面",
24
- "finishKey": "完成",
25
- "surpriseKey": "惊喜",
26
- "releaseRefreshKey": "松开刷新",
27
- "nationalEmblemSideOfIDCardKey": "身份证国徽面",
28
- "buttonKey": "按钮",
29
- "jumpKey": "跳转",
30
- "disappointmentKey": "失望"
31
- }
32
- },
33
2
  "zh_tw": {
34
3
  "componentKey": {
35
4
  "sureKey": "確定",
@@ -91,5 +60,36 @@
91
60
  "jumpKey": "Jump",
92
61
  "disappointmentKey": "Disappointment"
93
62
  }
63
+ },
64
+ "zh_cn": {
65
+ "componentKey": {
66
+ "sureKey": "确定",
67
+ "satisfyKey": "满意",
68
+ "confirmKey": "确认",
69
+ "uploadingKey": "上传中",
70
+ "resetKey": "重置",
71
+ "NoDataKey": "暂无数据",
72
+ "liveStreamingKey": "直播",
73
+ "generallyKey": "一般",
74
+ "uploadFailedKey": "上传失败",
75
+ "submitKey": "提交",
76
+ "requestSuccessfulKey": "请求成功",
77
+ "cancelKey": "取消",
78
+ "PullDownToRefreshKey": "下拉刷新",
79
+ "selectAllKey": "全选",
80
+ "requestDataKey": "请求数据中",
81
+ "closeKey": "收起",
82
+ "veryBadKey": "极差",
83
+ "searchKey": "搜索",
84
+ "expandKey": "展开",
85
+ "IDCardPhotoKey": "身份证人像面",
86
+ "finishKey": "完成",
87
+ "surpriseKey": "惊喜",
88
+ "releaseRefreshKey": "松开刷新",
89
+ "nationalEmblemSideOfIDCardKey": "身份证国徽面",
90
+ "buttonKey": "按钮",
91
+ "jumpKey": "跳转",
92
+ "disappointmentKey": "失望"
93
+ }
94
94
  }
95
95
  }