@swan-io/lake 7.2.5 → 7.3.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.2.5",
3
+ "version": "7.3.1",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Suspense, useEffect, useMemo, useRef, useState } from "react";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { PanResponder, Pressable, ScrollView, StyleSheet, View } from "react-native";
4
4
  import { commonStyles } from "../constants/commonStyles";
5
5
  import { backgroundColor, colors, radii, shadows, spacings } from "../constants/design";
@@ -8,6 +8,7 @@ import { limitElastic } from "../utils/math";
8
8
  import { FocusTrap } from "./FocusTrap";
9
9
  import { LoadingView } from "./LoadingView";
10
10
  import { Portal } from "./Portal";
11
+ import { Suspendable } from "./Suspendable";
11
12
  import { TransitionView } from "./TransitionView";
12
13
  const ELASTIC_LENGTH = 100; // the maximum value you can reach
13
14
  const ELASTIC_STRENGTH = 0.008; // higher value, maximum value reached faster
@@ -153,5 +154,5 @@ export const BottomPanel = ({ visible, onPressClose, children, returnFocus = tru
153
154
  if (rootElement == null) {
154
155
  return null;
155
156
  }
156
- return (_jsxs(Portal, { container: rootElement, children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? _jsx(View, { style: styles.overlay }) : null }), _jsx(Suspense, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: styles.fill, enter: styles.modalEnter, leave: styles.modalLeave, children: visible ? (_jsxs(View, { ref: container, style: styles.container, children: [_jsx(ScrollView, { style: styles.modalContainer, contentContainerStyle: styles.modalContentContainer, children: _jsxs(FocusTrap, { autoFocus: true, focusLock: true, returnFocus: returnFocus, style: styles.trap, children: [onPressClose != null ? (_jsx(Pressable, { onPress: onPressClose, style: styles.pressableOverlay })) : null, _jsxs(View, { style: styles.modal, children: [_jsx(View, { style: styles.grabContainer, ...panResponder.panHandlers, children: _jsx(View, { style: styles.grabLine }) }), children] })] }) }), _jsx(View, { style: styles.bottomCache })] })) : null }) })] }));
157
+ return (_jsxs(Portal, { container: rootElement, children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? _jsx(View, { style: styles.overlay }) : null }), _jsx(Suspendable, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: styles.fill, enter: styles.modalEnter, leave: styles.modalLeave, children: visible ? (_jsxs(View, { ref: container, style: styles.container, children: [_jsx(ScrollView, { style: styles.modalContainer, contentContainerStyle: styles.modalContentContainer, children: _jsxs(FocusTrap, { autoFocus: true, focusLock: true, returnFocus: returnFocus, style: styles.trap, children: [onPressClose != null ? (_jsx(Pressable, { onPress: onPressClose, style: styles.pressableOverlay })) : null, _jsxs(View, { style: styles.modal, children: [_jsx(View, { style: styles.grabContainer, ...panResponder.panHandlers, children: _jsx(View, { style: styles.grabLine }) }), children] })] }) }), _jsx(View, { style: styles.bottomCache })] })) : null }) })] }));
157
158
  };
@@ -71,7 +71,7 @@ export declare const BalanceCell: ({ value, currency, originalValue, formatCurre
71
71
  textAlign?: "left" | "right" | "center" | undefined;
72
72
  variant?: "light" | "semibold" | "medium" | "regular" | "smallSemibold" | "smallMedium" | "smallRegular" | undefined;
73
73
  }) => import("react/jsx-runtime").JSX.Element;
74
- export declare const LinkCell: ({ children, external, onPress, variant, tooltip, }: {
74
+ export declare const LinkCell: ({ children, external, onPress, variant, tooltip, buttonPosition, }: {
75
75
  children: ReactNode;
76
76
  onPress: () => void;
77
77
  external?: boolean | undefined;
@@ -90,6 +90,7 @@ export declare const LinkCell: ({ children, external, onPress, variant, tooltip,
90
90
  containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
91
91
  disabled?: boolean | undefined;
92
92
  } & import("react").RefAttributes<import("./LakeTooltip").TooltipRef>, "children"> | undefined;
93
+ buttonPosition?: "end" | "start" | undefined;
93
94
  }) => import("react/jsx-runtime").JSX.Element;
94
95
  export declare const StartAlignedCell: ({ children }: {
95
96
  children: ReactNode;
@@ -142,11 +142,12 @@ export const BalanceCell = ({ value, currency, originalValue, formatCurrency, te
142
142
  value < 0 && { color: colors.negative.primary },
143
143
  ], children: [value > 0 && "+", formatCurrency(value, currency)] }) }), isNotNullish(originalValue) && originalValue.currency !== currency && (_jsx(View, { style: styles.cell, children: _jsxs(LakeText, { style: styles.mediumText, align: textAlign, color: colors.gray[500], variant: "smallRegular", children: [originalValue.value > 0 && "+", formatCurrency(originalValue.value, originalValue.currency)] }) }))] }));
144
144
  };
