@swan-io/lake 9.2.0 → 10.0.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": "9.2.0",
3
+ "version": "10.0.1",
4
4
  "engines": {
5
5
  "node": ">=20.9.0",
6
6
  "yarn": "^1.22.0"
@@ -26,31 +26,31 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@react-three/drei": "^9.109.2",
30
- "@react-three/fiber": "^8.16.8",
29
+ "@react-three/drei": "^9.114.6",
30
+ "@react-three/fiber": "^8.17.10",
31
31
  "@swan-io/boxed": "^3.0.0",
32
32
  "@swan-io/chicane": "^2.1.0",
33
33
  "@swan-io/use-form": "^3.1.0",
34
- "dayjs": "^1.11.12",
34
+ "dayjs": "^1.11.13",
35
35
  "polished": "^4.3.1",
36
- "prism-react-renderer": "^2.3.1",
36
+ "prism-react-renderer": "^2.4.0",
37
37
  "react": "^18.3.1",
38
38
  "react-atomic-state": "^2.0.0",
39
39
  "react-dom": "^18.3.1",
40
- "react-native-web": "^0.19.12",
40
+ "react-native-web": "^0.19.13",
41
41
  "rifm": "^0.12.1",
42
- "three": "^0.167.0",
42
+ "three": "^0.169.0",
43
43
  "ts-dedent": "^2.2.0",
44
- "ts-pattern": "^5.2.0",
44
+ "ts-pattern": "^5.5.0",
45
45
  "uuid": "^10.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@types/react": "^18.3.3",
49
- "@types/react-dom": "^18.3.0",
48
+ "@types/react": "^18.3.11",
49
+ "@types/react-dom": "^18.3.1",
50
50
  "@types/react-native": "^0.72.8",
51
- "@types/three": "^0.163.0",
51
+ "@types/three": "^0.169.0",
52
52
  "@types/uuid": "^10.0.0",
53
- "jsdom": "^24.1.1",
54
- "type-fest": "^4.23.0"
53
+ "jsdom": "^25.0.1",
54
+ "type-fest": "^4.26.1"
55
55
  }
56
56
  }
@@ -12,10 +12,6 @@ export type FilterCheckboxDef<T> = {
12
12
  items: Item<T>[];
13
13
  width?: number;
14
14
  checkAllLabel?: string;
15
- /**
16
- * @deprecated
17
- */
18
- submitText?: string;
19
15
  };
