@swan-io/lake 8.4.3 → 8.4.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "8.4.3",
3
+ "version": "8.4.5",
4
4
  "engines": {
5
5
  "node": ">=20.9.0",
6
6
  "yarn": "^1.22.0"
@@ -1,11 +1,17 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AsyncData, Result } from "@swan-io/boxed";
3
3
  import { useRef, useState } from "react";
4
+ import { StyleSheet } from "react-native";
4
5
  import { P, match } from "ts-pattern";
5
6
  import { colors } from "../constants/design";
6
7
  import { LakeCombobox } from "./LakeCombobox";
7
8
  import { LakeText } from "./LakeText";
8
9
  import { Separator } from "./Separator";
10
+ const styles = StyleSheet.create({
11
+ unselectable: {
12
+ userSelect: "none",
13
+ },
14
+ });
9
15
  export const AutocompleteSearchInput = ({ inputRef, value, onValueChange, disabled, id, placeholder, error, emptyResultText, ListFooterComponent, shouldDisplaySuggestions = true, loadSuggestions, onSuggestion, onLoadError, }) => {
10
16
  const [state, setState] = useState(AsyncData.NotAsked());
11
17
  const lastRequest = useRef();
@@ -30,5 +36,5 @@ export const AutocompleteSearchInput = ({ inputRef, value, onValueChange, disabl
30
36
  }
31
37
  request.onResolve(value => setState(AsyncData.Done(value)));
32
38
  }
33
- }, keyExtractor: item => `${item.title} ${item.subtitle}`, emptyResultText: emptyResultText, renderItem: item => (_jsxs(_Fragment, { children: [_jsx(LakeText, { numberOfLines: 1, selectable: false, color: colors.gray[900], children: item.title }), _jsx(LakeText, { numberOfLines: 1, selectable: false, variant: "smallRegular", children: item.subtitle })] })) }));
39
+ }, keyExtractor: item => `${item.title} ${item.subtitle}`, emptyResultText: emptyResultText, renderItem: item => (_jsxs(_Fragment, { children: [_jsx(LakeText, { numberOfLines: 1, style: styles.unselectable, color: colors.gray[900], children: item.title }), _jsx(LakeText, { numberOfLines: 1, style: styles.unselectable, variant: "smallRegular", children: item.subtitle })] })) }));
34
40
  };
@@ -1,28 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useRef, useState } from "react";
3
- import { PanResponder, Pressable, ScrollView, StyleSheet, View } from "react-native";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { Pressable, ScrollView, StyleSheet, View } from "react-native";
4
4
  import { commonStyles } from "../constants/commonStyles";
5
- import { backgroundColor, colors, radii, shadows, spacings } from "../constants/design";
5
+ import { backgroundColor, radii, shadows } from "../constants/design";
6
6
  import { useBodyClassName } from "../hooks/useBodyClassName";
7
- import { limitElastic } from "../utils/math";
8
7
  import { FocusTrap } from "./FocusTrap";
9
8
  import { LoadingView } from "./LoadingView";
10
9
  import { Portal } from "./Portal";
11
10
  import { Suspendable } from "./Suspendable";
12
11
  import { TransitionView } from "./TransitionView";
13
- const ELASTIC_LENGTH = 100; // the maximum value you can reach
14
- const ELASTIC_STRENGTH = 0.008; // higher value, maximum value reached faster
15
- const limitGrab = limitElastic({
16
- elasticLength: ELASTIC_LENGTH,
17
- elasticStrength: ELASTIC_STRENGTH,
18
- });
19
- const DELTA_Y_CLOSE_THRESHOLD = 100;
20
- const SWIPE_CLOSE_VELOCITY = 0.5;
21
12
  const BACKGROUND_COLOR = "rgba(0, 0, 0, 0.6)";
