@swan-io/lake 8.3.2 → 8.4.0

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,8 +1,8 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "8.3.2",
3
+ "version": "8.4.0",
4
4
  "engines": {
5
- "node": ">=18.0.0",
5
+ "node": ">=20.9.0",
6
6
  "yarn": "^1.22.0"
7
7
  },
8
8
  "files": [
@@ -98,6 +98,7 @@ const styles = StyleSheet.create({
98
98
  outlineWidth: 0,
99
99
  // make focus indicator invisible on iOS (outline: none doesn't work)
100
100
  opacity: 0,
101
+ order: -1,
101
102
  },
102
103
  grabContainer: {
103
104
  paddingHorizontal: 128,
@@ -154,5 +155,9 @@ export const BottomPanel = ({ visible, onPressClose, children, returnFocus = tru
154
155
  if (rootElement == null) {
155
156
  return null;
156
157
  }
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 }) })] }));
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 }) })] }));
158
163
  };
@@ -42,7 +42,7 @@ export const Toggle = ({ onToggle, value, disabled = false, mode = "desktop", on
42
42
  const onItemRef = useRef(null);
43
43
  const offItemRef = useRef(null);
44
44
  const [handleStyle, setHandleStyle] = useState();
45
- const isMobile = mode === "mobile";
45
+ const isMobileMode = mode === "mobile";
46
46
  const onColor = value ? colors.positive[500] : colors.gray[500];
47
47
  const offColor = !value ? colors.negative[500] : colors.gray[500];
48
48
  const reajustLayout = useCallback(() => {
@@ -55,7 +55,7 @@ export const Toggle = ({ onToggle, value, disabled = false, mode = "desktop", on
55
55
  }));
56
56
  }, () => { });
57
57
  }, [value]);
58
- useEffect(reajustLayout, [reajustLayout, value, isMobile, onLabel, offLabel]);
58
+ useEffect(reajustLayout, [reajustLayout, value, isMobileMode, onLabel, offLabel]);
59
59
  return (_jsxs(Pressable, { style: [styles.switch, disabled && commonStyles.disabled], onPress: () => onToggle(!value), "aria-disabled": disabled, "aria-checked": value, disabled: disabled, ref: containerRef, role: "switch", onLayout: reajustLayout, children: [_jsx(View, { style: [
60
60
  styles.handle,
61
61
  handleStyle,
@@ -63,5 +63,5 @@ export const Toggle = ({ onToggle, value, disabled = false, mode = "desktop", on
63
63
  borderColor: value ? colors.positive[500] : colors.negative[500],
64
64
  backgroundColor: value ? colors.positive[50] : colors.negative[50],
65
65
  },
66
- ] }), _jsx(Box, { style: styles.switchItem, ref: onItemRef, children: isMobile ? (_jsx(Icon, { size: 16, name: "checkmark-circle-regular", color: onColor })) : (_jsx(LakeText, { variant: "smallMedium", color: onColor, children: onLabel })) }), _jsx(Box, { style: styles.switchItem, ref: offItemRef, children: isMobile ? (_jsx(Icon, { size: 16, name: "subtract-circle-regular", color: offColor })) : (_jsx(LakeText, { variant: "smallMedium", color: offColor, children: offLabel })) })] }));
66
+ ] }), _jsx(Box, { style: styles.switchItem, ref: onItemRef, children: isMobileMode ? (_jsx(Icon, { size: 16, name: "checkmark-circle-regular", color: onColor })) : (_jsx(LakeText, { variant: "smallMedium", color: onColor, children: onLabel })) }), _jsx(Box, { style: styles.switchItem, ref: offItemRef, children: isMobileMode ? (_jsx(Icon, { size: 16, name: "subtract-circle-regular", color: offColor })) : (_jsx(LakeText, { variant: "smallMedium", color: offColor, children: offLabel })) })] }));
67
67
  };
@@ -1,4 +1,18 @@
1
+ /**
2
+ * @deprecated
3
+ */
1
4
  export declare const isChrome: boolean;
5
+ /**
6
+ * @deprecated
7
+ */
2
8
  export declare const isMobile: boolean;
9
+ /**
10
+ * @deprecated
11
+ */
3
12
  export declare const isChromeMobile: boolean;
13
+ /**
14
+ * @see https://github.com/jakearchibald/safari-14-idb-fix/blob/v3.0.0/src/index.ts#L7
15
+ * @deprecated
16
+ */
4
17
  export declare const isSafari: boolean;
18
+ export declare const isDecentMobileDevice: boolean;
@@ -2,8 +2,35 @@ import { isNullish } from "./nullish";
2
2
  const CHROME_REGEXP = /Chrom(e|ium)\//;
3
3
  const MOBI_REGEXP = /Mobi/;
4
4
  const SAFARI_REGEXP = /Safari\//;
5
+ /**
6
+ * @deprecated
7
+ */
5
8
  export const isChrome = CHROME_REGEXP.test(navigator.userAgent);
9
+ /**
10
+ * @deprecated
11
+ */
6
12
  export const isMobile = MOBI_REGEXP.test(navigator.userAgent);
13
+ /**
14
+ * @deprecated
15
+ */
7
16
  export const isChromeMobile = isChrome && isMobile;
8
- // https://github.com/jakearchibald/safari-14-idb-fix/blob/v3.0.0/src/index.ts#L7
17
+ /**
18
+ * @see https://github.com/jakearchibald/safari-14-idb-fix/blob/v3.0.0/src/index.ts#L7
19
+ * @deprecated
20
+ */
9
21
  export const isSafari = isNullish(navigator.userAgentData) && SAFARI_REGEXP.test(navigator.userAgent) && !isChrome;
22
+ // from https://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system
23
+ export const isDecentMobileDevice = (() => {
24
+ // Windows Phone must come first because its UA also contains "Android"
25
+ if (/windows phone/i.test(navigator.userAgent)) {
26
+ return false;
27
+ }
28
+ if (/android/i.test(navigator.userAgent)) {
29
+ return true;
30
+ }
31
+ // MSStream must be checked to avoid identify IE11 as iOS
32
+ if (/iPad|iPhone/.test(navigator.userAgent) && !("MSStream" in window)) {
33
+ return true;
34
+ }
35
+ return false;
36
+ })();
@@ -1,3 +1,7 @@
1
1
  import { Future } from "@swan-io/boxed";
2
+ /**
3
+ * Prevents Safari from zooming automatically on inputs, still allow user to zoom manually
4
+ * @deprecated
5
+ */
2
6
  export declare const preventSafariAutoZoomOnInputs: () => void;
3
7
  export declare const detectScrollAnimationEnd: (element: HTMLElement) => Future<void>;
@@ -1,7 +1,10 @@
1
1
  import { Future } from "@swan-io/boxed";
2
2
  import { isNotNullish } from "./nullish";
3
3
  import { isSafari } from "./userAgent";
4
- // Prevents Safari from zooming automatically on inputs, still allow user to zoom manually
4
+ /**
5
+ * Prevents Safari from zooming automatically on inputs, still allow user to zoom manually
6
+ * @deprecated
7
+ */
5
8
  export const preventSafariAutoZoomOnInputs = () => {
6
9
  if (isSafari) {
7
10
  const viewport = document.querySelector("meta[name=viewport]");