145
- export const LinkCell = ({ children, external = false, onPress, variant = "medium", tooltip, }) => {
146
- return (_jsxs(View, { style: styles.cell, children: [_jsx(Pressable, { style: ({ hovered }) => [styles.icon, hovered && styles.underline], onPress: event => {
147
- event.preventDefault();
148
- onPress();
149
- }, children: _jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }) }), _jsx(Space, { width: 8 }), _jsx(LakeText, { color: colors.gray[900], variant: variant, style: styles.mediumText, tooltip: tooltip, children: children })] }));
145
+ export const LinkCell = ({ children, external = false, onPress, variant = "medium", tooltip, buttonPosition = "start", }) => {
146
+ const ArrowButton = () => (_jsx(Pressable, { style: ({ hovered }) => [styles.icon, hovered && styles.underline], onPress: event => {
147
+ event.preventDefault();
148
+ onPress();
149
+ }, children: _jsx(Icon, { size: 14, name: external ? "open-regular" : "arrow-right-filled" }) }));
150
+ return (_jsxs(View, { style: styles.cell, children: [buttonPosition === "start" && (_jsxs(_Fragment, { children: [_jsx(ArrowButton, {}), _jsx(Space, { width: 8 })] })), _jsx(LakeText, { color: colors.gray[900], variant: variant, style: styles.mediumText, tooltip: tooltip, children: children }), buttonPosition === "end" && (_jsxs(_Fragment, { children: [_jsx(Space, { width: 8 }), _jsx(ArrowButton, {})] }))] }));
150
151
  };
151
152
  export const StartAlignedCell = ({ children }) => {
152
153
  return _jsx(View, { style: styles.cell, children: children });
@@ -1,16 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Suspense, useEffect, useState } from "react";
2
+ import { useEffect, useState } from "react";
3
3
  import { StyleSheet, View } from "react-native";
4
4
  import { backgroundColor } from "../constants/design";
5
5
  import { FocusTrap } from "./FocusTrap";
6
6
  import { LoadingView } from "./LoadingView";
7
7
  import { Portal } from "./Portal";
8
+ import { Suspendable } from "./Suspendable";
8
9
  import { TransitionView } from "./TransitionView";
9
10
  const BACKGROUND_COLOR = "rgba(0, 0, 0, 0.6)";
10
11
  const styles = StyleSheet.create({
11
12
  root: {
12
13
  ...StyleSheet.absoluteFillObject,
13
- overflow: "hidden",
14
+ position: "fixed",
14
15
  },
15
16
  inert: {
16
17
  pointerEvents: "none",
@@ -36,14 +37,14 @@ const styles = StyleSheet.create({
36
37
  },
37
38
  containerEnter: {
38
39
  animationKeyframes: {
39
- "0%": { opacity: 0, transform: "translateZ(0px) translateX(200px)" },
40
+ "0%": { opacity: 0, transform: "translateX(200px)" },
40
41
  },
41
42
  animationDuration: "500ms",
42
43
  animationTimingFunction: "ease-in-out",
43
44
  },
44
45
  containerLeave: {
45
46
  animationKeyframes: {
46
- "100%": { opacity: 0, transform: "translateZ(0px) translateX(200px)" },
47
+ "100%": { opacity: 0, transform: "translateX(200px)" },
47
48
  },
48
49
  animationDuration: "500ms",
49
50
  animationTimingFunction: "ease-in-out",
@@ -54,21 +55,20 @@ const styles = StyleSheet.create({
54
55
  },
55
56
  container: {
56
57
  ...StyleSheet.absoluteFillObject,
57
- transform: "translateZ(0px)",
58
58
  flexDirection: "row",
59
59
  alignItems: "stretch",
60
60
  backgroundColor: backgroundColor.default,
61
61
  },
62
62
  contentsEnter: {
63
63
  animationKeyframes: {
64
- "0%": { transform: "translateZ(0px) translateX(50px)" },
64
+ "0%": { transform: "translateX(50px)" },
65
65
  },
66
66
  animationDuration: "500ms",
67
67
  animationTimingFunction: "ease-in-out",
68
68
  },
69
69
  contentsLeave: {
70
70
  animationKeyframes: {
71
- "100%": { transform: "translateZ(0px) translateX(50px)" },
71
+ "100%": { transform: "translateX(50px)" },
72
72
  },
73
73
  animationDuration: "500ms",
74
74
  animationTimingFunction: "ease-in-out",
@@ -76,7 +76,6 @@ const styles = StyleSheet.create({
76
76
  contentsContainer: {
77
77
  ...StyleSheet.absoluteFillObject,
78
78
  zIndex: 2,
79
- transform: "translateZ(0px)",
80
79
  maxWidth: "100%",
81
80
  },
82
81
  contents: {
@@ -90,5 +89,5 @@ export const FullViewportLayer = ({ visible, children }) => {
90
89
  useEffect(() => {
91
90
  setDelayedVisible(visible);
92
91
  }, [visible]);
93
- return (_jsx(Portal, { container: rootNode, children: _jsxs(View, { style: [styles.root, !visible && styles.inert], children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? _jsx(View, { style: styles.overlay }) : null }), _jsx(Suspense, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: styles.fill, enter: styles.containerEnter, leave: styles.containerLeave, children: delayedVisible ? (_jsx(FocusTrap, { focusLock: true, autoFocus: true, returnFocus: true, style: styles.container, children: _jsx(TransitionView, { style: styles.contentsContainer, enter: styles.contentsEnter, leave: styles.contentsLeave, children: _jsx(View, { style: styles.contents, children: _jsx(View, { style: styles.contentsContainer, children: children }) }) }) })) : null }) })] }) }));
92
+ return (_jsx(Portal, { container: rootNode, children: _jsxs(View, { style: [styles.root, !visible && styles.inert], children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? _jsx(View, { style: styles.overlay }) : null }), _jsx(Suspendable, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: styles.fill, enter: styles.containerEnter, leave: styles.containerLeave, children: delayedVisible ? (_jsx(FocusTrap, { focusLock: true, autoFocus: true, returnFocus: true, style: styles.container, children: _jsx(TransitionView, { style: styles.contentsContainer, enter: styles.contentsEnter, leave: styles.contentsLeave, children: _jsx(View, { style: styles.contents, children: _jsx(View, { style: styles.contentsContainer, children: children }) }) }) })) : null }) })] }) }));
94
93
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Suspense, forwardRef, useEffect, useState } from "react";
2
+ import { forwardRef, useEffect, useState } from "react";
3
3
  import { StyleSheet, View } from "react-native";
