@swan-io/lake 7.3.0 → 7.3.2

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.0",
3
+ "version": "7.3.2",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -29,8 +29,8 @@
29
29
  "@react-three/drei": "^9.104.1",
30
30
  "@react-three/fiber": "^8.16.1",
31
31
  "@swan-io/boxed": "^2.1.1",
32
- "@swan-io/chicane": "^2.0.0-rc.2",
33
- "@swan-io/use-form": "^2.0.0-rc.2",
32
+ "@swan-io/chicane": "^2.0.0",
33
+ "@swan-io/use-form": "^2.0.0",
34
34
  "dayjs": "^1.11.10",
35
35
  "polished": "^4.3.1",
36
36
  "prism-react-renderer": "^2.3.1",
@@ -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
  };
@@ -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
+ };