@tap-payments/os-micro-frontend-shared 0.0.309 → 0.0.311
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.
|
@@ -5,6 +5,7 @@ export type ScrollLoaderProps<IRootProps extends object = StackProps> = PropsWit
|
|
|
5
5
|
loadMoreItems: () => Promise<unknown>;
|
|
6
6
|
loading?: boolean;
|
|
7
7
|
hasMore?: boolean;
|
|
8
|
+
isFetchingNextPage: boolean;
|
|
8
9
|
}>;
|
|
9
10
|
declare const ScrollLoader: <IRootProps extends object = StackProps>(props: ScrollLoaderProps<IRootProps>) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export default ScrollLoader;
|
|
@@ -19,20 +19,24 @@ const isNearBottom = (el, offset = OFFSET) => {
|
|
|
19
19
|
return scrollHeight - scrollBottom <= offset;
|
|
20
20
|
};
|
|
21
21
|
const ScrollLoader = (props) => {
|
|
22
|
-
const { component = Stack, loadMoreItems, hasMore, loading, children } = props, rootProps = __rest(props, ["component", "loadMoreItems", "hasMore", "loading", "children"]);
|
|
22
|
+
const { component = Stack, loadMoreItems, hasMore, loading, isFetchingNextPage, children } = props, rootProps = __rest(props, ["component", "loadMoreItems", "hasMore", "loading", "isFetchingNextPage", "children"]);
|
|
23
23
|
const [initialChecked, setInitialChecked] = useState(false);
|
|
24
24
|
const loadMoreItemsRef = useRef(loadMoreItems);
|
|
25
25
|
const containerRef = useRef(null);
|
|
26
26
|
loadMoreItemsRef.current = loadMoreItems;
|
|
27
27
|
const Component = component;
|
|
28
|
+
const fetchMoreData = useCallback(() => {
|
|
29
|
+
if (hasMore && !isFetchingNextPage)
|
|
30
|
+
loadMoreItemsRef.current();
|
|
31
|
+
}, [hasMore, isFetchingNextPage]);
|
|
28
32
|
const handleScroll = useCallback(() => {
|
|
29
33
|
const el = containerRef.current;
|
|
30
|
-
if (!el
|
|
34
|
+
if (!el)
|
|
31
35
|
return;
|
|
32
36
|
const isBottom = isNearBottom(el);
|
|
33
37
|
if (isBottom)
|
|
34
|
-
|
|
35
|
-
}, [
|
|
38
|
+
fetchMoreData();
|
|
39
|
+
}, [fetchMoreData]);
|
|
36
40
|
useEffect(() => {
|
|
37
41
|
const el = containerRef.current;
|
|
38
42
|
if (!el)
|
|
@@ -42,19 +46,19 @@ const ScrollLoader = (props) => {
|
|
|
42
46
|
}, [handleScroll]);
|
|
43
47
|
useEffect(() => {
|
|
44
48
|
const el = containerRef.current;
|
|
45
|
-
if (!el || loading)
|
|
49
|
+
if (!el || loading || initialChecked)
|
|
46
50
|
return;
|
|
47
51
|
const timeout = setTimeout(() => {
|
|
52
|
+
setInitialChecked(true);
|
|
48
53
|
const isBottom = isNearBottom(el);
|
|
49
|
-
if (isBottom
|
|
50
|
-
|
|
51
|
-
setInitialChecked(true);
|
|
54
|
+
if (isBottom) {
|
|
55
|
+
fetchMoreData();
|
|
52
56
|
}
|
|
53
|
-
},
|
|
57
|
+
}, 1000);
|
|
54
58
|
return () => {
|
|
55
59
|
clearTimeout(timeout);
|
|
56
60
|
};
|
|
57
|
-
}, [loading, initialChecked]);
|
|
61
|
+
}, [loading, fetchMoreData, initialChecked]);
|
|
58
62
|
return (_jsx(Component, Object.assign({ overflow: "auto", ref: containerRef, style: {
|
|
59
63
|
overflow: 'auto',
|
|
60
64
|
height: '100%',
|
|
@@ -29,5 +29,8 @@ export declare enum ChargeBreakDownType {
|
|
|
29
29
|
PaymentCurrency = "PAYMENT_CURRENCY",
|
|
30
30
|
PaymentScheme = "PAYMENT_SCHEME",
|
|
31
31
|
PaymentType = "PAYMENT_TYPE",
|
|
32
|
-
PaymentLocation = "PAYMENT_LOCATION"
|
|
32
|
+
PaymentLocation = "PAYMENT_LOCATION",
|
|
33
|
+
PaymentIssuer = "PAYMENT_ISSUER",
|
|
34
|
+
PaymentAcquirer = "PAYMENT_ACQUIRER",
|
|
35
|
+
PaymentGateway = "PAYMENT_GATEWAY"
|
|
33
36
|
}
|
package/build/types/analytics.js
CHANGED
|
@@ -5,4 +5,7 @@ export var ChargeBreakDownType;
|
|
|
5
5
|
ChargeBreakDownType["PaymentScheme"] = "PAYMENT_SCHEME";
|
|
6
6
|
ChargeBreakDownType["PaymentType"] = "PAYMENT_TYPE";
|
|
7
7
|
ChargeBreakDownType["PaymentLocation"] = "PAYMENT_LOCATION";
|
|
8
|
+
ChargeBreakDownType["PaymentIssuer"] = "PAYMENT_ISSUER";
|
|
9
|
+
ChargeBreakDownType["PaymentAcquirer"] = "PAYMENT_ACQUIRER";
|
|
10
|
+
ChargeBreakDownType["PaymentGateway"] = "PAYMENT_GATEWAY";
|
|
8
11
|
})(ChargeBreakDownType || (ChargeBreakDownType = {}));
|
package/package.json
CHANGED