20
16
  export type FilterRadioDef<T> = {
21
17
  type: "radio";
@@ -39,19 +35,8 @@ export type FilterInputDef = {
39
35
  noValueText: string;
40
36
  placeholder?: string;
41
37
  validate?: (value: string) => ValidatorResult;
42
- /**
43
- * @deprecated
44
- */
45
- submitText?: string;
46
38
  };
47
- /**
48
- * @deprecated
49
- */
50
- export type FilterBooleanDef = {
51
- type: "boolean";
52
- label: string;
53
- };
54
- type Filter<T> = FilterCheckboxDef<T> | FilterRadioDef<T> | FilterDateDef | FilterInputDef | FilterBooleanDef;
39
+ type Filter<T> = FilterCheckboxDef<T> | FilterRadioDef<T> | FilterDateDef | FilterInputDef;
55
40
  type ExtractFilterValue<T extends Filter<unknown>> = T extends {
56
41
  type: "checkbox";
57
42
  } ? T["items"][number]["value"][] | undefined : T extends {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { DatePickerModal, } from "@swan-io/shared-business/src/components/DatePicker";
3
3
  import dayjs from "dayjs";
4
- import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
4
+ import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
5
5
  import { Pressable, StyleSheet, Text, View } from "react-native";
6
6
  import { P, match } from "ts-pattern";
7
7
  import { colors, shadows } from "../constants/design";
@@ -172,10 +172,6 @@ function FilterInput({ label, initialValue = "", noValueText, autoOpen = false,
172
172
  const onChangeText = useCallback((value) => setState(getValueState(value, false)), [getValueState]);
173
173
  return (_jsxs(View, { style: styles.container, children: [_jsx(FilterTag, { label: label, onPress: toggle, ref: tagRef, onPressRemove: onPressRemove, isActive: visible, value: validValue !== null && validValue !== void 0 ? validValue : noValueText }), _jsx(Popover, { role: "listbox", matchReferenceWidth: false, onDismiss: close, referenceRef: tagRef, returnFocus: false, visible: visible, children: _jsx(View, { style: [styles.dropdown, styles.inputContent], children: _jsx(LakeLabel, { label: label, render: id => (_jsx(LakeTextInput, { id: id, value: inputValue, error: error, style: styles.input, placeholder: placeholder, onChangeText: onChangeText })) }) }) })] }));
174
174
  }
175
- function FilterBooleanTag({ children, onAdd, onPressRemove }) {
176
- useEffect(onAdd, []); // eslint-disable-line react-hooks/exhaustive-deps
177
- return (_jsx(Tag, { color: "current", onPressRemove: onPressRemove, children: children }));
178
- }
179
175
  const getFilterValue = (_type, filters, name) => filters[name];
180
176
  export const FiltersStack = ({ filters, openedFilters, definition, onChangeOpened, onChangeFilters, }) => {
181
177
  const previousOpened = usePreviousValue(openedFilters);
@@ -203,16 +199,10 @@ export const FiltersStack = ({ filters, openedFilters, definition, onChangeOpene
203
199
  onChangeFilters({ ...filters, [filterName]: undefined });
204
200
  onChangeOpened(openedFilters.filter(f => f !== filterName));
205
201
  } })))
206
- .with({ type: "input" }, ({ type, label, placeholder, noValueText, submitText, validate }) => (_jsx(FilterInput, { label: label, placeholder: placeholder, noValueText: noValueText, submitText: submitText, autoOpen: lastOpenedFilter === filterName, validate: validate, initialValue: getFilterValue(type, filters, filterName), onValueChange: value => onChangeFilters({ ...filters, [filterName]: value }), onPressRemove: () => {
202
+ .with({ type: "input" }, ({ type, label, placeholder, noValueText, validate }) => (_jsx(FilterInput, { label: label, placeholder: placeholder, noValueText: noValueText, autoOpen: lastOpenedFilter === filterName, validate: validate, initialValue: getFilterValue(type, filters, filterName), onValueChange: value => onChangeFilters({ ...filters, [filterName]: value }), onPressRemove: () => {
207
203
  onChangeFilters({ ...filters, [filterName]: undefined });
208
204
  onChangeOpened(openedFilters.filter(f => f !== filterName));
209
205
  } })))
210
- .with({ type: "boolean" }, ({ label }) => (_jsx(FilterBooleanTag, { onAdd: () => {
211
- onChangeFilters({ ...filters, [filterName]: true });
212
- }, onPressRemove: () => {
213
- onChangeFilters({ ...filters, [filterName]: undefined });
214
- onChangeOpened(openedFilters.filter(f => f !== filterName));
215
- }, children: label })))
216
206
  .exhaustive() }, filterName));
217
207
  }) }));
218
208
  };
@@ -1,14 +1,8 @@
1
- import { CountryCCA2, CountryCCA3 } from "@swan-io/shared-business/src/constants/countries";
1
+ import { CountryCCA2 } from "@swan-io/shared-business/src/constants/countries";
2
2
  export type FlagCode = CountryCCA2 | "EU";
3
3
  type Props = {
4
- width?: number;
5
- } & ({
6
- /**
7
- * @deprecated Use cca2 prop instead
8
- */
9
- icon: CountryCCA3;
10
- } | {
11
4
  code: FlagCode;
12
- });
5
+ width?: number;
6
+ };
13
7
  export declare const Flag: (props: Props) => import("react/jsx-runtime").JSX.Element;
14
8
  export {};
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Lazy } from "@swan-io/boxed";
3
- import { getCCA2forCCA3, } from "@swan-io/shared-business/src/constants/countries";
4
3
  import { useEffect, useMemo, useState } from "react";
5
4
  import { match } from "ts-pattern";
6
5
  import { getFlagGlyphName } from "../utils/string";
