@xhsreds/reds-rn-next 0.9.1-feat-image-2202510231126 → 0.9.1-test.1
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/CHANGELOG.md +13 -0
- package/coverage/.tmp/coverage-13.json +1 -1
- package/coverage/.tmp/coverage-14.json +1 -1
- package/coverage/.tmp/coverage-15.json +1 -1
- package/coverage/.tmp/coverage-19.json +1 -1
- package/coverage/.tmp/coverage-20.json +1 -1
- package/coverage/.tmp/coverage-21.json +1 -1
- package/coverage/.tmp/coverage-22.json +1 -1
- package/coverage/.tmp/coverage-23.json +1 -1
- package/coverage/.tmp/coverage-26.json +1 -1
- package/coverage/.tmp/coverage-27.json +1 -1
- package/coverage/.tmp/coverage-32.json +1 -1
- package/coverage/.tmp/coverage-33.json +1 -1
- package/coverage/.tmp/coverage-34.json +1 -1
- package/coverage/.tmp/coverage-35.json +1 -1
- package/coverage/.tmp/coverage-36.json +1 -1
- package/coverage/.tmp/coverage-37.json +1 -1
- package/coverage/.tmp/coverage-38.json +1 -1
- package/coverage/.tmp/coverage-39.json +1 -1
- package/coverage/.tmp/coverage-6.json +1 -1
- package/coverage/.tmp/coverage-7.json +1 -1
- package/coverage/.tmp/coverage-8.json +1 -1
- package/lib/cjs/components/Image/VisibilitySensor.js +76 -18
- package/lib/cjs/components/Image/VisibilitySensor.js.map +1 -1
- package/lib/cjs/components/Radio/Radio.js.map +1 -1
- package/lib/cjs/pvCount/pvData.js +1 -1
- package/lib/esm/components/Image/VisibilitySensor.js +78 -20
- package/lib/esm/components/Image/VisibilitySensor.js.map +1 -1
- package/lib/esm/components/Radio/Radio.js.map +1 -1
- package/lib/esm/pvCount/pvData.js +1 -1
- package/package.json +1 -1
- package/src/components/Image/VisibilitySensor.tsx +84 -30
- package/src/i18n/@types/resources.d.ts +27 -27
- package/src/i18n/index.json +31 -31
- package/src/index.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { push, pushByrequestIdleCallback } from '@xhs/reds-apm/src/index.native';
|
|
2
2
|
|
|
3
3
|
var name = "@xhs/reds-rn-next";
|
|
4
|
-
var version = "0.9.
|
|
4
|
+
var version = "0.9.1-test.1";
|
|
5
5
|
var author = "贾斌(呀哈) <jiabin@xiaohongshu.com>";
|
|
6
6
|
var license = "ISC";
|
|
7
7
|
var dependencies = {
|
package/package.json
CHANGED
|
@@ -1,44 +1,98 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, forwardRef, useImperativeHandle } from "react";
|
|
2
|
-
import { Dimensions, View } from "react-native";
|
|
3
|
-
import type { VisibilitySensorRef, VisibilitySensorProps } from "./interface/visibilitySensor";
|
|
4
|
-
|
|
5
|
-
//
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState, forwardRef, useImperativeHandle } from "react";
|
|
2
|
+
import { Dimensions, type ScaledSize, View } from "react-native";
|
|
3
|
+
import type { VisibilitySensorRef, VisibilitySensorProps, RectDimensionsState } from "./interface/visibilitySensor";
|
|
4
|
+
// function useInterval(callback: () => void, delay: number | null) {
|
|
5
|
+
// const savedCallback = useRef(callback);
|
|
6
|
+
// useEffect(() => {
|
|
7
|
+
// savedCallback.current = callback;
|
|
8
|
+
// }, [callback]);
|
|
9
|
+
// useEffect(() => {
|
|
10
|
+
// if (delay === null || delay === undefined) {
|
|
11
|
+
// return;
|
|
12
|
+
// }
|
|
13
|
+
// const id = setInterval(() => savedCallback.current(), delay);
|
|
14
|
+
// return () => clearInterval(id);
|
|
15
|
+
// }, [delay]);
|
|
16
|
+
// }
|
|
6
17
|
const VisibilitySensor = forwardRef<VisibilitySensorRef, VisibilitySensorProps>((props, ref) => {
|
|
7
|
-
const { onChange, disabled = false, threshold = {}, children, ...rest } = props;
|
|
18
|
+
const { onChange, disabled = false, triggerOnce = false, delay, threshold = {}, children, ...rest } = props;
|
|
8
19
|
const localRef = useRef<View>(null);
|
|
9
|
-
const
|
|
10
|
-
|
|
20
|
+
const hasMountedRef = useRef(false);
|
|
11
21
|
useImperativeHandle(ref, () => ({
|
|
12
22
|
getInnerRef: () => localRef.current,
|
|
13
23
|
}));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const [rectDimensions, setRectDimensions] = useState<RectDimensionsState>({
|
|
25
|
+
rectTop: 0,
|
|
26
|
+
rectBottom: 0,
|
|
27
|
+
rectLeft: 0,
|
|
28
|
+
rectRight: 0,
|
|
29
|
+
rectWidth: 0,
|
|
30
|
+
rectHeight: 0,
|
|
31
|
+
});
|
|
32
|
+
const [lastValue, setLastValue] = useState<boolean | undefined>(undefined);
|
|
33
|
+
const [active, setActive] = useState<boolean>(false);
|
|
34
|
+
const measureInnerView = () => {
|
|
35
|
+
if (!active) return;
|
|
36
|
+
localRef.current?.measure((_x: number, _y: number, width: number, height: number, pageX: number, pageY: number) => {
|
|
37
|
+
const dimensions = {
|
|
38
|
+
rectTop: pageY,
|
|
39
|
+
rectBottom: pageY + height,
|
|
40
|
+
rectLeft: pageX,
|
|
41
|
+
rectRight: pageX + width,
|
|
42
|
+
rectWidth: width,
|
|
43
|
+
rectHeight: height,
|
|
44
|
+
};
|
|
45
|
+
if (
|
|
46
|
+
rectDimensions.rectTop !== dimensions.rectTop ||
|
|
47
|
+
rectDimensions.rectBottom !== dimensions.rectBottom ||
|
|
48
|
+
rectDimensions.rectLeft !== dimensions.rectLeft ||
|
|
49
|
+
rectDimensions.rectRight !== dimensions.rectRight ||
|
|
50
|
+
rectDimensions.rectWidth !== dimensions.rectWidth ||
|
|
51
|
+
rectDimensions.rectHeight !== dimensions.rectHeight
|
|
52
|
+
) {
|
|
53
|
+
setRectDimensions(dimensions);
|
|
54
|
+
}
|
|
27
55
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
56
|
+
};
|
|
57
|
+
// useInterval(measureInnerView, delay || 100);
|
|
58
|
+
const startWatching = useCallback(() => {
|
|
59
|
+
if (!active) setActive(true);
|
|
60
|
+
}, [active]);
|
|
61
|
+
const stopWatching = useCallback(() => {
|
|
62
|
+
if (active) setActive(false);
|
|
63
|
+
}, [active]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!disabled) {
|
|
66
|
+
startWatching();
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
stopWatching();
|
|
70
|
+
};
|
|
71
|
+
}, [disabled, startWatching, stopWatching]);
|
|
31
72
|
useEffect(() => {
|
|
32
|
-
if (!
|
|
33
|
-
|
|
73
|
+
if (!hasMountedRef.current) {
|
|
74
|
+
hasMountedRef.current = true;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const window: ScaledSize = Dimensions.get("window");
|
|
78
|
+
const isVisible: boolean =
|
|
79
|
+
rectDimensions.rectTop + (threshold.top || 0) <= window.height && // Top edge is within the bottom of the window
|
|
80
|
+
rectDimensions.rectBottom - (threshold.bottom || 0) >= 0 && // Bottom edge is within the top of the window
|
|
81
|
+
rectDimensions.rectLeft + (threshold.left || 0) <= window.width && // Left edge is within the right of the window
|
|
82
|
+
rectDimensions.rectRight - (threshold.right || 0) >= 0; // Right edge is within the left of the window
|
|
83
|
+
if (lastValue !== isVisible) {
|
|
84
|
+
setLastValue(isVisible);
|
|
85
|
+
onChange(isVisible);
|
|
86
|
+
if (isVisible && triggerOnce) {
|
|
87
|
+
stopWatching();
|
|
88
|
+
}
|
|
34
89
|
}
|
|
35
|
-
|
|
36
|
-
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
}, [rectDimensions, lastValue]);
|
|
37
92
|
return (
|
|
38
|
-
<View ref={localRef} {...rest} onLayout={
|
|
93
|
+
<View ref={localRef} {...rest} onLayout={() => measureInnerView()}>
|
|
39
94
|
{children}
|
|
40
95
|
</View>
|
|
41
96
|
);
|
|
42
97
|
});
|
|
43
|
-
|
|
44
98
|
export default VisibilitySensor;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
interface Resources {
|
|
2
2
|
componentKey: {
|
|
3
|
-
sureKey: "
|
|
4
|
-
satisfyKey: "
|
|
5
|
-
confirmKey: "
|
|
6
|
-
uploadingKey: "
|
|
7
|
-
resetKey: "
|
|
8
|
-
NoDataKey: "
|
|
9
|
-
liveStreamingKey: "
|
|
10
|
-
generallyKey: "
|
|
11
|
-
uploadFailedKey: "
|
|
12
|
-
submitKey: "
|
|
13
|
-
requestSuccessfulKey: "
|
|
14
|
-
cancelKey: "
|
|
15
|
-
PullDownToRefreshKey: "
|
|
16
|
-
selectAllKey: "
|
|
17
|
-
requestDataKey: "
|
|
18
|
-
closeKey: "
|
|
19
|
-
veryBadKey: "
|
|
20
|
-
searchKey: "
|
|
21
|
-
expandKey: "
|
|
22
|
-
IDCardPhotoKey: "
|
|
23
|
-
finishKey: "
|
|
24
|
-
surpriseKey: "
|
|
25
|
-
releaseRefreshKey: "
|
|
26
|
-
nationalEmblemSideOfIDCardKey: "
|
|
27
|
-
buttonKey: "
|
|
28
|
-
jumpKey: "
|
|
29
|
-
disappointmentKey: "
|
|
3
|
+
sureKey: "确定";
|
|
4
|
+
satisfyKey: "满意";
|
|
5
|
+
confirmKey: "确认";
|
|
6
|
+
uploadingKey: "上传中";
|
|
7
|
+
resetKey: "重置";
|
|
8
|
+
NoDataKey: "暂无数据";
|
|
9
|
+
liveStreamingKey: "直播";
|
|
10
|
+
generallyKey: "一般";
|
|
11
|
+
uploadFailedKey: "上传失败";
|
|
12
|
+
submitKey: "提交";
|
|
13
|
+
requestSuccessfulKey: "请求成功";
|
|
14
|
+
cancelKey: "取消";
|
|
15
|
+
PullDownToRefreshKey: "下拉刷新";
|
|
16
|
+
selectAllKey: "全选";
|
|
17
|
+
requestDataKey: "请求数据中";
|
|
18
|
+
closeKey: "收起";
|
|
19
|
+
veryBadKey: "极差";
|
|
20
|
+
searchKey: "搜索";
|
|
21
|
+
expandKey: "展开";
|
|
22
|
+
IDCardPhotoKey: "身份证人像面";
|
|
23
|
+
finishKey: "完成";
|
|
24
|
+
surpriseKey: "惊喜";
|
|
25
|
+
releaseRefreshKey: "松开刷新";
|
|
26
|
+
nationalEmblemSideOfIDCardKey: "身份证国徽面";
|
|
27
|
+
buttonKey: "按钮";
|
|
28
|
+
jumpKey: "跳转";
|
|
29
|
+
disappointmentKey: "失望";
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
export default Resources;
|
package/src/i18n/index.json
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"en_us": {
|
|
3
|
-
"componentKey": {
|
|
4
|
-
"sureKey": "Confirm",
|
|
5
|
-
"satisfyKey": "Satisfy",
|
|
6
|
-
"confirmKey": "Confirm",
|
|
7
|
-
"uploadingKey": "Uploading",
|
|
8
|
-
"resetKey": "Reset",
|
|
9
|
-
"NoDataKey": "No data available at the moment",
|
|
10
|
-
"liveStreamingKey": "live",
|
|
11
|
-
"generallyKey": "Generally",
|
|
12
|
-
"uploadFailedKey": "Upload failed",
|
|
13
|
-
"submitKey": "Submit",
|
|
14
|
-
"requestSuccessfulKey": "Request successful",
|
|
15
|
-
"cancelKey": "Cancel",
|
|
16
|
-
"PullDownToRefreshKey": "Pull down to refresh",
|
|
17
|
-
"selectAllKey": "SelectAll",
|
|
18
|
-
"requestDataKey": "Request data",
|
|
19
|
-
"closeKey": "Close",
|
|
20
|
-
"veryBadKey": "Very bad",
|
|
21
|
-
"searchKey": "Search",
|
|
22
|
-
"expandKey": "Expand",
|
|
23
|
-
"IDCardPhotoKey": "ID card photo",
|
|
24
|
-
"finishKey": "Finish",
|
|
25
|
-
"surpriseKey": "Surprise",
|
|
26
|
-
"releaseRefreshKey": "Release refresh",
|
|
27
|
-
"nationalEmblemSideOfIDCardKey": "National emblem side of ID card",
|
|
28
|
-
"buttonKey": "Button",
|
|
29
|
-
"jumpKey": "Jump",
|
|
30
|
-
"disappointmentKey": "Disappointment"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
2
|
"zh_cn": {
|
|
34
3
|
"componentKey": {
|
|
35
4
|
"sureKey": "确定",
|
|
@@ -91,5 +60,36 @@
|
|
|
91
60
|
"jumpKey": "跳轉",
|
|
92
61
|
"disappointmentKey": "失望"
|
|
93
62
|
}
|
|
63
|
+
},
|
|
64
|
+
"en_us": {
|
|
65
|
+
"componentKey": {
|
|
66
|
+
"sureKey": "Confirm",
|
|
67
|
+
"satisfyKey": "Satisfy",
|
|
68
|
+
"confirmKey": "Confirm",
|
|
69
|
+
"uploadingKey": "Uploading",
|
|
70
|
+
"resetKey": "Reset",
|
|
71
|
+
"NoDataKey": "No data available at the moment",
|
|
72
|
+
"liveStreamingKey": "live",
|
|
73
|
+
"generallyKey": "Generally",
|
|
74
|
+
"uploadFailedKey": "Upload failed",
|
|
75
|
+
"submitKey": "Submit",
|
|
76
|
+
"requestSuccessfulKey": "Request successful",
|
|
77
|
+
"cancelKey": "Cancel",
|
|
78
|
+
"PullDownToRefreshKey": "Pull down to refresh",
|
|
79
|
+
"selectAllKey": "SelectAll",
|
|
80
|
+
"requestDataKey": "Request data",
|
|
81
|
+
"closeKey": "Close",
|
|
82
|
+
"veryBadKey": "Very bad",
|
|
83
|
+
"searchKey": "Search",
|
|
84
|
+
"expandKey": "Expand",
|
|
85
|
+
"IDCardPhotoKey": "ID card photo",
|
|
86
|
+
"finishKey": "Finish",
|
|
87
|
+
"surpriseKey": "Surprise",
|
|
88
|
+
"releaseRefreshKey": "Release refresh",
|
|
89
|
+
"nationalEmblemSideOfIDCardKey": "National emblem side of ID card",
|
|
90
|
+
"buttonKey": "Button",
|
|
91
|
+
"jumpKey": "Jump",
|
|
92
|
+
"disappointmentKey": "Disappointment"
|
|
93
|
+
}
|
|
94
94
|
}
|
|
95
95
|
}
|
package/src/index.ts
CHANGED