@swan-io/lake 7.3.3 → 7.4.0
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/FixedListViewCells.d.ts +3 -0
- package/src/components/LakeText.d.ts +1 -0
- package/src/components/LakeTooltip.d.ts +1 -0
- package/src/components/LakeTooltip.js +2 -2
- package/src/components/ProjectEnvTag.js +4 -7
- package/src/components/Tag.d.ts +1 -1
- package/src/components/Tag.js +54 -56
package/package.json
CHANGED
|
@@ -28,6 +28,7 @@ export declare const SimpleTitleCell: ({ isHighlighted, text, tooltip, }: {
|
|
|
28
28
|
onShow?: (() => void) | undefined;
|
|
29
29
|
placement?: "left" | "right" | "center" | undefined;
|
|
30
30
|
width?: number | undefined;
|
|
31
|
+
maxWidth?: number | undefined;
|
|
31
32
|
togglableOnFocus?: boolean | undefined;
|
|
32
33
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
33
34
|
disabled?: boolean | undefined;
|
|
@@ -55,6 +56,7 @@ export declare const CopyableRegularTextCell: ({ variant, text, textToCopy, copy
|
|
|
55
56
|
onShow?: (() => void) | undefined;
|
|
56
57
|
placement?: "left" | "right" | "center" | undefined;
|
|
57
58
|
width?: number | undefined;
|
|
59
|
+
maxWidth?: number | undefined;
|
|
58
60
|
togglableOnFocus?: boolean | undefined;
|
|
59
61
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
60
62
|
disabled?: boolean | undefined;
|
|
@@ -86,6 +88,7 @@ export declare const LinkCell: ({ children, external, onPress, variant, tooltip,
|
|
|
86
88
|
onShow?: (() => void) | undefined;
|
|
87
89
|
placement?: "left" | "right" | "center" | undefined;
|
|
88
90
|
width?: number | undefined;
|
|
91
|
+
maxWidth?: number | undefined;
|
|
89
92
|
togglableOnFocus?: boolean | undefined;
|
|
90
93
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
91
94
|
disabled?: boolean | undefined;
|
|
@@ -26,6 +26,7 @@ export declare const LakeText: import("react").ForwardRefExoticComponent<TextPro
|
|
|
26
26
|
onShow?: (() => void) | undefined;
|
|
27
27
|
placement?: "left" | "right" | "center" | undefined;
|
|
28
28
|
width?: number | undefined;
|
|
29
|
+
maxWidth?: number | undefined;
|
|
29
30
|
togglableOnFocus?: boolean | undefined;
|
|
30
31
|
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
31
32
|
disabled?: boolean | undefined;
|
|
@@ -50,7 +50,7 @@ export const LakeTooltip = forwardRef(({ content, children, ...rest }, forwarded
|
|
|
50
50
|
}
|
|
51
51
|
return (_jsx(Tooltip, { ref: forwardedRef, content: content, ...rest, children: children }));
|
|
52
52
|
});
|
|
53
|
-
const Tooltip = memo(forwardRef(({ children, content, describedBy, matchReferenceWidth = false, hideArrow = false, onHide, onShow, placement, width, togglableOnFocus = false, containerStyle, disabled = false, }, forwardedRef) => {
|
|
53
|
+
const Tooltip = memo(forwardRef(({ children, content, describedBy, matchReferenceWidth = false, hideArrow = false, onHide, onShow, placement, width, maxWidth, togglableOnFocus = false, containerStyle, disabled = false, }, forwardedRef) => {
|
|
54
54
|
const timeoutRef = useRef(0);
|
|
55
55
|
const [visible, setVisible] = useState(false);
|
|
56
56
|
const { referenceRef, position } = useContextualLayer({
|
|
@@ -117,7 +117,7 @@ const Tooltip = memo(forwardRef(({ children, content, describedBy, matchReferenc
|
|
|
117
117
|
.with("left", () => "start")
|
|
118
118
|
.with("center", () => "center")
|
|
119
119
|
.with("right", () => "end")
|
|
120
|
-
.exhaustive(), style: [styles.arrowBar, styles.arrowBarTop], children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 0 16 8 0 8", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null, _jsx(View, { style: [styles.content, { width }], children: typeof content === "string" || typeof content === "number" ? (_jsx(LakeText, { align: "center", color: colors.gray.contrast, children: content })) : (content) }), position.get().verticalPosition === "top" ? (_jsx(Box, { direction: "row", justifyContent: match(position.get().horizontalPosition)
|
|
120
|
+
.exhaustive(), style: [styles.arrowBar, styles.arrowBarTop], children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 0 16 8 0 8", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null, _jsx(View, { style: [styles.content, { width, maxWidth }], children: typeof content === "string" || typeof content === "number" ? (_jsx(LakeText, { align: "center", color: colors.gray.contrast, children: content })) : (content) }), position.get().verticalPosition === "top" ? (_jsx(Box, { direction: "row", justifyContent: match(position.get().horizontalPosition)
|
|
121
121
|
.with("left", () => "start")
|
|
122
122
|
.with("center", () => "center")
|
|
123
123
|
.with("right", () => "end")
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { match } from "ts-pattern";
|
|
3
|
-
import { Icon } from "./Icon";
|
|
4
2
|
import { Tag } from "./Tag";
|
|
5
3
|
export const ProjectEnvTag = (props) => {
|
|
6
4
|
const isLive = props.projectEnv === "Live";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.exhaustive() }));
|
|
5
|
+
if (props.iconOnly === true) {
|
|
6
|
+
return (_jsx(Tag, { color: isLive ? "live" : "sandbox", icon: isLive ? "live-regular" : "beaker-regular" }));
|
|
7
|
+
}
|
|
8
|
+
return _jsx(Tag, { color: isLive ? "live" : "sandbox", children: props.projectEnv });
|
|
12
9
|
};
|
package/src/components/Tag.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ type Props = {
|
|
|
13
13
|
style?: StyleProp<ViewStyle>;
|
|
14
14
|
ariaLabel?: string;
|
|
15
15
|
};
|
|
16
|
-
export declare const Tag: ({ children, label, color, size, icon,
|
|
16
|
+
export declare const Tag: ({ children, label, color, size, icon, ariaLabel, onPressRemove, style, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
export {};
|
package/src/components/Tag.js
CHANGED
|
@@ -1,84 +1,82 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { isValidElement } from "react";
|
|
3
|
-
import { Pressable, StyleSheet,
|
|
4
|
-
import { colors,
|
|
5
|
-
import { isNotNullish, isNotNullishOrEmpty
|
|
3
|
+
import { Pressable, StyleSheet, View } from "react-native";
|
|
4
|
+
import { colors, radii, spacings } from "../constants/design";
|
|
5
|
+
import { isNotNullish, isNotNullishOrEmpty } from "../utils/nullish";
|
|
6
6
|
import { Box } from "./Box";
|
|
7
7
|
import { Icon } from "./Icon";
|
|
8
|
-
import {
|
|
8
|
+
import { LakeText } from "./LakeText";
|
|
9
9
|
const styles = StyleSheet.create({
|
|
10
|
-
|
|
11
|
-
borderRadius: 4,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
container: {
|
|
11
|
+
borderRadius: radii[4],
|
|
12
|
+
height: spacings[24],
|
|
13
|
+
},
|
|
14
|
+
border: {
|
|
15
|
+
...StyleSheet.absoluteFillObject,
|
|
16
|
+
borderRadius: radii[4],
|
|
17
|
+
pointerEvents: "none",
|
|
15
18
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
padding: 0,
|
|
19
|
+
icon: {
|
|
20
|
+
aspectRatio: "1 / 1",
|
|
19
21
|
},
|
|
20
22
|
larger: {
|
|
21
|
-
height: 40,
|
|
23
|
+
height: spacings[40],
|
|
22
24
|
},
|
|
23
25
|
label: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
borderRightWidth: 0,
|
|
27
|
-
paddingHorizontal: 8,
|
|
28
|
-
},
|
|
29
|
-
withLabel: {
|
|
30
|
-
borderLeftWidth: 0,
|
|
31
|
-
borderTopLeftRadius: 0,
|
|
32
|
-
borderBottomLeftRadius: 0,
|
|
26
|
+
paddingHorizontal: spacings[8],
|
|
27
|
+
alignSelf: "stretch",
|
|
33
28
|
},
|
|
34
|
-
|
|
35
|
-
paddingHorizontal: 8,
|
|
29
|
+
contents: {
|
|
36
30
|
flexGrow: 1,
|
|
37
31
|
flexShrink: 1,
|
|
38
32
|
},
|
|
39
33
|
text: {
|
|
40
|
-
|
|
34
|
+
paddingHorizontal: spacings[8],
|
|
35
|
+
flexGrow: 1,
|
|
36
|
+
flexShrink: 1,
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
},
|
|
39
|
+
textWithIcon: {
|
|
40
|
+
paddingLeft: 0,
|
|
41
|
+
},
|
|
42
|
+
textContent: {
|
|
43
|
+
flexGrow: 1,
|
|
44
|
+
flexShrink: 1,
|
|
41
45
|
},
|
|
42
46
|
unselectable: {
|
|
43
47
|
userSelect: "none",
|
|
44
48
|
},
|
|
45
49
|
dismiss: {
|
|
50
|
+
alignSelf: "stretch",
|
|
46
51
|
justifyContent: "center",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
aspectRatio: "1 / 1",
|
|
54
|
+
borderTopRightRadius: radii[4],
|
|
55
|
+
borderBottomRightRadius: radii[4],
|
|
56
|
+
},
|
|
57
|
+
dismissIcon: {
|
|
58
|
+
transform: "translateX(-0.5px)",
|
|
50
59
|
},
|
|
51
60
|
});
|
|
52
|
-
export const Tag = ({ children, label, color = "gray", size = "small", icon,
|
|
53
|
-
const hasRemoveButton = isNotNullish(onPressRemove);
|
|
61
|
+
export const Tag = ({ children, label, color = "gray", size = "small", icon, ariaLabel, onPressRemove, style, }) => {
|
|
54
62
|
const hasLabel = isNotNullishOrEmpty(label);
|
|
55
|
-
const hasOnlyIcon = isNullish(children) && isNotNullish(icon);
|
|
56
63
|
const { primary, ...variant } = colors[color];
|
|
57
64
|
const tint50 = variant[50];
|
|
58
65
|
const tint100 = variant[100];
|
|
59
66
|
const tint200 = variant[200];
|
|
60
|
-
return (_jsxs(Box, { direction: "row",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
color: primary,
|
|
77
|
-
},
|
|
78
|
-
], children: children }))] }), hasRemoveButton && (_jsx(Pressable, { role: "button", onPress: onPressRemove, style: ({ hovered, pressed }) => [
|
|
79
|
-
styles.dismiss,
|
|
80
|
-
{ color: primary, borderColor: tint100 },
|
|
81
|
-
hovered && { backgroundColor: tint100 },
|
|
82
|
-
pressed && { backgroundColor: tint200 },
|
|
83
|
-
], children: _jsx(Icon, { name: "dismiss-regular", color: primary, size: 10 }) }))] })] }));
|
|
67
|
+
return (_jsxs(Box, { direction: "row", alignItems: "center", style: [
|
|
68
|
+
styles.container,
|
|
69
|
+
size === "large" && styles.larger,
|
|
70
|
+
{ backgroundColor: tint50 },
|
|
71
|
+
style,
|
|
72
|
+
], children: [hasLabel && (_jsx(Box, { alignItems: "center", direction: "row", style: [styles.label, { backgroundColor: tint100, borderColor: tint200 }], children: _jsx(LakeText, { numberOfLines: 1, variant: "smallMedium", style: styles.unselectable, color: primary, children: label }) })), _jsxs(Box, { alignItems: "center", direction: "row", "aria-label": ariaLabel, style: styles.contents, children: [isNotNullish(icon) ? (_jsx(Box, { style: [styles.icon, { width: size === "large" ? spacings[40] : spacings[24] }], alignItems: "center", justifyContent: "center", children: _jsx(Icon, { name: icon, color: primary, size: 16 }) })) : null, children != null ? (_jsx(Box, { direction: "row", alignItems: "center", style: [styles.text, isNotNullish(icon) ? styles.textWithIcon : null], children: isValidElement(children) ? (children) : (_jsx(LakeText, { numberOfLines: 1, variant: "smallMedium", color: primary, style: styles.textContent, children: children })) })) : null] }), onPressRemove != null ? (_jsx(Pressable, { role: "button", onPress: onPressRemove, style: ({ hovered, pressed }) => [
|
|
73
|
+
styles.dismiss,
|
|
74
|
+
{
|
|
75
|
+
color: primary,
|
|
76
|
+
width: size === "large" ? spacings[40] : spacings[24],
|
|
77
|
+
boxShadow: `-1px 0 ${tint200}`,
|
|
78
|
+
},
|
|
79
|
+
hovered && { backgroundColor: tint100 },
|
|
80
|
+
pressed && { backgroundColor: tint200 },
|
|
81
|
+
], children: _jsx(Icon, { name: "dismiss-regular", color: primary, size: 14, style: styles.dismissIcon }) })) : null, _jsx(View, { style: [styles.border, { boxShadow: `inset 0 0 0 1px ${tint200}` }] })] }));
|
|
84
82
|
};
|