@swan-io/lake 11.1.2 → 11.1.4
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
|
@@ -1,67 +1,144 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import { Except } from "type-fest";
|
|
2
4
|
import { ColorVariants } from "../constants/design";
|
|
3
5
|
import { TextVariant } from "./LakeText";
|
|
4
6
|
import { LakeTooltip } from "./LakeTooltip";
|
|
5
|
-
|
|
7
|
+
declare const directionStyles: {
|
|
8
|
+
column: {
|
|
9
|
+
flexShrink: number;
|
|
10
|
+
flexDirection: "column";
|
|
11
|
+
justifyContent: "center";
|
|
12
|
+
};
|
|
13
|
+
columnReverse: {
|
|
14
|
+
flexShrink: number;
|
|
15
|
+
flexDirection: "column-reverse";
|
|
16
|
+
justifyContent: "center";
|
|
17
|
+
};
|
|
18
|
+
row: {
|
|
19
|
+
flexShrink: number;
|
|
20
|
+
flexDirection: "row";
|
|
21
|
+
alignItems: "center";
|
|
22
|
+
};
|
|
23
|
+
rowReverse: {
|
|
24
|
+
flexShrink: number;
|
|
25
|
+
flexDirection: "row-reverse";
|
|
26
|
+
alignItems: "center";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type Align = "left" | "center" | "right";
|
|
6
30
|
type SortDirection = "Desc" | "Asc";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
31
|
+
type TooltipProp = Except<ComponentProps<typeof LakeTooltip>, "children">;
|
|
32
|
+
type CellProps = {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
align?: Align;
|
|
35
|
+
direction?: keyof typeof directionStyles;
|
|
36
|
+
style?: StyleProp<ViewStyle>;
|
|
37
|
+
};
|
|
38
|
+
export declare const Cell: ({ children, align, direction, style }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
type HeaderCellProps = {
|
|
40
|
+
align?: Align;
|
|
10
41
|
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
42
|
text: string;
|
|
26
|
-
|
|
43
|
+
onPress?: (direction: SortDirection) => void;
|
|
44
|
+
};
|
|
45
|
+
export declare const HeaderCell: ({ align, sort, text, onPress }: HeaderCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
type TextCellProps = {
|
|
47
|
+
align?: Align;
|
|
27
48
|
color?: string;
|
|
28
|
-
|
|
29
|
-
|
|
49
|
+
text: string;
|
|
50
|
+
tooltip?: TooltipProp;
|
|
30
51
|
variant?: TextVariant;
|
|
52
|
+
};
|
|
53
|
+
export declare const TextCell: ({ align, color, text, tooltip, variant, }: TextCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
type CopyableTextCellProps = {
|
|
55
|
+
copiedWording: string;
|
|
56
|
+
copyWording: string;
|
|
31
57
|
text: string;
|
|
32
58
|
textToCopy?: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
tooltip?: TooltipProp;
|
|
60
|
+
variant?: TextVariant;
|
|
61
|
+
};
|
|
62
|
+
export declare const CopyableTextCell: ({ copiedWording, copyWording, text, textToCopy, tooltip, variant, }: CopyableTextCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
63
|
+
type BalanceCellProps = {
|
|
64
|
+
align?: Align;
|
|
39
65
|
currency: string;
|
|
66
|
+
formatCurrency: (value: number, currency: string) => string;
|
|
40
67
|
originalValue?: {
|
|
41
68
|
value: number;
|
|
42
69
|
currency: string;
|
|
43
70
|
};
|
|
44
|
-
|
|
45
|
-
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use `align` prop instead
|
|
73
|
+
*/
|
|
74
|
+
textAlign?: Align;
|
|
75
|
+
value: number;
|
|
46
76
|
variant?: TextVariant;
|
|
47
|
-
}
|
|
48
|
-
export declare const
|
|
77
|
+
};
|
|
78
|
+
export declare const BalanceCell: ({ textAlign, align, currency, formatCurrency, originalValue, value, variant, }: BalanceCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
type LinkCellProps = {
|
|
80
|
+
buttonPosition?: "start" | "end";
|
|
49
81
|
children: ReactNode;
|
|
50
|
-
onPress: () => void;
|
|
51
82
|
external?: boolean;
|
|
83
|
+
onPress: () => void;
|
|
84
|
+
tooltip?: TooltipProp;
|
|
52
85
|
variant?: TextVariant;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
};
|
|
87
|
+
export declare const LinkCell: ({ buttonPosition, children, external, onPress, tooltip, variant, }: LinkCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Avoid usage
|
|
90
|
+
*/
|
|
91
|
+
export declare const ColorPatchCell: ({ alternativeText, color, isHovered, }: {
|
|
92
|
+
alternativeText?: string;
|
|
93
|
+
color: ColorVariants;
|
|
94
|
+
isHovered: boolean;
|
|
95
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Use `HeaderCell` instead
|
|
98
|
+
*/
|
|
99
|
+
export declare const SimpleHeaderCell: ({ justifyContent, ...props }: {
|
|
100
|
+
justifyContent?: "flex-start" | "center" | "flex-end";
|
|
101
|
+
text: string;
|
|
102
|
+
sort?: SortDirection;
|
|
103
|
+
onPress?: (direction: SortDirection) => void;
|
|
58
104
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
59
|
-
|
|
60
|
-
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use `TextCell` with color={…} and variant="medium" instead
|
|
107
|
+
*/
|
|
108
|
+
export declare const SimpleTitleCell: ({ isHighlighted, text, tooltip, }: {
|
|
109
|
+
isHighlighted?: boolean;
|
|
110
|
+
text: string;
|
|
111
|
+
tooltip?: TooltipProp;
|
|
61
112
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
62
|
-
|
|
63
|
-
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `TextCell` instead
|
|
115
|
+
*/
|
|
116
|
+
export declare const SimpleRegularTextCell: ({ color, text, textAlign, variant, }: {
|
|
117
|
+
color?: string;
|
|
118
|
+
text: string;
|
|
119
|
+
textAlign?: Align;
|
|
120
|
+
variant?: TextVariant;
|
|
64
121
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated Use `CopyableTextCell` instead
|
|
124
|
+
*/
|
|
125
|
+
export declare const CopyableRegularTextCell: ({ copiedWording, copyWording, text, textToCopy, tooltip, variant, }: CopyableTextCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
126
|
+
/**
|
|
127
|
+
* @deprecated Use `<Cell align="left" />` instead
|
|
128
|
+
*/
|
|
129
|
+
export declare const StartAlignedCell: (props: Except<CellProps, "align">) => import("react/jsx-runtime").JSX.Element;
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated Use `<Cell align="center" />` instead
|
|
132
|
+
*/
|
|
133
|
+
export declare const CenteredCell: (props: Except<CellProps, "align">) => import("react/jsx-runtime").JSX.Element;
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated Use `<Cell align="right" />` instead
|
|
136
|
+
*/
|
|
137
|
+
export declare const EndAlignedCell: (props: Except<CellProps, "align">) => import("react/jsx-runtime").JSX.Element;
|
|
138
|
+
export declare const ActionCell: ({ style, ...props }: CellProps) => import("react/jsx-runtime").JSX.Element;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Use <ActionCell /> instead
|
|
141
|
+
*/
|
|
65
142
|
export declare const CellAction: ({ children }: {
|
|
66
143
|
children: ReactNode;
|
|
67
144
|
}) => import("react/jsx-runtime").JSX.Element;
|
package/src/components/Cells.js
CHANGED
|
@@ -3,8 +3,9 @@ import { useCallback, useState } from "react";
|
|
|
3
3
|
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import { match } from "ts-pattern";
|
|
5
5
|
import { visuallyHiddenStyle } from "../constants/commonStyles";
|
|
6
|
-
import { colors, spacings } from "../constants/design";
|
|
6
|
+
import { colors, negativeSpacings, spacings } from "../constants/design";
|
|
7
7
|
import { setClipboardText } from "../utils/clipboard";
|
|
8
|
+
import { identity } from "../utils/function";
|
|
8
9
|
import { isNotNullish, isNullish } from "../utils/nullish";
|
|
9
10
|
import { Box } from "./Box";
|
|
10
11
|
import { Icon } from "./Icon";
|
|
@@ -12,113 +13,110 @@ import { LakeText } from "./LakeText";
|
|
|
12
13
|
import { LakeTooltip } from "./LakeTooltip";
|
|
13
14
|
import { Pressable } from "./Pressable";
|
|
14
15
|
import { Space } from "./Space";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
flexDirection: "
|
|
20
|
-
|
|
16
|
+
/* eslint-disable react-native/no-unused-styles */
|
|
17
|
+
const directionStyles = StyleSheet.create({
|
|
18
|
+
column: {
|
|
19
|
+
flexShrink: 1,
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
justifyContent: "center",
|
|
21
22
|
},
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
columnReverse: {
|
|
24
|
+
flexShrink: 1,
|
|
25
|
+
flexDirection: "column-reverse",
|
|
26
|
+
justifyContent: "center",
|
|
24
27
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
paddingHorizontal: spacings[16],
|
|
28
|
-
flexGrow: 1,
|
|
28
|
+
row: {
|
|
29
|
+
flexShrink: 1,
|
|
29
30
|
flexDirection: "row",
|
|
30
31
|
alignItems: "center",
|
|
31
32
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
icon: {
|
|
36
|
-
alignSelf: "stretch",
|
|
33
|
+
rowReverse: {
|
|
34
|
+
flexShrink: 1,
|
|
35
|
+
flexDirection: "row-reverse",
|
|
37
36
|
alignItems: "center",
|
|
38
|
-
justifyContent: "center",
|
|
39
|
-
paddingHorizontal: spacings[4],
|
|
40
37
|
},
|
|
41
|
-
|
|
38
|
+
});
|
|
39
|
+
/* eslint-enable react-native/no-unused-styles */
|
|
40
|
+
const styles = StyleSheet.create({
|
|
41
|
+
cell: {
|
|
42
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
43
|
flexGrow: 1,
|
|
58
|
-
|
|
44
|
+
flexShrink: 1,
|
|
45
|
+
paddingHorizontal: spacings[16],
|
|
59
46
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
textOverflow: "ellipsis",
|
|
63
|
-
width: 1,
|
|
64
|
-
flexGrow: 1,
|
|
65
|
-
whiteSpace: "nowrap",
|
|
66
|
-
flexDirection: "row",
|
|
67
|
-
alignItems: "center",
|
|
47
|
+
noCursor: {
|
|
48
|
+
cursor: "text",
|
|
68
49
|
},
|
|
69
|
-
|
|
70
|
-
|
|
50
|
+
marginLeftAuto: {
|
|
51
|
+
marginLeft: "auto",
|
|
52
|
+
},
|
|
53
|
+
marginRightAuto: {
|
|
54
|
+
marginRight: "auto",
|
|
71
55
|
},
|
|
72
|
-
alternativeText: visuallyHiddenStyle,
|
|
73
56
|
sortIcon: {
|
|
74
57
|
transitionProperty: "transform",
|
|
75
58
|
transitionDuration: "300ms",
|
|
76
59
|
transitionTimingFunction: "ease-in-out",
|
|
77
60
|
},
|
|
78
|
-
|
|
61
|
+
rotated: {
|
|
79
62
|
transform: "rotate(-180deg)",
|
|
80
63
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
boxShadow: "inset 0 -2px currentColor",
|
|
87
|
-
},
|
|
88
|
-
sortHorizontalBar: {
|
|
64
|
+
headerUnderline: {
|
|
65
|
+
backgroundColor: colors.gray[900],
|
|
66
|
+
borderBottomColor: colors.current[500],
|
|
67
|
+
bottom: -10,
|
|
68
|
+
height: 2,
|
|
89
69
|
position: "absolute",
|
|
90
70
|
width: "100%",
|
|
91
|
-
|
|
92
|
-
|
|
71
|
+
},
|
|
72
|
+
headerUnderlineActive: {
|
|
93
73
|
backgroundColor: colors.current[500],
|
|
94
|
-
|
|
74
|
+
},
|
|
75
|
+
buttonUnderline: {
|
|
76
|
+
boxShadow: "inset 0 -2px currentColor",
|
|
77
|
+
},
|
|
78
|
+
copyButton: {
|
|
79
|
+
justifyContent: "center",
|
|
80
|
+
alignSelf: "stretch",
|
|
81
|
+
marginHorizontal: negativeSpacings[8],
|
|
82
|
+
},
|
|
83
|
+
copyButtonTooltip: {
|
|
84
|
+
justifyContent: "center",
|
|
85
|
+
height: "100%",
|
|
86
|
+
paddingHorizontal: spacings[8],
|
|
87
|
+
},
|
|
88
|
+
linkButton: {
|
|
89
|
+
justifyContent: "center",
|
|
90
|
+
alignSelf: "stretch",
|
|
91
|
+
marginHorizontal: negativeSpacings[8],
|
|
92
|
+
paddingHorizontal: spacings[8],
|
|
93
|
+
},
|
|
94
|
+
actionCell: {
|
|
95
|
+
paddingVertical: spacings[16],
|
|
96
|
+
paddingHorizontal: spacings[8],
|
|
95
97
|
},
|
|
96
98
|
});
|
|
97
|
-
export const
|
|
99
|
+
export const Cell = ({ children, align = "left", direction = "row", style }) => (_jsx(View, { style: [styles.cell, style], children: _jsx(View, { style: [
|
|
100
|
+
directionStyles[direction],
|
|
101
|
+
(align === "right" || align === "center") && styles.marginLeftAuto,
|
|
102
|
+
(align === "left" || align === "center") && styles.marginRightAuto,
|
|
103
|
+
], children: children }) }));
|
|
104
|
+
export const HeaderCell = ({ align = "left", sort, text, onPress }) => {
|
|
98
105
|
const sortActive = isNotNullish(sort) && isNotNullish(onPress);
|
|
99
106
|
const disabled = isNullish(onPress);
|
|
100
|
-
return (_jsx(Pressable, { onPress: () => {
|
|
107
|
+
return (_jsx(Pressable, { role: "columnheader", disabled: disabled, style: [styles.cell, disabled && styles.noCursor], onPress: () => {
|
|
101
108
|
onPress === null || onPress === void 0 ? void 0 : onPress(match(sort)
|
|
102
109
|
.returnType()
|
|
103
110
|
.with("Desc", () => "Asc")
|
|
104
|
-
.with("Asc", () => "Desc")
|
|
105
111
|
.otherwise(() => "Desc"));
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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;
|
|
112
|
+
}, children: ({ hovered }) => (_jsxs(View, { style: [
|
|
113
|
+
directionStyles["row"],
|
|
114
|
+
(align === "right" || align === "center") && styles.marginLeftAuto,
|
|
115
|
+
(align === "left" || align === "center") && styles.marginRightAuto,
|
|
116
|
+
], children: [_jsx(LakeText, { numberOfLines: 1, align: align, color: sortActive ? colors.current[500] : colors.gray[900], variant: "medium", children: text }), isNotNullish(onPress) && (_jsxs(_Fragment, { children: [_jsx(Space, { width: 8 }), _jsx(Icon, { size: 15, color: sortActive ? colors.current[500] : colors.gray[500], name: sortActive ? "arrow-down-filled" : "chevron-up-down-regular", style: [styles.sortIcon, sort === "Asc" && styles.rotated] })] })), (hovered || sortActive) && (_jsx(View, { style: [styles.headerUnderline, sortActive && styles.headerUnderlineActive] }))] })) }));
|
|
116
117
|
};
|
|
117
|
-
export const
|
|
118
|
-
export const
|
|
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, }) => {
|
|
118
|
+
export const TextCell = ({ align = "left", color = colors.gray[900], text, tooltip, variant = "regular", }) => (_jsx(Cell, { align: align, children: _jsx(LakeText, { numberOfLines: 1, align: align, color: color, tooltip: tooltip, variant: variant, children: text }) }));
|
|
119
|
+
export const CopyableTextCell = ({ copiedWording, copyWording, text, textToCopy, tooltip, variant = "regular", }) => {
|
|
122
120
|
const [visibleState, setVisibleState] = useState("copy");
|
|
123
121
|
const clipboardText = textToCopy !== null && textToCopy !== void 0 ? textToCopy : text;
|
|
124
122
|
const onPress = useCallback((event) => {
|
|
@@ -126,39 +124,58 @@ export const CopyableRegularTextCell = ({ variant = "regular", text, textToCopy,
|
|
|
126
124
|
setClipboardText(clipboardText);
|
|
127
125
|
setVisibleState("copied");
|
|
128
126
|
}, [clipboardText]);
|
|
129
|
-
return (_jsxs(
|
|
127
|
+
return (_jsxs(Cell, { children: [_jsx(Pressable, { "aria-label": copyWording, role: "button", onPress: onPress, style: ({ hovered }) => [styles.copyButton, hovered && styles.buttonUnderline], children: ({ hovered }) => (_jsx(LakeTooltip, { content: visibleState === "copy" ? copyWording : copiedWording, onHide: () => setVisibleState("copy"), placement: "center", togglableOnFocus: true, containerStyle: styles.copyButtonTooltip, children: _jsx(Icon, { name: hovered ? "copy-filled" : "copy-regular", color: "currentColor", size: 14 }) })) }), _jsx(Space, { width: 8 }), _jsx(LakeText, { numberOfLines: 1, color: colors.gray[900], tooltip: tooltip, variant: variant, children: text })] }));
|
|
130
128
|
};
|
|
131
129
|
// TODO: handle `+` sign properly
|
|
132
|
-
export const BalanceCell = ({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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 });
|
|
130
|
+
export const BalanceCell = ({ textAlign = "right", align = textAlign, currency, formatCurrency, originalValue, value, variant = "medium", }) => (_jsxs(Cell, { align: align, direction: "column", children: [_jsx(LakeText, { numberOfLines: 1, align: align, color: colors.gray[900], variant: variant, style: [
|
|
131
|
+
value > 0 && { color: colors.positive.primary },
|
|
132
|
+
value < 0 && { color: colors.negative.primary },
|
|
133
|
+
], children: (value > 0 ? "+" : "") + formatCurrency(value, currency) }), isNotNullish(originalValue) && originalValue.currency !== currency && (_jsx(LakeText, { numberOfLines: 1, align: align, color: colors.gray[500], variant: "smallRegular", children: (originalValue.value > 0 ? "+" : "") +
|
|
134
|
+
formatCurrency(originalValue.value, originalValue.currency) }))] }));
|
|
135
|
+
export const LinkCell = ({ buttonPosition = "start", children, external = false, onPress, tooltip, variant = "medium", }) => (_jsxs(Cell, { direction: buttonPosition === "end" ? "rowReverse" : "row", children: [_jsx(Pressable, { style: ({ hovered }) => [styles.linkButton, hovered && styles.buttonUnderline], onPress: event => {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
onPress();
|
|
138
|
+
}, children: _jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }) }), _jsx(Space, { width: 8 }), _jsx(LakeText, { numberOfLines: 1, color: colors.gray[900], variant: variant, tooltip: tooltip, children: children })] }));
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Avoid usage
|
|
141
|
+
*/
|
|
142
|
+
export const ColorPatchCell = ({ alternativeText, color, isHovered, }) => {
|
|
143
|
+
return isHovered ? (_jsx(Box, { grow: 1, style: { backgroundColor: colors[color].primary }, children: isNotNullish(alternativeText) ? (_jsx(LakeText, { style: visuallyHiddenStyle, children: alternativeText })) : null })) : null;
|
|
164
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated Use `HeaderCell` instead
|
|
147
|
+
*/
|
|
148
|
+
export const SimpleHeaderCell = ({ justifyContent = "flex-start", ...props }) => (_jsx(HeaderCell, { ...props, align: match(justifyContent)
|
|
149
|
+
.returnType()
|
|
150
|
+
.with("flex-start", () => "left")
|
|
151
|
+
.with("flex-end", () => "right")
|
|
152
|
+
.otherwise(identity) }));
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated Use `TextCell` with color={…} and variant="medium" instead
|
|
155
|
+
*/
|
|
156
|
+
export const SimpleTitleCell = ({ isHighlighted = false, text, tooltip, }) => (_jsx(TextCell, { color: isHighlighted ? colors.current.primary : colors.gray[900], text: text, tooltip: tooltip, variant: "medium" }));
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated Use `TextCell` instead
|
|
159
|
+
*/
|
|
160
|
+
export const SimpleRegularTextCell = ({ color = colors.gray[900], text, textAlign = "left", variant = "regular", }) => _jsx(TextCell, { align: textAlign, color: color, text: text, variant: variant });
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated Use `CopyableTextCell` instead
|
|
163
|
+
*/
|
|
164
|
+
export const CopyableRegularTextCell = CopyableTextCell;
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated Use `<Cell align="left" />` instead
|
|
167
|
+
*/
|
|
168
|
+
export const StartAlignedCell = (props) => (_jsx(Cell, { align: "left", ...props }));
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated Use `<Cell align="center" />` instead
|
|
171
|
+
*/
|
|
172
|
+
export const CenteredCell = (props) => (_jsx(Cell, { align: "center", ...props }));
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated Use `<Cell align="right" />` instead
|
|
175
|
+
*/
|
|
176
|
+
export const EndAlignedCell = (props) => (_jsx(Cell, { align: "right", ...props }));
|
|
177
|
+
export const ActionCell = ({ style, ...props }) => (_jsx(Cell, { ...props, style: [styles.actionCell, style] }));
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated Use <ActionCell /> instead
|
|
180
|
+
*/
|
|
181
|
+
export const CellAction = ({ children }) => (_jsx(ActionCell, { children: children }));
|
|
@@ -22,6 +22,8 @@ const styles = StyleSheet.create({
|
|
|
22
22
|
minWidth: 90,
|
|
23
23
|
justifyContent: "center",
|
|
24
24
|
paddingHorizontal: 20,
|
|
25
|
+
},
|
|
26
|
+
transition: {
|
|
25
27
|
transitionDuration: "150ms",
|
|
26
28
|
transitionProperty: "background-color, color",
|
|
27
29
|
},
|
|
@@ -163,6 +165,8 @@ export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLab
|
|
|
163
165
|
const shouldHideContents = loading || progressAnimation.isSome();
|
|
164
166
|
return (_jsx(Pressable, { href: href, hrefAttrs: hrefAttrs, role: href != null ? "link" : "button", "aria-busy": loading, "aria-disabled": disabled, "aria-controls": ariaControls, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, disabled: loading || disabled || progressAnimation.isSome(), ref: forwardedRef, onPress: onPress, style: ({ hovered, pressed, focused }) => [
|
|
165
167
|
styles.base,
|
|
168
|
+
(hovered || pressed) && styles.transition,
|
|
169
|
+
grow && styles.grow,
|
|
166
170
|
isSmall && styles.small,
|
|
167
171
|
vertical && [styles.vertical, isSmall && styles.verticalSmall],
|
|
168
172
|
hasIconStart && isSmall ? styles.withIconStartSmall : styles.withIconStart,
|
|
@@ -170,7 +174,6 @@ export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLab
|
|
|
170
174
|
hasOnlyIcon && (isSmall ? styles.iconSmallOnly : styles.iconOnly),
|
|
171
175
|
(disabled || progressAnimation.isSome()) && commonStyles.disabled,
|
|
172
176
|
disabled && forceBackground && styles.resetOpacity,
|
|
173
|
-
grow && styles.grow,
|
|
174
177
|
match(mode)
|
|
175
178
|
.with("primary", () => ({
|
|
176
179
|
backgroundColor: color === "warning"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { StyleSheet, View } from "react-native";
|
|
4
|
-
import { colors } from "../constants/design";
|
|
4
|
+
import { colors, radii } from "../constants/design";
|
|
5
5
|
import { LakeText } from "./LakeText";
|
|
6
6
|
import { Pressable } from "./Pressable";
|
|
7
7
|
import { Space } from "./Space";
|
|
@@ -29,6 +29,12 @@ const styles = StyleSheet.create({
|
|
|
29
29
|
disabled: {
|
|
30
30
|
opacity: 0.5,
|
|
31
31
|
},
|
|
32
|
+
errorPill: {
|
|
33
|
+
width: 5,
|
|
34
|
+
height: 5,
|
|
35
|
+
backgroundColor: colors.negative[500],
|
|
36
|
+
borderRadius: radii[6],
|
|
37
|
+
},
|
|
32
38
|
});
|
|
33
39
|
export const LakeCheckbox = ({ value, color = "current", disabled = false, isError = false, }) => {
|
|
34
40
|
const isFirstRender = useRef(true);
|
|
@@ -50,5 +56,5 @@ export const LakeCheckbox = ({ value, color = "current", disabled = false, isErr
|
|
|
50
56
|
], children: [value === true && (_jsx(Svg, { viewBox: "0 0 16 16", children: _jsx(Path, { d: "m3.5 7.5 2.8 3.4 5.6-6.7", stroke: colors[color].contrast, strokeWidth: 1.5, fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: "20", strokeDashoffset: shouldAnimate ? "20" : "0", children: shouldAnimate && (_jsx(Animate, { attributeName: "stroke-dashoffset", values: "20;0", dur: "150ms", begin: "150ms", fill: "freeze" })) }) })), value === "mixed" && (_jsx(View, { style: [styles.mixed, { backgroundColor: colors[color].contrast }] }))] }));
|
|
51
57
|
};
|
|
52
58
|
export const LakeLabelledCheckbox = ({ value, color, label, onValueChange, disabled = false, isError = false, }) => {
|
|
53
|
-
return (_jsxs(Pressable, { role: "checkbox", "aria-checked": value, style: styles.labelled, onPress: () => onValueChange(value === true ? false : true), disabled: disabled, children: [_jsx(LakeCheckbox, { value: value, color: color, disabled: disabled, isError: isError }), _jsx(Space, { width: 8 }), _jsx(LakeText, { color: colors.gray[900], userSelect: "none", children: label })] }));
|
|
59
|
+
return (_jsxs(Pressable, { role: "checkbox", "aria-checked": value, style: styles.labelled, onPress: () => onValueChange(value === true ? false : true), disabled: disabled, children: [_jsx(LakeCheckbox, { value: value, color: color, disabled: disabled, isError: isError }), _jsx(Space, { width: 8 }), _jsx(LakeText, { color: colors.gray[900], userSelect: "none", children: label }), isError ? (_jsxs(_Fragment, { children: [_jsx(Space, { width: 8 }), _jsx(View, { style: styles.errorPill })] })) : null] }));
|
|
54
60
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { PressableStateCallbackType, ViewStyle } from "react-native";
|
|
3
3
|
import { ColumnCellConfig, ColumnTitleConfig, LinkConfig } from "./VirtualizedList";
|
|
4
|
+
export type { LinkConfig } from "./VirtualizedList";
|
|
4
5
|
export type ColumnConfig<T, ExtraInfo> = {
|
|
5
6
|
id: string;
|
|
6
7
|
width: number | "grow";
|
|
@@ -46,4 +47,3 @@ export declare const PlainListViewPlaceholder: ({ count, rowHeight, groupHeaderH
|
|
|
46
47
|
headerHeight?: number;
|
|
47
48
|
marginHorizontal?: string;
|
|
48
49
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
49
|
-
export {};
|