@swan-io/lake 8.18.11 → 8.18.12
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 +1 -1
- package/src/components/Cells.d.ts +68 -0
- package/src/components/Cells.js +164 -0
- package/src/components/EmptyView.d.ts +13 -0
- package/src/components/EmptyView.js +17 -0
- package/src/components/PlainListView.d.ts +8 -1
- package/src/components/PlainListView.js +3 -2
- package/src/components/VirtualizedList.d.ts +0 -1
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { ColorVariants } from "../constants/design";
|
|
3
|
+
import { TextVariant } from "./LakeText";
|
|
4
|
+
import { LakeTooltip } from "./LakeTooltip";
|
|
5
|
+
type Justify = "flex-start" | "center" | "flex-end";
|
|
6
|
+
type SortDirection = "Desc" | "Asc";
|
|
7
|
+
export declare const SimpleHeaderCell: ({ text, sort, justifyContent, onPress, }: {
|
|
8
|
+
text: string;
|
|
9
|
+
justifyContent?: Justify;
|
|
10
|
+
sort?: SortDirection;
|
|
11
|
+
onPress?: (direction: SortDirection) => void;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const ColorPatchCell: ({ isHovered, alternativeText, color, }: {
|
|
14
|
+
isHovered: boolean;
|
|
15
|
+
alternativeText?: string;
|
|
16
|
+
color: ColorVariants;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
export declare const SimpleTitleCell: ({ isHighlighted, text, tooltip, }: {
|
|
19
|
+
isHighlighted?: boolean;
|
|
20
|
+
text: string;
|
|
21
|
+
tooltip?: Omit<ComponentProps<typeof LakeTooltip>, "children">;
|
|
22
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const SimpleRegularTextCell: ({ variant, text, textAlign, color, }: {
|
|
24
|
+
variant?: TextVariant;
|
|
25
|
+
text: string;
|
|
26
|
+
textAlign?: "left" | "center" | "right";
|
|
27
|
+
color?: string;
|
|
28
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const CopyableRegularTextCell: ({ variant, text, textToCopy, copyWording, copiedWording, tooltip, }: {
|
|
30
|
+
variant?: TextVariant;
|
|
31
|
+
text: string;
|
|
32
|
+
textToCopy?: string;
|
|
33
|
+
copyWording: string;
|
|
34
|
+
copiedWording: string;
|
|
35
|
+
tooltip?: Omit<ComponentProps<typeof LakeTooltip>, "children">;
|
|
36
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare const BalanceCell: ({ value, currency, originalValue, formatCurrency, textAlign, variant, }: {
|
|
38
|
+
value: number;
|
|
39
|
+
currency: string;
|
|
40
|
+
originalValue?: {
|
|
41
|
+
value: number;
|
|
42
|
+
currency: string;
|
|
43
|
+
};
|
|
44
|
+
formatCurrency: (value: number, currency: string) => string;
|
|
45
|
+
textAlign?: "left" | "center" | "right";
|
|
46
|
+
variant?: TextVariant;
|
|
47
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare const LinkCell: ({ children, external, onPress, variant, tooltip, buttonPosition, }: {
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
onPress: () => void;
|
|
51
|
+
external?: boolean;
|
|
52
|
+
variant?: TextVariant;
|
|
53
|
+
tooltip?: Omit<ComponentProps<typeof LakeTooltip>, "children">;
|
|
54
|
+
buttonPosition?: "start" | "end";
|
|
55
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare const StartAlignedCell: ({ children }: {
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export declare const CenteredCell: ({ children }: {
|
|
60
|
+
children: ReactNode;
|
|
61
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
export declare const EndAlignedCell: ({ children }: {
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare const CellAction: ({ children }: {
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import { match } from "ts-pattern";
|
|
5
|
+
import { visuallyHiddenStyle } from "../constants/commonStyles";
|
|
6
|
+
import { colors, spacings } from "../constants/design";
|
|
7
|
+
import { setClipboardText } from "../utils/clipboard";
|
|
8
|
+
import { isNotNullish, isNullish } from "../utils/nullish";
|
|
9
|
+
import { Box } from "./Box";
|
|
10
|
+
import { Icon } from "./Icon";
|
|
11
|
+
import { LakeText } from "./LakeText";
|
|
12
|
+
import { LakeTooltip } from "./LakeTooltip";
|
|
13
|
+
import { Pressable } from "./Pressable";
|
|
14
|
+
import { Space } from "./Space";
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
cellContainer: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexGrow: 1,
|
|
19
|
+
flexDirection: "row",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
},
|
|
22
|
+
balanceCellContainer: {
|
|
23
|
+
width: "100%",
|
|
24
|
+
},
|
|
25
|
+
cell: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
paddingHorizontal: spacings[16],
|
|
28
|
+
flexGrow: 1,
|
|
29
|
+
flexDirection: "row",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
},
|
|
32
|
+
disabledCellHeader: {
|
|
33
|
+
cursor: "text",
|
|
34
|
+
},
|
|
35
|
+
icon: {
|
|
36
|
+
alignSelf: "stretch",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
paddingHorizontal: spacings[4],
|
|
40
|
+
},
|
|
41
|
+
iconContainer: {
|
|
42
|
+
flexDirection: "row",
|
|
43
|
+
alignSelf: "stretch",
|
|
44
|
+
alignItems: "stretch",
|
|
45
|
+
justifyContent: "center",
|
|
46
|
+
},
|
|
47
|
+
centeredCell: {
|
|
48
|
+
justifyContent: "center",
|
|
49
|
+
},
|
|
50
|
+
endAlignedCell: {
|
|
51
|
+
justifyContent: "flex-end",
|
|
52
|
+
},
|
|
53
|
+
regularText: {
|
|
54
|
+
overflow: "hidden",
|
|
55
|
+
textOverflow: "ellipsis",
|
|
56
|
+
width: 1,
|
|
57
|
+
flexGrow: 1,
|
|
58
|
+
whiteSpace: "nowrap",
|
|
59
|
+
},
|
|
60
|
+
mediumText: {
|
|
61
|
+
overflow: "hidden",
|
|
62
|
+
textOverflow: "ellipsis",
|
|
63
|
+
width: 1,
|
|
64
|
+
flexGrow: 1,
|
|
65
|
+
whiteSpace: "nowrap",
|
|
66
|
+
flexDirection: "row",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
},
|
|
69
|
+
colorPatch: {
|
|
70
|
+
flexGrow: 1,
|
|
71
|
+
},
|
|
72
|
+
alternativeText: visuallyHiddenStyle,
|
|
73
|
+
sortIcon: {
|
|
74
|
+
transitionProperty: "transform",
|
|
75
|
+
transitionDuration: "300ms",
|
|
76
|
+
transitionTimingFunction: "ease-in-out",
|
|
77
|
+
},
|
|
78
|
+
sortIconReversed: {
|
|
79
|
+
transform: "rotate(-180deg)",
|
|
80
|
+
},
|
|
81
|
+
cellAction: {
|
|
82
|
+
paddingVertical: spacings[16],
|
|
83
|
+
paddingHorizontal: spacings[8],
|
|
84
|
+
},
|
|
85
|
+
underline: {
|
|
86
|
+
boxShadow: "inset 0 -2px currentColor",
|
|
87
|
+
},
|
|
88
|
+
sortHorizontalBar: {
|
|
89
|
+
position: "absolute",
|
|
90
|
+
width: "100%",
|
|
91
|
+
height: 2,
|
|
92
|
+
bottom: -10,
|
|
93
|
+
backgroundColor: colors.current[500],
|
|
94
|
+
borderBottomColor: colors.current[500],
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
export const SimpleHeaderCell = ({ text, sort, justifyContent = "flex-start", onPress, }) => {
|
|
98
|
+
const sortActive = isNotNullish(sort) && isNotNullish(onPress);
|
|
99
|
+
const disabled = isNullish(onPress);
|
|
100
|
+
return (_jsx(Pressable, { onPress: () => {
|
|
101
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(match(sort)
|
|
102
|
+
.returnType()
|
|
103
|
+
.with("Desc", () => "Asc")
|
|
104
|
+
.with("Asc", () => "Desc")
|
|
105
|
+
.otherwise(() => "Desc"));
|
|
106
|
+
}, disabled: disabled, style: [styles.cellContainer, disabled && styles.disabledCellHeader], role: "columnheader", children: ({ hovered }) => (_jsx(View, { style: [styles.cell, { justifyContent }], children: _jsxs(View, { children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(LakeText, { numberOfLines: 1, variant: "medium", color: sortActive ? colors.current[500] : colors.gray[900], style: {
|
|
107
|
+
textAlign: match(justifyContent)
|
|
108
|
+
.with("flex-start", () => "left")
|
|
109
|
+
.with("center", () => "center")
|
|
110
|
+
.with("flex-end", () => "right")
|
|
111
|
+
.exhaustive(),
|
|
112
|
+
}, children: text }), isNotNullish(onPress) ? (_jsxs(_Fragment, { children: [_jsx(Space, { width: 8 }), _jsx(Box, { style: [styles.sortIcon, sort === "Asc" && styles.sortIconReversed], children: _jsx(Icon, { size: 15, color: sortActive ? colors.current[500] : colors.gray[500], name: sortActive ? "arrow-down-filled" : "chevron-up-down-regular" }) })] })) : null] }), sortActive ? (_jsx(View, { style: styles.sortHorizontalBar })) : hovered ? (_jsx(View, { style: [styles.sortHorizontalBar, { backgroundColor: colors.gray[900] }] })) : null] }) })) }));
|
|
113
|
+
};
|
|
114
|
+
export const ColorPatchCell = ({ isHovered, alternativeText, color, }) => {
|
|
115
|
+
return isHovered ? (_jsx(View, { style: [styles.colorPatch, { backgroundColor: colors[color].primary }], children: isNotNullish(alternativeText) ? (_jsx(LakeText, { style: styles.alternativeText, children: alternativeText })) : null })) : null;
|
|
116
|
+
};
|
|
117
|
+
export const SimpleTitleCell = ({ isHighlighted = false, text, tooltip, }) => (_jsx(View, { style: styles.cell, children: _jsx(LakeText, { numberOfLines: 1, color: isHighlighted ? colors.current.primary : colors.gray[900], style: styles.regularText, variant: "medium", tooltip: tooltip, children: text }) }));
|
|
118
|
+
export const SimpleRegularTextCell = ({ variant = "regular", text, textAlign = "left", color = colors.gray[900], }) => {
|
|
119
|
+
return (_jsx(View, { style: styles.cell, children: _jsx(LakeText, { align: textAlign, color: color, style: styles.regularText, variant: variant, children: text }) }));
|
|
120
|
+
};
|
|
121
|
+
export const CopyableRegularTextCell = ({ variant = "regular", text, textToCopy, copyWording, copiedWording, tooltip, }) => {
|
|
122
|
+
const [visibleState, setVisibleState] = useState("copy");
|
|
123
|
+
const clipboardText = textToCopy !== null && textToCopy !== void 0 ? textToCopy : text;
|
|
124
|
+
const onPress = useCallback((event) => {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
setClipboardText(clipboardText);
|
|
127
|
+
setVisibleState("copied");
|
|
128
|
+
}, [clipboardText]);
|
|
129
|
+
return (_jsxs(View, { style: styles.cell, children: [_jsx(LakeTooltip, { placement: "right", onHide: () => setVisibleState("copy"), togglableOnFocus: true, content: visibleState === "copy" ? copyWording : copiedWording, containerStyle: styles.iconContainer, children: _jsx(Pressable, { role: "button", "aria-label": copyWording, onPress: onPress, style: ({ hovered }) => [styles.icon, hovered && styles.underline], children: ({ hovered }) => (_jsx(Icon, { name: hovered ? "copy-filled" : "copy-regular", color: "currentColor", size: 14 })) }) }), _jsx(Space, { width: 4 }), _jsx(LakeText, { tooltip: tooltip, color: colors.gray[900], style: styles.regularText, variant: variant, children: text })] }));
|
|
130
|
+
};
|
|
131
|
+
// TODO: handle `+` sign properly
|
|
132
|
+
export const BalanceCell = ({ value, currency, originalValue, formatCurrency, textAlign = "right", variant = "medium", }) => {
|
|
133
|
+
return (_jsxs(View, { style: styles.balanceCellContainer, children: [_jsx(View, { style: styles.cell, children: _jsxs(LakeText, { align: textAlign, color: colors.gray[900], variant: variant, style: [
|
|
134
|
+
styles.mediumText,
|
|
135
|
+
{
|
|
136
|
+
justifyContent: match(textAlign)
|
|
137
|
+
.with("left", () => "flex-start")
|
|
138
|
+
.with("center", () => "center")
|
|
139
|
+
.with("right", () => "flex-end")
|
|
140
|
+
.exhaustive(),
|
|
141
|
+
},
|
|
142
|
+
value > 0 && { color: colors.positive.primary },
|
|
143
|
+
value < 0 && { color: colors.negative.primary },
|
|
144
|
+
], children: [value > 0 && "+", formatCurrency(value, currency)] }) }), isNotNullish(originalValue) && originalValue.currency !== currency && (_jsx(View, { style: styles.cell, children: _jsxs(LakeText, { style: styles.mediumText, align: textAlign, color: colors.gray[500], variant: "smallRegular", children: [originalValue.value > 0 && "+", formatCurrency(originalValue.value, originalValue.currency)] }) }))] }));
|
|
145
|
+
};
|
|
146
|
+
export const LinkCell = ({ children, external = false, onPress, variant = "medium", tooltip, buttonPosition = "start", }) => {
|
|
147
|
+
const ArrowButton = () => (_jsx(Pressable, { style: ({ hovered }) => [styles.icon, hovered && styles.underline], onPress: event => {
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
onPress();
|
|
150
|
+
}, children: _jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }) }));
|
|
151
|
+
return (_jsxs(View, { style: styles.cell, children: [buttonPosition === "start" && (_jsxs(_Fragment, { children: [_jsx(ArrowButton, {}), _jsx(Space, { width: 8 })] })), _jsx(LakeText, { color: colors.gray[900], variant: variant, style: styles.mediumText, tooltip: tooltip, children: children }), buttonPosition === "end" && (_jsxs(_Fragment, { children: [_jsx(Space, { width: 8 }), _jsx(ArrowButton, {})] }))] }));
|
|
152
|
+
};
|
|
153
|
+
export const StartAlignedCell = ({ children }) => {
|
|
154
|
+
return _jsx(View, { style: styles.cell, children: children });
|
|
155
|
+
};
|
|
156
|
+
export const CenteredCell = ({ children }) => {
|
|
157
|
+
return _jsx(View, { style: [styles.cell, styles.centeredCell], children: children });
|
|
158
|
+
};
|
|
159
|
+
export const EndAlignedCell = ({ children }) => {
|
|
160
|
+
return _jsx(View, { style: [styles.cell, styles.endAlignedCell], children: children });
|
|
161
|
+
};
|
|
162
|
+
export const CellAction = ({ children }) => {
|
|
163
|
+
return _jsx(View, { style: styles.cellAction, children: children });
|
|
164
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { IconName } from "./Icon";
|
|
3
|
+
import { SpacingValue } from "./Space";
|
|
4
|
+
type Props = {
|
|
5
|
+
icon: IconName;
|
|
6
|
+
borderedIcon?: boolean;
|
|
7
|
+
borderedIconPadding?: SpacingValue | 0;
|
|
8
|
+
title?: string;
|
|
9
|
+
subtitle?: ReactNode;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare const EmptyView: ({ icon, borderedIcon, borderedIconPadding, title, subtitle, children, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from "@react-three/drei";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { colors } from "../constants/design";
|
|
5
|
+
import { BorderedIcon } from "./BorderedIcon";
|
|
6
|
+
import { Icon } from "./Icon";
|
|
7
|
+
import { LakeHeading } from "./LakeHeading";
|
|
8
|
+
import { LakeText } from "./LakeText";
|
|
9
|
+
import { Space } from "./Space";
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
emptyList: {
|
|
12
|
+
flexDirection: "column",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
export const EmptyView = ({ icon, borderedIcon = false, borderedIconPadding, title, subtitle, children, }) => (_jsxs(View, { style: styles.emptyList, children: [borderedIcon ? (_jsx(BorderedIcon, { name: icon, padding: borderedIconPadding })) : (_jsx(Icon, { name: icon, size: 96, color: colors.current.primary })), _jsx(Space, { height: 24 }), title != null ? (_jsxs(_Fragment, { children: [_jsx(LakeHeading, { align: "center", level: 3, variant: "h5", children: title }), _jsx(Space, { height: 8 })] })) : null, subtitle != null && _jsx(LakeText, { align: "center", children: subtitle }), children] }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { PressableStateCallbackType, ViewStyle } from "react-native";
|
|
3
|
-
import { ColumnCellConfig, ColumnTitleConfig, LinkConfig } from "./
|
|
3
|
+
import { ColumnCellConfig, ColumnTitleConfig, LinkConfig } from "./VirtualizedList";
|
|
4
4
|
export type ColumnConfig<T, ExtraInfo> = {
|
|
5
5
|
id: string;
|
|
6
6
|
width: number | "grow";
|
|
@@ -39,4 +39,11 @@ type Props<T, ExtraInfo> = {
|
|
|
39
39
|
headerBackgroundColor?: string;
|
|
40
40
|
};
|
|
41
41
|
export declare const PlainListView: <T, ExtraInfo>({ data: originalData, keyExtractor, rowHeight, groupHeaderHeight, headerHeight, columns, smallColumns, extraInfo, onEndReached, onEndReachedThresholdPx, headerStyle, rowStyle, getRowLink, activeRowId, renderEmptyList, onActiveRowChange, groupBy, loading, breakpoint, withoutScroll, stickyOffset, headerBackgroundColor, }: Props<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare const PlainListViewPlaceholder: ({ count, rowHeight, groupHeaderHeight, headerHeight, marginHorizontal, }: {
|
|
43
|
+
count: number;
|
|
44
|
+
rowHeight: number;
|
|
45
|
+
groupHeaderHeight?: number;
|
|
46
|
+
headerHeight?: number;
|
|
47
|
+
marginHorizontal?: string;
|
|
48
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
42
49
|
export {};
|
|
@@ -5,10 +5,10 @@ import { commonStyles } from "../constants/commonStyles";
|
|
|
5
5
|
import { backgroundColor, breakpoints, colors, spacings } from "../constants/design";
|
|
6
6
|
import { useHover } from "../hooks/useHover";
|
|
7
7
|
import { isNotNullish, isNullish } from "../utils/nullish";
|
|
8
|
-
import { PlainListViewPlaceholder, } from "./FixedListView";
|
|
9
8
|
import { LakeHeading } from "./LakeHeading";
|
|
10
9
|
import { ResponsiveContainer } from "./ResponsiveContainer";
|
|
11
10
|
import { ScrollView } from "./ScrollView";
|
|
11
|
+
import { VirtualizedListPlaceholder, } from "./VirtualizedList";
|
|
12
12
|
const INHERIT = "inherit";
|
|
13
13
|
const styles = StyleSheet.create({
|
|
14
14
|
root: {
|
|
@@ -216,7 +216,8 @@ export const PlainListView = ({ data: originalData, keyExtractor, rowHeight, gro
|
|
|
216
216
|
children: (_jsx(Row, { id: key, rowHeight: rowHeight, columns: displayColumns, item: item, index: index, extraInfo: extraInfo, isActive: isActive, isHovered: isHovered, large: large, style: rowStyle, onMouseEnter: setHoveredRow, onMouseLeave: removeHoveredRow })),
|
|
217
217
|
});
|
|
218
218
|
})] }, groupName));
|
|
219
|
-
}) }), _jsx(View, { children: _jsx(View, { "aria-busy": isLoading, style: styles.loadingPlaceholder, children: isLoading ? (_jsx(PlainListViewPlaceholder, { count: loading.count, rowHeight: rowHeight
|
|
219
|
+
}) }), _jsx(View, { children: _jsx(View, { "aria-busy": isLoading, style: styles.loadingPlaceholder, children: isLoading ? (_jsx(PlainListViewPlaceholder, { count: loading.count, rowHeight: rowHeight })) : null }) }), isEmpty && isNotNullish(renderEmptyList) && !isLoading ? (_jsx(View, { style: styles.emptyListContainer, children: renderEmptyList() })) : null, _jsx(View, { style: [styles.scrollTracker, { height: onEndReachedThresholdPx }], ref: scrollTrackerRef })] })),
|
|
220
220
|
}) }));
|
|
221
221
|
} }));
|
|
222
222
|
};
|
|
223
|
+
export const PlainListViewPlaceholder = VirtualizedListPlaceholder;
|