4
4
  import { backgroundColor, breakpoints } from "../constants/design";
5
5
  import { useBodyClassName } from "../hooks/useBodyClassName";
@@ -8,6 +8,7 @@ import { LoadingView } from "./LoadingView";
8
8
  import { Portal } from "./Portal";
9
9
  import { Pressable } from "./Pressable";
10
10
  import { ResponsiveContainer } from "./ResponsiveContainer";
11
+ import { Suspendable } from "./Suspendable";
11
12
  import { TransitionView } from "./TransitionView";
12
13
  const BACKGROUND_COLOR = "rgba(0, 0, 0, 0.6)";
13
14
  const styles = StyleSheet.create({
@@ -102,5 +103,5 @@ export const RightPanel = forwardRef(({ visible, children, onPressClose }, ref)
102
103
  setDelayedVisible(visible);
103
104
  }, [visible]);
104
105
  useBodyClassName("RightPanelOpen", { enabled: visible });
105
- return (_jsx(Portal, { container: rootNode, children: _jsx(View, { style: [styles.root, !visible && styles.inert], children: _jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.small, children: ({ large }) => (_jsxs(_Fragment, { children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? (onPressClose != null ? (_jsx(Pressable, { style: styles.overlay, onPress: onPressClose })) : (_jsx(View, { style: styles.overlay }))) : null }), _jsx(Suspense, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: [styles.fillMax, large && styles.fillMaxLarge], enter: styles.containerEnter, leave: styles.containerLeave, children: delayedVisible ? (_jsx(FocusTrap, { onEscapeKey: onPressClose, focusLock: true, autoFocus: true, returnFocus: true, ref: ref, style: styles.container, children: _jsx(TransitionView, { style: styles.contentsContainer, enter: styles.contentsEnter, leave: styles.contentsLeave, children: _jsx(View, { style: styles.contents, children: _jsx(View, { style: styles.contentsContainer, children: typeof children == "function" ? (_jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.small, children: children })) : (children) }) }) }) })) : null }) })] })) }) }) }));
106
+ return (_jsx(Portal, { container: rootNode, children: _jsx(View, { style: [styles.root, !visible && styles.inert], children: _jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.small, children: ({ large }) => (_jsxs(_Fragment, { children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? (onPressClose != null ? (_jsx(Pressable, { style: styles.overlay, onPress: onPressClose })) : (_jsx(View, { style: styles.overlay }))) : null }), _jsx(Suspendable, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: [styles.fillMax, large && styles.fillMaxLarge], enter: styles.containerEnter, leave: styles.containerLeave, children: delayedVisible ? (_jsx(FocusTrap, { onEscapeKey: onPressClose, focusLock: true, autoFocus: true, returnFocus: true, ref: ref, style: styles.container, children: _jsx(TransitionView, { style: styles.contentsContainer, enter: styles.contentsEnter, leave: styles.contentsLeave, children: _jsx(View, { style: styles.contents, children: _jsx(View, { style: styles.contentsContainer, children: typeof children == "function" ? (_jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.small, children: children })) : (children) }) }) }) })) : null }) })] })) }) }) }));
106
107
  });
@@ -0,0 +1,3 @@
1
+ import { SuspenseProps } from "react";
2
+ export declare const Suspendable: (props: SuspenseProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const useIsSuspendable: () => boolean;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Suspense, createContext, useContext } from "react";
3
+ const SuspendableContext = createContext(false);
4
+ export const Suspendable = (props) => {
5
+ return (_jsx(SuspendableContext.Provider, { value: true, children: _jsx(Suspense, { ...props }) }));
6
+ };
7
+ export const useIsSuspendable = () => {
8
+ return useContext(SuspendableContext);
9
+ };