22
13
  const styles = StyleSheet.create({
23
14
  fill: {
24
15
  ...StyleSheet.absoluteFillObject,
25
- position: "fixed",
16
+ position: "absolute",
26
17
  animationFillMode: "forwards",
27
18
  visibility: "visible",
28
19
  },
@@ -69,13 +60,6 @@ const styles = StyleSheet.create({
69
60
  transitionDuration: "300ms",
70
61
  transitionProperty: "transform",
71
62
  },
72
- bottomCache: {
73
- position: "absolute",
74
- bottom: -ELASTIC_LENGTH + 1,
75
- width: "100%",
76
- height: ELASTIC_LENGTH,
77
- backgroundColor: backgroundColor.accented,
78
- },
79
63
  modalContainer: {
80
64
  ...StyleSheet.absoluteFillObject,
81
65
  },
@@ -100,15 +84,6 @@ const styles = StyleSheet.create({
100
84
  opacity: 0,
101
85
  order: -1,
102
86
  },
103
- grabContainer: {
104
- paddingHorizontal: 128,
105
- paddingVertical: spacings[12],
106
- },
107
- grabLine: {
108
- backgroundColor: colors.gray[100],
109
- height: 5,
110
- borderRadius: radii[4],
111
- },
112
87
  });
113
88
  export const BottomPanel = ({ visible, onPressClose, children, returnFocus = true }) => {
114
89
  const [rootElement, setRootElement] = useState(() => undefined);
@@ -122,42 +97,13 @@ export const BottomPanel = ({ visible, onPressClose, children, returnFocus = tru
122
97
  setRootElement(undefined);
123
98
  };
124
99
  }, []);
125
- const panResponder = useMemo(() => PanResponder.create({
126
- onMoveShouldSetPanResponder: () => true,
127
- onPanResponderGrant: () => {
128
- if (container.current instanceof HTMLElement) {
129
- container.current.style.transitionDuration = "0ms";
130
- }
131
- },
132
- onPanResponderMove: (_event, { dy }) => {
133
- const translateY = dy > 0 ? dy : -limitGrab(-dy);
134
- if (container.current instanceof HTMLElement) {
135
- container.current.style.transform = `translateY(${translateY}px)`;
136
- }
137
- },
138
- onPanResponderRelease: (_event, gestureState) => {
139
- if (container.current instanceof HTMLElement) {
140
- // @ts-expect-error
141
- container.current.style.transitionDuration = null;
142
- }
143
- const shouldClose = gestureState.dy > DELTA_Y_CLOSE_THRESHOLD || gestureState.vy > SWIPE_CLOSE_VELOCITY;
144
- if (shouldClose) {
145
- onPressClose();
146
- }
147
- else {
148
- if (container.current instanceof HTMLElement) {
149
- container.current.style.transform = `translateY(0px)`;
150
- }
151
- }
152
- },
153
- }), [onPressClose]);
154
100
  useBodyClassName("BottomPanelOpen", { enabled: visible });
155
101
  if (rootElement == null) {
156
102
  return null;
157
103
  }
158
- 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, onEscapeKey: () => {
159
- if (onPressClose != null) {
160
- onPressClose();
161
- }
162
- }, style: styles.trap, children: [_jsxs(View, { style: styles.modal, children: [_jsx(View, { style: styles.grabContainer, ...panResponder.panHandlers, children: _jsx(View, { style: styles.grabLine }) }), children] }), onPressClose != null ? (_jsx(Pressable, { onPress: onPressClose, style: styles.pressableOverlay })) : null] }) }), _jsx(View, { style: styles.bottomCache })] })) : null }) })] }));
104
+ 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 ? (_jsx(View, { ref: container, style: styles.container, children: _jsx(ScrollView, { style: styles.modalContainer, contentContainerStyle: styles.modalContentContainer, children: _jsxs(FocusTrap, { autoFocus: true, focusLock: true, returnFocus: returnFocus, onEscapeKey: () => {
105
+ if (onPressClose != null) {
106
+ onPressClose();
107
+ }
108
+ }, style: styles.trap, children: [_jsx(View, { style: styles.modal, children: children }), onPressClose != null ? (_jsx(Pressable, { onPress: onPressClose, style: styles.pressableOverlay })) : null] }) }) })) : null }) })] }));
163
109
  };