@swan-io/lake 13.1.7 → 13.1.9

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": "13.1.7",
3
+ "version": "13.1.9",
4
4
  "engines": {
5
5
  "node": "^22.12.0"
6
6
  },
@@ -9,6 +9,7 @@ type Props = {
9
9
  title: ReactNode;
10
10
  subtitle?: string;
11
11
  style?: StyleProp<ViewStyle>;
12
+ tag?: string;
12
13
  };
13
- export declare const LakeAlert: ({ anchored, variant, title, subtitle, children, style, callToAction, }: Props) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const LakeAlert: ({ anchored, variant, title, subtitle, children, style, callToAction, tag, }: Props) => import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { StyleSheet, View } from "react-native";
3
+ import { match } from "ts-pattern";
3
4
  import { commonStyles } from "../constants/commonStyles";
4
5
  import { breakpoints, colors, shadows } from "../constants/design";
5
6
  import { useResponsive } from "../hooks/useResponsive";
@@ -8,6 +9,7 @@ import { Box } from "./Box";
8
9
  import { Icon } from "./Icon";
9
10
  import { LakeText } from "./LakeText";
10
11
  import { Space } from "./Space";
12
+ import { Tag } from "./Tag";
11
13
  const styles = StyleSheet.create({
12
14
  base: {
13
15
  paddingVertical: 20,
@@ -71,14 +73,22 @@ const alertLeftBorder = {
71
73
  neutral: colors.gray[500],
72
74
  };
73
75
  const isText = (node) => typeof node === "string" || typeof node === "number";
74
- export const LakeAlert = ({ anchored = false, variant, title, subtitle, children, style, callToAction, }) => {
76
+ export const LakeAlert = ({ anchored = false, variant, title, subtitle, children, style, callToAction, tag, }) => {
75
77
  const color = alertColor[variant];
76
78
  const icon = alertIcon[variant];
77
79
  const { desktop } = useResponsive(breakpoints.medium);
80
+ const translateColorTag = () => match(variant)
81
+ .returnType()
82
+ .with("error", () => "negative")
83
+ .with("info", () => "shakespear")
84
+ .with("neutral", () => "gray")
85
+ .with("success", () => "positive")
86
+ .with("warning", () => "warning")
87
+ .exhaustive();
78
88
  return (_jsxs(View, { style: [
79
89
  styles.base,
80
90
  { backgroundColor: alertBackground[variant], borderColor: alertBorder[variant] },
81
91
  anchored ? styles.anchored : { borderLeftColor: alertLeftBorder[variant] },
82
92
  style,
83
- ], children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [icon != null ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon, color: color, size: 20 }), _jsx(Space, { width: 20 })] })) : null, _jsxs(View, { style: commonStyles.fill, children: [_jsx(LakeText, { color: color, variant: icon != null ? "regular" : "medium", children: title }), isNotNullishOrEmpty(subtitle) && _jsx(LakeText, { color: color, children: subtitle })] }), isNotNullish(callToAction) && _jsx(View, { style: styles.callToAction, children: callToAction })] }), isNotNullish(children) && (_jsxs(View, { style: desktop && icon != null && styles.content, children: [_jsx(Space, { height: 12 }), isText(children) ? _jsx(LakeText, { children: children }) : children] }))] }));
93
+ ], children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [icon != null ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon, color: color, size: 20 }), _jsx(Space, { width: 20 })] })) : null, _jsxs(View, { style: commonStyles.fill, children: [_jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsx(LakeText, { color: color, variant: icon != null ? "regular" : "medium", children: title }), tag && _jsx(Tag, { color: translateColorTag(), children: tag })] }), isNotNullishOrEmpty(subtitle) && _jsx(LakeText, { color: color, children: subtitle })] }), isNotNullish(callToAction) && _jsx(View, { style: styles.callToAction, children: callToAction })] }), isNotNullish(children) && (_jsxs(View, { style: desktop && icon != null && styles.content, children: [_jsx(Space, { height: 12 }), isText(children) ? _jsx(LakeText, { children: children }) : children] }))] }));
84
94
  };