@swan-io/lake 7.3.3 → 7.4.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "7.3.3",
3
+ "version": "7.4.1",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -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;
@@ -10,6 +10,7 @@ type Props = {
10
10
  onShow?: () => void;
11
11
  placement?: "left" | "right" | "center";
12
12
  width?: number;
13
+ maxWidth?: number;
13
14
  togglableOnFocus?: boolean;
14
15
  containerStyle?: ViewProps["style"];
15
16
  disabled?: boolean;
@@ -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
- return (_jsx(Tag, { color: isLive ? "live" : "sandbox", children: match(props)
8
- .with({ iconOnly: true, projectEnv: "Live" }, () => _jsx(Icon, { name: "live-regular", size: 20 }))
9
- .with({ iconOnly: true, projectEnv: "Sandbox" }, () => (_jsx(Icon, { name: "beaker-regular", size: 20 })))
10
- .with({ projectEnv: "Sandbox" }, { projectEnv: "Live" }, ({ projectEnv }) => projectEnv)
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
  };
@@ -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, iconSize, ariaLabel, onPressRemove, style, }: Props) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const Tag: ({ children, label, color, size, icon, ariaLabel, onPressRemove, style, }: Props) => import("react/jsx-runtime").JSX.Element;
17
17
  export {};
@@ -1,84 +1,83 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { isValidElement } from "react";
3
- import { Pressable, StyleSheet, Text } from "react-native";
4
- import { colors, texts } from "../constants/design";
5
- import { isNotNullish, isNotNullishOrEmpty, isNullish } from "../utils/nullish";
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 { Space } from "./Space";
8
+ import { LakeText } from "./LakeText";
9
9
  const styles = StyleSheet.create({
10
- base: {
11
- borderRadius: 4,
12
- borderWidth: 1,
13
- height: 28,
14
- overflow: "hidden",
10
+ container: {
11
+ alignSelf: "flex-start",
12
+ borderRadius: radii[4],
13
+ height: spacings[24],
14
+ },
15
+ border: {
16
+ ...StyleSheet.absoluteFillObject,
17
+ borderRadius: radii[4],
18
+ pointerEvents: "none",
15
19
  },
16
- onlyIcon: {
17
- height: 28,
18
- padding: 0,
20
+ icon: {
21
+ aspectRatio: "1 / 1",
19
22
  },
20
23
  larger: {
21
- height: 40,
24
+ height: spacings[40],
22
25
  },
23
26
  label: {
24
- borderTopRightRadius: 0,
25
- borderBottomRightRadius: 0,
26
- borderRightWidth: 0,
27
- paddingHorizontal: 8,
28
- },
29
- withLabel: {
30
- borderLeftWidth: 0,
31
- borderTopLeftRadius: 0,
32
- borderBottomLeftRadius: 0,
27
+ paddingHorizontal: spacings[8],
28
+ alignSelf: "stretch",
33
29
  },
34
- center: {
35
- paddingHorizontal: 8,
30
+ contents: {
36
31
  flexGrow: 1,
37
32
  flexShrink: 1,
38
33
  },
39
34
  text: {
40
- ...texts.smallMedium,
35
+ paddingHorizontal: spacings[8],
36
+ flexGrow: 1,
37
+ flexShrink: 1,
38
+ overflow: "hidden",
39
+ },
40
+ textWithIcon: {
41
+ paddingLeft: 0,
42
+ },
43
+ textContent: {
44
+ flexGrow: 1,
45
+ flexShrink: 1,
41
46
  },
42
47
  unselectable: {
43
48
  userSelect: "none",
44
49
  },
45
50
  dismiss: {
51
+ alignSelf: "stretch",
46
52
  justifyContent: "center",
47
- height: "100%",
48
- paddingHorizontal: 8,
49
- borderLeftWidth: 1,
53
+ alignItems: "center",
54
+ aspectRatio: "1 / 1",
55
+ borderTopRightRadius: radii[4],
56
+ borderBottomRightRadius: radii[4],
57
+ },
58
+ dismissIcon: {
59
+ transform: "translateX(-0.5px)",
50
60
  },
51
61
  });
52
- export const Tag = ({ children, label, color = "gray", size = "small", icon, iconSize = 16, ariaLabel, onPressRemove, style, }) => {
53
- const hasRemoveButton = isNotNullish(onPressRemove);
62
+ export const Tag = ({ children, label, color = "gray", size = "small", icon, ariaLabel, onPressRemove, style, }) => {
54
63
  const hasLabel = isNotNullishOrEmpty(label);
55
- const hasOnlyIcon = isNullish(children) && isNotNullish(icon);
56
64
  const { primary, ...variant } = colors[color];
57
65
  const tint50 = variant[50];
58
66
  const tint100 = variant[100];
59
67
  const tint200 = variant[200];
60
- return (_jsxs(Box, { direction: "row", children: [hasLabel && (_jsx(Box, { alignItems: "center", direction: "row", style: [
61
- styles.base,
62
- styles.label,
63
- size === "large" && styles.larger,
64
- hasOnlyIcon && styles.onlyIcon,
65
- { backgroundColor: tint100, borderColor: tint200 },
66
- ], children: _jsx(Text, { numberOfLines: 1, style: [styles.text, styles.unselectable, { color: primary }], children: label }) })), _jsxs(Box, { alignItems: "center", direction: "row", "aria-label": ariaLabel, style: [
67
- styles.base,
68
- size === "large" && styles.larger,
69
- hasOnlyIcon && styles.onlyIcon,
70
- { backgroundColor: tint50, borderColor: tint200 },
71
- hasLabel && styles.withLabel,
72
- style,
73
- ], children: [_jsxs(Box, { direction: "row", alignItems: "center", style: [styles.center, hasOnlyIcon && styles.onlyIcon], children: [isNotNullish(icon) ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon, color: primary, size: iconSize }), isNotNullish(children) && _jsx(Space, { width: 8 })] })) : null, isValidElement(children) ? (children) : (_jsx(Text, { numberOfLines: 1, style: [
74
- styles.text,
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 }) }))] })] }));
68
+ return (_jsxs(Box, { direction: "row", alignItems: "center", style: [
69
+ styles.container,
70
+ size === "large" && styles.larger,
71
+ { backgroundColor: tint50 },
72
+ style,
73
+ ], 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 }) => [
74
+ styles.dismiss,
75
+ {
76
+ color: primary,
77
+ width: size === "large" ? spacings[40] : spacings[24],
78
+ boxShadow: `-1px 0 ${tint200}`,
79
+ },
80
+ hovered && { backgroundColor: tint100 },
81
+ pressed && { backgroundColor: tint200 },
82
+ ], 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
83
  };