@swan-io/lake 8.18.1 → 8.18.3
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/package.json
CHANGED
|
@@ -39,17 +39,19 @@ export type VirtualizedListProps<T, ExtraInfo> = {
|
|
|
39
39
|
onEndReachedThreshold?: number;
|
|
40
40
|
getRowLink?: (config: LinkConfig<T, ExtraInfo>) => ReactElement | undefined;
|
|
41
41
|
renderEmptyList?: () => ReactNode;
|
|
42
|
+
marginHorizontal?: string;
|
|
42
43
|
loading?: {
|
|
43
44
|
isLoading: boolean;
|
|
44
45
|
count: number;
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
|
-
export declare const VirtualizedList: <T, ExtraInfo>({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold, onEndReached, onEndReachedThreshold, loading, extraInfo, keyExtractor, }: VirtualizedListProps<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare const VirtualizedList: <T, ExtraInfo>({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold, onEndReached, onEndReachedThreshold, loading, extraInfo, keyExtractor, marginHorizontal, }: VirtualizedListProps<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
|
|
48
49
|
type VirtualizedListPlaceholderProps = {
|
|
49
50
|
count: number;
|
|
50
51
|
rowHeight: number;
|
|
51
52
|
groupHeaderHeight?: number;
|
|
52
53
|
headerHeight?: number;
|
|
54
|
+
marginHorizontal?: string;
|
|
53
55
|
};
|
|
54
|
-
export declare const VirtualizedListPlaceholder: ({ count, rowHeight, groupHeaderHeight, headerHeight, }: VirtualizedListPlaceholderProps) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare const VirtualizedListPlaceholder: ({ count, rowHeight, groupHeaderHeight, headerHeight, marginHorizontal, }: VirtualizedListPlaceholderProps) => import("react/jsx-runtime").JSX.Element;
|
|
55
57
|
export {};
|
|
@@ -3,10 +3,11 @@ import { Option } from "@swan-io/boxed";
|
|
|
3
3
|
import { cloneElement, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
4
4
|
import { StyleSheet, View } from "react-native";
|
|
5
5
|
import { commonStyles } from "../constants/commonStyles";
|
|
6
|
-
import { backgroundColor as backgroundColorVariants, colors, spacings } from "../constants/design";
|
|
6
|
+
import { backgroundColor as backgroundColorVariants, colors, negativeSpacings, spacings, } from "../constants/design";
|
|
7
7
|
import { useHover } from "../hooks/useHover";
|
|
8
8
|
import { ScrollView } from "./ScrollView";
|
|
9
9
|
import { Space } from "./Space";
|
|
10
|
+
const HORIZONTAL_ROW_PADDING = 8;
|
|
10
11
|
const styles = StyleSheet.create({
|
|
11
12
|
container: {
|
|
12
13
|
...commonStyles.fill,
|
|
@@ -19,19 +20,26 @@ const styles = StyleSheet.create({
|
|
|
19
20
|
flexDirection: "row",
|
|
20
21
|
alignItems: "stretch",
|
|
21
22
|
zIndex: 2,
|
|
23
|
+
paddingHorizontal: spacings[HORIZONTAL_ROW_PADDING],
|
|
22
24
|
},
|
|
23
25
|
cellsContainer: {
|
|
24
26
|
flexDirection: "row",
|
|
25
27
|
transform: "translateZ(0)",
|
|
28
|
+
marginHorizontal: negativeSpacings[HORIZONTAL_ROW_PADDING],
|
|
29
|
+
paddingHorizontal: spacings[HORIZONTAL_ROW_PADDING],
|
|
26
30
|
},
|
|
27
31
|
stickedToStartColumnGroup: {
|
|
28
32
|
position: "sticky",
|
|
29
33
|
left: 0,
|
|
34
|
+
marginLeft: negativeSpacings[HORIZONTAL_ROW_PADDING],
|
|
35
|
+
paddingLeft: spacings[HORIZONTAL_ROW_PADDING],
|
|
30
36
|
zIndex: 1,
|
|
31
37
|
},
|
|
32
38
|
stickedToEndColumnGroup: {
|
|
33
39
|
position: "sticky",
|
|
34
40
|
right: 0,
|
|
41
|
+
marginRight: negativeSpacings[HORIZONTAL_ROW_PADDING],
|
|
42
|
+
paddingRight: spacings[HORIZONTAL_ROW_PADDING],
|
|
35
43
|
zIndex: 1,
|
|
36
44
|
},
|
|
37
45
|
rowsContainer: {
|
|
@@ -43,6 +51,7 @@ const styles = StyleSheet.create({
|
|
|
43
51
|
right: 0,
|
|
44
52
|
flexDirection: "row",
|
|
45
53
|
alignItems: "stretch",
|
|
54
|
+
paddingHorizontal: spacings[HORIZONTAL_ROW_PADDING],
|
|
46
55
|
},
|
|
47
56
|
headerCell: {
|
|
48
57
|
display: "flex",
|
|
@@ -142,7 +151,7 @@ const styles = StyleSheet.create({
|
|
|
142
151
|
width: "10%",
|
|
143
152
|
},
|
|
144
153
|
});
|
|
145
|
-
export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold = 1000, onEndReached, onEndReachedThreshold = 200, loading, extraInfo, keyExtractor, }) => {
|
|
154
|
+
export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold = 1000, onEndReached, onEndReachedThreshold = 200, loading, extraInfo, keyExtractor, marginHorizontal, }) => {
|
|
146
155
|
// Used for unique IDs generation (usefull for header IDs and cells aria-describedBy pointing to them)
|
|
147
156
|
const viewId = useId();
|
|
148
157
|
const scrollViewRef = useRef(null);
|
|
@@ -160,7 +169,10 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
|
|
|
160
169
|
const stickedToEndColumnsWidth = useMemo(() => Option.fromNullable(stickedToEndColumns)
|
|
161
170
|
.map(columns => columns.reduce((acc, column) => acc + column.width, 0))
|
|
162
171
|
.getOr(0), [stickedToEndColumns]);
|
|
163
|
-
const contentContainerWidth = stickedToStartColumnsWidth +
|
|
172
|
+
const contentContainerWidth = stickedToStartColumnsWidth +
|
|
173
|
+
centerColumnsWidth +
|
|
174
|
+
stickedToEndColumnsWidth +
|
|
175
|
+
HORIZONTAL_ROW_PADDING * 2;
|
|
164
176
|
const backgroundColor = backgroundColorVariants[variant];
|
|
165
177
|
// We store the `startIndex` and `endIndex` rather than the scroll position
|
|
166
178
|
// so that it triggers way less re-renders
|
|
@@ -317,7 +329,7 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
|
|
|
317
329
|
},
|
|
318
330
|
] }));
|
|
319
331
|
}, [stickedToEndColumnsWidth, horizontalScrollPosition]);
|
|
320
|
-
return (_jsxs(ScrollView, { ref: scrollViewRef, both: true, style: styles.container, onScroll: onScroll, scrollEventThrottle: 32, contentContainerStyle: {
|
|
332
|
+
return (_jsxs(ScrollView, { ref: scrollViewRef, both: true, style: [styles.container, { marginHorizontal }], onScroll: onScroll, scrollEventThrottle: 32, contentContainerStyle: {
|
|
321
333
|
height: containerContainerHeight,
|
|
322
334
|
width: contentContainerWidth,
|
|
323
335
|
}, children: [header, rowsToRender
|
|
@@ -419,8 +431,8 @@ const RawVirtualizedRow = ({ viewId, rowHeight, absoluteIndex, variant, stickedT
|
|
|
419
431
|
});
|
|
420
432
|
};
|
|
421
433
|
const VirtualizedRow = memo(RawVirtualizedRow);
|
|
422
|
-
export const VirtualizedListPlaceholder = ({ count, rowHeight, groupHeaderHeight, headerHeight, }) => {
|
|
423
|
-
return (_jsxs(View, { style: styles.container, children: [headerHeight != null ? _jsx(View, { style: { height: headerHeight } }) : null, groupHeaderHeight != groupHeaderHeight ? _jsx(View, { style: { height: headerHeight } }) : null, _jsx(View, { children: Array.from({ length: count }, (_, index) => {
|
|
434
|
+
export const VirtualizedListPlaceholder = ({ count, rowHeight, groupHeaderHeight, headerHeight, marginHorizontal, }) => {
|
|
435
|
+
return (_jsxs(View, { style: [styles.container, { marginHorizontal }], children: [headerHeight != null ? _jsx(View, { style: { height: headerHeight } }) : null, groupHeaderHeight != groupHeaderHeight ? _jsx(View, { style: { height: headerHeight } }) : null, _jsx(View, { children: Array.from({ length: count }, (_, index) => {
|
|
424
436
|
const top = index * rowHeight;
|
|
425
437
|
return (_jsx(View, { style: [styles.placeholderRowContainer, { height: rowHeight, top }], children: _jsxs(View, { style: styles.placeholderRowContents, children: [_jsx(View, { style: styles.placeholderRow }), _jsx(Space, { width: 32 }), _jsx(View, { style: [styles.placeholderRow, styles.smallPlaceholderRow] }), _jsx(Space, { width: 32 }), _jsx(View, { style: styles.placeholderRowEnd, children: _jsx(View, { style: [styles.placeholderRow, styles.smallPlaceholderRow] }) })] }) }, String(index)));
|
|
426
438
|
}) })] }));
|