@swan-io/lake 11.1.4 → 11.1.5

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,9 +1,9 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "11.1.4",
3
+ "version": "11.1.5",
4
4
  "engines": {
5
5
  "node": ">=20.9.0",
6
- "pnpm": "9.9.0"
6
+ "pnpm": "^9.13.0"
7
7
  },
8
8
  "files": [
9
9
  "LICENSE",
@@ -6,36 +6,25 @@ import { TextVariant } from "./LakeText";
6
6
  import { LakeTooltip } from "./LakeTooltip";
7
7
  declare const directionStyles: {
8
8
  column: {
9
- flexShrink: number;
10
9
  flexDirection: "column";
11
- justifyContent: "center";
12
- };
13
- columnReverse: {
14
- flexShrink: number;
15
- flexDirection: "column-reverse";
16
- justifyContent: "center";
17
10
  };
18
11
  row: {
19
- flexShrink: number;
20
12
  flexDirection: "row";
21
- alignItems: "center";
22
- };
23
- rowReverse: {
24
- flexShrink: number;
25
- flexDirection: "row-reverse";
26
- alignItems: "center";
27
13
  };
28
14
  };
29
15
  type Align = "left" | "center" | "right";
16
+ type FadeOn = "left" | "right";
30
17
  type SortDirection = "Desc" | "Asc";
31
18
  type TooltipProp = Except<ComponentProps<typeof LakeTooltip>, "children">;
32
19
  type CellProps = {
33
20
  children: ReactNode;
34
21
  align?: Align;
35
22
  direction?: keyof typeof directionStyles;
23
+ fadeOn?: FadeOn;
36
24
  style?: StyleProp<ViewStyle>;
25
+ contentContainerStyle?: StyleProp<ViewStyle>;
37
26
  };
38
- export declare const Cell: ({ children, align, direction, style }: CellProps) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const Cell: ({ children, align, direction, fadeOn, style, contentContainerStyle, }: CellProps) => import("react/jsx-runtime").JSX.Element;
39
28
  type HeaderCellProps = {
40
29
  align?: Align;
41
30
  sort?: SortDirection;
@@ -80,11 +69,12 @@ type LinkCellProps = {
80
69
  buttonPosition?: "start" | "end";
81
70
  children: ReactNode;
82
71
  external?: boolean;
72
+ fadeOn?: FadeOn;
83
73
  onPress: () => void;
84
74
  tooltip?: TooltipProp;
85
75
  variant?: TextVariant;
86
76
  };
87
- export declare const LinkCell: ({ buttonPosition, children, external, onPress, tooltip, variant, }: LinkCellProps) => import("react/jsx-runtime").JSX.Element;
77
+ export declare const LinkCell: ({ buttonPosition, children, external, fadeOn, onPress, tooltip, variant, }: LinkCellProps) => import("react/jsx-runtime").JSX.Element;
88
78
  /**
89
79
  * @deprecated Avoid usage
90
80
  */
@@ -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, negativeSpacings, spacings } from "../constants/design";
6
+ import { colors, invariantColors, negativeSpacings, 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";
@@ -15,28 +15,22 @@ import { Pressable } from "./Pressable";
15
15
  import { Space } from "./Space";
16
16
  /* eslint-disable react-native/no-unused-styles */
17
17
  const directionStyles = StyleSheet.create({
18
- column: {
19
- flexShrink: 1,
20
- flexDirection: "column",
21
- justifyContent: "center",
22
- },
23
- columnReverse: {
24
- flexShrink: 1,
25
- flexDirection: "column-reverse",
26
- justifyContent: "center",
27
- },
28
- row: {
29
- flexShrink: 1,
30
- flexDirection: "row",
31
- alignItems: "center",
32
- },
33
- rowReverse: {
34
- flexShrink: 1,
35
- flexDirection: "row-reverse",
36
- alignItems: "center",
37
- },
18
+ column: { flexDirection: "column" },
19
+ row: { flexDirection: "row" },
20
+ });
21
+ const alignItemsStyles = StyleSheet.create({
22
+ left: { alignItems: "flex-start" },
23
+ center: { alignItems: "center" },
24
+ right: { alignItems: "flex-end" },
25
+ });
26
+ const justifyContentStyles = StyleSheet.create({
27
+ left: { justifyContent: "flex-start" },
28
+ center: { justifyContent: "center" },
29
+ right: { justifyContent: "flex-end" },
38
30
  });
39
31
  /* eslint-enable react-native/no-unused-styles */
32
+ const fadeOnLeftMask = `linear-gradient(to right, ${invariantColors.transparent}, ${invariantColors.black} ${spacings[16]})`;
33
+ const fadeOnRightMask = `linear-gradient(to left, ${invariantColors.transparent}, ${invariantColors.black} ${spacings[16]})`;
40
34
  const styles = StyleSheet.create({
41
35
  cell: {
42
36
  flexDirection: "row",
@@ -44,14 +38,21 @@ const styles = StyleSheet.create({
44
38
  flexShrink: 1,
45
39
  paddingHorizontal: spacings[16],
46
40
  },
47
- noCursor: {
48
- cursor: "text",
41
+ cellContentContainer: {
42
+ flexGrow: 1,
43
+ flexShrink: 1,
44
+ overflow: "hidden",
49
45
  },
50
- marginLeftAuto: {
51
- marginLeft: "auto",
46
+ fadeOnLeft: {
47
+ maskImage: fadeOnLeftMask,
48
+ WebkitMaskImage: fadeOnLeftMask,
52
49
  },
53
- marginRightAuto: {
54
- marginRight: "auto",
50
+ fadeOnRight: {
51
+ maskImage: fadeOnRightMask,
52
+ WebkitMaskImage: fadeOnRightMask,
53
+ },
54
+ noCursor: {
55
+ cursor: "text",
55
56
  },
56
57
  sortIcon: {
57
58
  transitionProperty: "transform",
@@ -96,10 +97,14 @@ const styles = StyleSheet.create({
96
97
  paddingHorizontal: spacings[8],
97
98
  },
98
99
  });
99
- export const Cell = ({ children, align = "left", direction = "row", style }) => (_jsx(View, { style: [styles.cell, style], children: _jsx(View, { style: [
100
+ export const Cell = ({ children, align = "left", direction = "row", fadeOn, style, contentContainerStyle, }) => (_jsx(View, { style: [styles.cell, style], children: _jsx(View, { style: [
101
+ styles.cellContentContainer,
100
102
  directionStyles[direction],
101
- (align === "right" || align === "center") && styles.marginLeftAuto,
102
- (align === "left" || align === "center") && styles.marginRightAuto,
103
+ alignItemsStyles[direction === "row" ? "center" : align],
104
+ justifyContentStyles[direction === "row" ? align : "center"],
105
+ fadeOn === "left" && styles.fadeOnLeft,
106
+ fadeOn === "right" && styles.fadeOnRight,
107
+ contentContainerStyle,
103
108
  ], children: children }) }));
104
109
  export const HeaderCell = ({ align = "left", sort, text, onPress }) => {
105
110
  const sortActive = isNotNullish(sort) && isNotNullish(onPress);
@@ -110,9 +115,10 @@ export const HeaderCell = ({ align = "left", sort, text, onPress }) => {
110
115
  .with("Desc", () => "Asc")
111
116
  .otherwise(() => "Desc"));
112
117
  }, children: ({ hovered }) => (_jsxs(View, { style: [
118
+ styles.cellContentContainer,
113
119
  directionStyles["row"],
114
- (align === "right" || align === "center") && styles.marginLeftAuto,
115
- (align === "left" || align === "center") && styles.marginRightAuto,
120
+ alignItemsStyles["center"],
121
+ justifyContentStyles[align],
116
122
  ], 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] }))] })) }));
117
123
  };
118
124
  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 }) }));
@@ -132,10 +138,20 @@ export const BalanceCell = ({ textAlign = "right", align = textAlign, currency,
132
138
  value < 0 && { color: colors.negative.primary },
133
139
  ], 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
140
  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 => {
141
+ export const LinkCell = ({ buttonPosition = "start", children, external = false, fadeOn, onPress, tooltip, variant = "medium", }) => {
142
+ const elements = [
143
+ _jsx(Pressable, { style: ({ hovered }) => [styles.linkButton, hovered && styles.buttonUnderline], onPress: event => {
136
144
  event.preventDefault();
137
145
  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 })] }));
146
+ }, children: _jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }) }),
147
+ _jsx(Space, { width: 8 }),
148
+ _jsx(LakeText, { numberOfLines: 1, color: colors.gray[900], variant: variant, tooltip: tooltip, children: children }),
149
+ ];
150
+ if (buttonPosition === "end") {
151
+ elements.reverse();
152
+ }
153
+ return _jsx(Cell, { fadeOn: fadeOn, children: elements });
154
+ };
139
155
  /**
140
156
  * @deprecated Avoid usage
141
157
  */
@@ -7,12 +7,12 @@ export type ColumnTitleConfig<ExtraInfo> = {
7
7
  export type ColumnCellConfig<T, ExtraInfo> = {
8
8
  columnId: string;
9
9
  item: T;
10
- index: number;
11
- extraInfo: ExtraInfo;
12
10
  /**
13
- * @deprecated Always false in VirtualizedList
11
+ * isHovered is only set for PlainListView
14
12
  */
15
13
  isHovered: boolean;
14
+ index: number;
15
+ extraInfo: ExtraInfo;
16
16
  };
17
17
  export type ColumnConfig<T, ExtraInfo> = {
18
18
  id: string;
@@ -69,14 +69,12 @@ const styles = StyleSheet.create({
69
69
  transitionTimingFunction: "ease-in-out",
70
70
  },
71
71
  headerCell: {
72
- display: "flex",
73
72
  flexDirection: "row",
74
73
  flexGrow: 1,
75
74
  alignItems: "center",
76
75
  boxShadow: `0 -1px ${colors.gray[100]}`,
77
76
  },
78
77
  cell: {
79
- display: "flex",
80
78
  flexDirection: "row",
81
79
  flexGrow: 1,
82
80
  alignItems: "stretch",