@swan-io/lake 11.1.5 → 11.1.6
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
package/src/components/Cells.js
CHANGED
|
@@ -3,7 +3,7 @@ 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, invariantColors,
|
|
6
|
+
import { colors, invariantColors, spacings } from "../constants/design";
|
|
7
7
|
import { setClipboardText } from "../utils/clipboard";
|
|
8
8
|
import { identity } from "../utils/function";
|
|
9
9
|
import { isNotNullish, isNullish } from "../utils/nullish";
|
|
@@ -73,24 +73,30 @@ const styles = StyleSheet.create({
|
|
|
73
73
|
headerUnderlineActive: {
|
|
74
74
|
backgroundColor: colors.current[500],
|
|
75
75
|
},
|
|
76
|
+
// eslint-disable-next-line react-native/no-color-literals
|
|
76
77
|
buttonUnderline: {
|
|
77
|
-
|
|
78
|
+
position: "absolute",
|
|
79
|
+
bottom: 0,
|
|
80
|
+
left: 0,
|
|
81
|
+
right: spacings[8],
|
|
82
|
+
height: 2,
|
|
83
|
+
backgroundColor: "currentColor",
|
|
78
84
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
marginHorizontal: negativeSpacings[8],
|
|
85
|
+
buttonEndUnderline: {
|
|
86
|
+
right: 0,
|
|
87
|
+
left: spacings[8],
|
|
83
88
|
},
|
|
84
|
-
|
|
85
|
-
justifyContent: "center",
|
|
89
|
+
fullHeight: {
|
|
86
90
|
height: "100%",
|
|
87
|
-
paddingHorizontal: spacings[8],
|
|
88
91
|
},
|
|
89
|
-
|
|
92
|
+
button: {
|
|
90
93
|
justifyContent: "center",
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
height: "100%",
|
|
95
|
+
paddingRight: spacings[8],
|
|
96
|
+
},
|
|
97
|
+
buttonEnd: {
|
|
98
|
+
paddingRight: 0,
|
|
99
|
+
paddingLeft: spacings[8],
|
|
94
100
|
},
|
|
95
101
|
actionCell: {
|
|
96
102
|
paddingVertical: spacings[16],
|
|
@@ -130,7 +136,7 @@ export const CopyableTextCell = ({ copiedWording, copyWording, text, textToCopy,
|
|
|
130
136
|
setClipboardText(clipboardText);
|
|
131
137
|
setVisibleState("copied");
|
|
132
138
|
}, [clipboardText]);
|
|
133
|
-
return (_jsxs(Cell, {
|
|
139
|
+
return (_jsxs(Cell, { style: styles.fullHeight, children: [_jsx(LakeTooltip, { content: visibleState === "copy" ? copyWording : copiedWording, onHide: () => setVisibleState("copy"), placement: "left", togglableOnFocus: true, containerStyle: styles.fullHeight, children: _jsx(Pressable, { "aria-label": copyWording, role: "button", onPress: onPress, style: styles.button, children: ({ hovered }) => (_jsxs(_Fragment, { children: [_jsx(Icon, { name: hovered ? "copy-filled" : "copy-regular", color: "currentColor", size: 14 }), hovered && _jsx(View, { role: "none", style: styles.buttonUnderline })] })) }) }), _jsx(LakeText, { numberOfLines: 1, color: colors.gray[900], tooltip: tooltip, variant: variant, children: text })] }));
|
|
134
140
|
};
|
|
135
141
|
// TODO: handle `+` sign properly
|
|
136
142
|
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: [
|
|
@@ -139,15 +145,15 @@ export const BalanceCell = ({ textAlign = "right", align = textAlign, currency,
|
|
|
139
145
|
], 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 ? "+" : "") +
|
|
140
146
|
formatCurrency(originalValue.value, originalValue.currency) }))] }));
|
|
141
147
|
export const LinkCell = ({ buttonPosition = "start", children, external = false, fadeOn, onPress, tooltip, variant = "medium", }) => {
|
|
148
|
+
const atEnd = buttonPosition === "end";
|
|
142
149
|
const elements = [
|
|
143
|
-
_jsx(Pressable, { style:
|
|
150
|
+
_jsx(Pressable, { style: [styles.button, atEnd && styles.buttonEnd], onPress: event => {
|
|
144
151
|
event.preventDefault();
|
|
145
152
|
onPress();
|
|
146
|
-
}, children: _jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }) }),
|
|
147
|
-
_jsx(Space, { width: 8 }),
|
|
153
|
+
}, children: ({ hovered }) => (_jsxs(_Fragment, { children: [_jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }), hovered && (_jsx(View, { role: "none", style: [styles.buttonUnderline, atEnd && styles.buttonEndUnderline] }))] })) }),
|
|
148
154
|
_jsx(LakeText, { numberOfLines: 1, color: colors.gray[900], variant: variant, tooltip: tooltip, children: children }),
|
|
149
155
|
];
|
|
150
|
-
if (
|
|
156
|
+
if (atEnd) {
|
|
151
157
|
elements.reverse();
|
|
152
158
|
}
|
|
153
159
|
return _jsx(Cell, { fadeOn: fadeOn, children: elements });
|
|
@@ -36,7 +36,7 @@ export const useContextualLayer = ({ placement, visible, matchReferenceWidth = f
|
|
|
36
36
|
top: rect.top + height,
|
|
37
37
|
};
|
|
38
38
|
const horizontalPosition = match(inferedPlacement)
|
|
39
|
-
.with("left", () => ({ left: rect.left }))
|
|
39
|
+
.with("left", () => ({ left: rect.left - 12 }))
|
|
40
40
|
.with("right", () => ({ right: window.innerWidth - rect.right }))
|
|
41
41
|
.with("center", () => ({ left: rect.left + width / 2, transform: "translateX(-50%)" }))
|
|
42
42
|
.exhaustive();
|