@@ -14,7 +13,7 @@ const svgUrlGetter = Lazy(async () => {
14
13
  });
15
14
  export const Flag = (props) => {
16
15
  var _a;
17
- const code = "code" in props ? props.code : getCCA2forCCA3(props.icon);
16
+ const { code } = props;
18
17
  const width = (_a = props.width) !== null && _a !== void 0 ? _a : 18;
19
18
  const [url, setUrl] = useState(svgUrl);
20
19
  useEffect(() => {
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { View } from "react-native";
3
3
  export declare const Form: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<{
4
- children?: ReactNode | undefined;
4
+ children?: React.ReactNode | undefined;
5
5
  hitSlop?: import("react-native").Insets | undefined;
6
6
  id?: string | undefined;
7
7
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | undefined;
@@ -23,7 +23,7 @@ type HeadingAlign = keyof typeof alignments;
23
23
  type HeadingVariant = keyof typeof variants;
24
24
  export declare const LakeHeading: import("react").ForwardRefExoticComponent<{
25
25
  allowFontScaling?: boolean | undefined;
26
- children?: ReactNode | undefined;
26
+ children?: React.ReactNode | undefined;
27
27
  ellipsizeMode?: "head" | "middle" | "tail" | "clip" | undefined;
28
28
  id?: string | undefined;
29
29
  lineBreakMode?: "head" | "middle" | "tail" | "clip" | undefined;
@@ -64,7 +64,7 @@ export declare const LakeTagInput: import("react").ForwardRefExoticComponent<{
64
64
  autoComplete?: ("additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "email" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "impp" | "language" | "name" | "new-password" | "nickname" | "off" | "on" | "one-time-code" | "organization" | "organization-title" | "postal-code" | "sex" | "street-address" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-national" | "transaction-amount" | "transaction-currency" | "url" | "username") | undefined;
65
65
  enterKeyHint?: ("enter" | "done" | "go" | "next" | "previous" | "search" | "send") | undefined;
66
66
  rows?: number | undefined;
67
- children?: import("react").ReactNode | undefined;
67
+ children?: React.ReactNode | undefined;
68
68
  hitSlop?: import("react-native").Insets | undefined;
69
69
  id?: string | undefined;
70
70
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | undefined;
@@ -77,7 +77,7 @@ export declare const LakeTextInput: import("react").ForwardRefExoticComponent<{
77
77
  enterKeyHint?: ("enter" | "done" | "go" | "next" | "previous" | "search" | "send") | undefined;
78
78
  rows?: number | undefined;
79
79
  readOnly?: boolean | undefined;
80
- children?: ReactNode | undefined;
80
+ children?: React.ReactNode | undefined;
81
81
  hitSlop?: import("react-native").Insets | undefined;
82
82
  id?: string | undefined;
83
83
  onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | undefined;
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactNode, Ref } from "react";
2
- import { HrefAttrs, NativeSyntheticEvent, PressableProps, PressableStateCallbackType, Text, TextInput, TextInputProps, TextProps, View, ViewProps } from "react-native";
2
+ import { HrefAttrs, NativeSyntheticEvent, PressableProps, PressableStateCallbackType, Text, TextInputProps, TextProps, View, ViewProps } from "react-native";
3
3
  import { Except, Merge } from "type-fest";
4
4
  import { PressResponderConfig } from "../hooks/usePressEvents";
5
5
  type Props<BaseProps extends TextProps | TextInputProps> = Merge<BaseProps, {
@@ -33,20 +33,10 @@ type ExtraProps = {
33
33
  };
34
34
  export type PressableViewProps = Except<Props<ViewProps>, "children">;
35
35
  export type PressableTextProps = Props<TextProps>;
36
- /**
37
- * @deprecated
38
- */
39
- export type PressableTextInputProps = Except<Props<TextInputProps>, "children" | "editable" | "keyboardType" | "numberOfLines">;
40
36
  export declare const Pressable: FC<PressableProps & ExtraProps & {
41
37
  ref?: Ref<View>;
42
38
  }>;
43
39
  export declare const PressableText: FC<PressableTextProps & {
44
40
  ref?: Ref<Text>;
45
41
  }>;
46
- /**
47
- * @deprecated
48
- */
49
- export declare const PressableTextInput: FC<PressableTextInputProps & {
50
- ref?: Ref<TextInput>;
51
- }>;
52
42
  export {};
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // https://github.com/necolas/react-native-web/blob/0.19.1/packages/react-native-web/src/exports/Pressable/index.js
3
3
  import { forwardRef, memo, useCallback, useMemo, useRef, } from "react";
4
- import { StyleSheet, Text, TextInput, View, } from "react-native";
4
+ import { StyleSheet, Text, View, } from "react-native";
5
5
  import { match } from "ts-pattern";
6
6
  import { useForceableState } from "../hooks/useForceableState";
7
7
  import { useHover } from "../hooks/useHover";
@@ -100,9 +100,4 @@ Component, config = {}) => {
100
100
  };
101
101
  export const Pressable = memo(getPressable(View, { applyPressStyle: true }));
102
102
  export const PressableText = memo(getPressable(Text, { applyPressStyle: true }));
103
- /**
104
- * @deprecated
105
- */
106
- export const PressableTextInput = memo(getPressable(TextInput, { applyPressStyle: false }));
107
103
  PressableText.displayName = "PressableText";
108
- PressableTextInput.displayName = "PressableTextInput";
@@ -61,7 +61,7 @@ export const WithPartnerAccentColor = ({ color, scoped = false, children }) => {
61
61
  rootElement.style.setProperty("--color-partner-contrast", colorScale.contrast, "");
62
62
  }
63
63
  }
64
- catch (err) {
64
+ catch {
65
65
  // will default to white label color
66
66
  }
67
67
  }, [color, scoped]);
@@ -6,7 +6,7 @@ const isValidColor = (color) => {
6
6
  getLuminance(color);
7
7
  return true;
8
8
  }
9
- catch (error) {
9
+ catch {
10
10
  return false;
11
11
  }
12
12
  };
@@ -13,7 +13,7 @@ export const usePersistedState = (key, defaultValue) => {
13
13
  try {
14
14
  localStorage.setItem(key, JSON.stringify(state));
15
15
  }
16
- catch (err) {
16
+ catch {
17
17
  // ignore
18
18
  }
19
19
  }, [key]);
@@ -1,18 +1 @@
1
- /**
2
- * @deprecated
3
- */
4
- export declare const isChrome: boolean;
5
- /**
6
- * @deprecated
7
- */
8
- export declare const isMobile: boolean;
9
- /**
10
- * @deprecated
11
- */
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
- */
17
- export declare const isSafari: boolean;
18
1
  export declare const isDecentMobileDevice: boolean;
@@ -1,24 +1,3 @@
1
- import { isNullish } from "./nullish";
2
- const CHROME_REGEXP = /Chrom(e|ium)\//;
3
- const MOBI_REGEXP = /Mobi/;
4
- const SAFARI_REGEXP = /Safari\//;
5
- /**
6
- * @deprecated
7
- */
8
- export const isChrome = CHROME_REGEXP.test(navigator.userAgent);
9
- /**
10
- * @deprecated
11
- */
12
- export const isMobile = MOBI_REGEXP.test(navigator.userAgent);
13
- /**
14
- * @deprecated
15
- */
16
- export const isChromeMobile = isChrome && isMobile;
17
- /**
18
- * @see https://github.com/jakearchibald/safari-14-idb-fix/blob/v3.0.0/src/index.ts#L7
19
- * @deprecated
20
- */
21
- export const isSafari = isNullish(navigator.userAgentData) && SAFARI_REGEXP.test(navigator.userAgent) && !isChrome;
22
1
  // from https://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system
23
2
  export const isDecentMobileDevice = (() => {
24
3
  // Windows Phone must come first because its UA also contains "Android"
@@ -1,7 +1,2 @@
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
- */
6
- export declare const preventSafariAutoZoomOnInputs: () => void;
7
2
  export declare const detectScrollAnimationEnd: (element: HTMLElement) => Future<void>;
@@ -1,19 +1,4 @@
1
1
  import { Future } from "@swan-io/boxed";
2
- import { isNotNullish } from "./nullish";
3
- import { isSafari } from "./userAgent";
4
- /**
5
- * Prevents Safari from zooming automatically on inputs, still allow user to zoom manually
6
- * @deprecated
7
- */
8
- export const preventSafariAutoZoomOnInputs = () => {
9
- if (isSafari) {
10
- const viewport = document.querySelector("meta[name=viewport]");
11
- const content = viewport === null || viewport === void 0 ? void 0 : viewport.getAttribute("content");
12
- if (isNotNullish(viewport) && isNotNullish(content)) {
13
- viewport.setAttribute("content", content + ", maximum-scale=1.0");
14
- }
15
- }
16
- };
17
2
  // When using `node.scroll()` with smooth behavior, there isn't any event to detect when the scroll animation is finished
18
3
  // We need this also with `ScrollView.scrollTo` (which just call the native node.scroll function)
19
4
  // More info about why this workaround: https://stackoverflow.com/a/60001032
@@ -1,5 +0,0 @@
1
- import { Animated } from "react-native";
2
- /**
3
- * @deprecated
4
- */
5
- export declare const useAnimatedValue: (value: number) => Animated.Value;
@@ -1,13 +0,0 @@
1
- import { useRef } from "react";
2
- import { Animated } from "react-native";
3
- const UNSET = Symbol("unset");
4
- /**
5
- * @deprecated
6
- */
7
- export const useAnimatedValue = (value) => {
8
- const ref = useRef(UNSET);
9
- if (ref.current === UNSET) {
10
- ref.current = new Animated.Value(value);
11
- }
12
- return ref.current;
13
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Import this function from string.ts instead
3
- */
4
- export declare const getFlagGlyphName: (flag: string) => string;
@@ -1,5 +0,0 @@
1
- import { getFlagGlyphName as fn } from "./string";
2
- /**
3
- * @deprecated Import this function from string.ts instead
4
- */
5
- export const getFlagGlyphName = fn;
@@ -1,17 +0,0 @@
1
- /**
2
- * @deprecated
3
- */
4
- export type ControllableTimeout = {
5
- readonly duration: number;
6
- readonly clear: () => void;
7
- readonly reset: () => void;
8
- };
9
- /**
10
- * @deprecated
11
- */
12
- export declare const createControllableTimeout: (config: {
13
- duration: number;
14
- onStart: (duration: number) => void;
15
- onEnd: () => void;
16
- onReset: (duration: number) => void;
17
- }) => ControllableTimeout;
@@ -1,49 +0,0 @@
1
- // based on https://gist.github.com/ncou/3a0a1f89c8e22416d0d607f621a948a9
2
- /**
3
- * @deprecated
4
- */
5
- export const createControllableTimeout = (config) => {
6
- const { duration, onStart, onReset, onEnd } = config;
7
- let timerId = 0;
8
- let remaining = duration;
9
- const clear = () => {
10
- document.removeEventListener("visibilitychange", onVisibilityChange);
11
- window.clearTimeout(timerId);
12
- };
13
- const start = () => {
14
- if (remaining <= 0) {
15
- return;
16
- }
17
- timerId = window.setTimeout(() => {
18
- remaining = 0;
19
- clear();
20
- onEnd();
21
- }, remaining);
22
- onStart(duration);
23
- };
24
- const reset = () => {
25
- window.clearTimeout(timerId);
26
- remaining = duration;
27
- timerId = window.setTimeout(() => {
28
- remaining = 0;
29
- clear();
30
- onEnd();
31
- }, duration);
32
- onReset(duration);
33
- };
34
- const onVisibilityChange = () => {
35
- document.removeEventListener("visibilitychange", onVisibilityChange);
36
- start();
37
- };
38
- if (document.hidden) {
39
- document.addEventListener("visibilitychange", onVisibilityChange);
40
- }
41
- else {
42
- start();
43
- }
44
- return {
45
- duration,
46
- clear,
47
- reset,
48
- };
49
- };