@swan-io/lake 4.9.2 → 4.10.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": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.0.0",
|
|
6
6
|
"yarn": "^1.22.0"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@popperjs/core": "^2.11.8",
|
|
30
|
-
"@react-three/drei": "^9.
|
|
30
|
+
"@react-three/drei": "^9.99.4",
|
|
31
31
|
"@react-three/fiber": "^8.15.16",
|
|
32
|
-
"@swan-io/boxed": "^2.0.
|
|
32
|
+
"@swan-io/boxed": "^2.0.1",
|
|
33
33
|
"@swan-io/chicane": "^1.4.1",
|
|
34
34
|
"dayjs": "^1.11.10",
|
|
35
35
|
"polished": "^4.3.1",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
"rifm": "^0.12.1",
|
|
44
44
|
"three": "^0.161.0",
|
|
45
45
|
"ts-dedent": "^2.2.0",
|
|
46
|
-
"ts-pattern": "^5.0.
|
|
46
|
+
"ts-pattern": "^5.0.8",
|
|
47
47
|
"urql": "^4.0.6",
|
|
48
48
|
"uuid": "^9.0.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@types/react": "^18.2.
|
|
51
|
+
"@types/react": "^18.2.60",
|
|
52
52
|
"@types/react-dom": "^18.2.19",
|
|
53
53
|
"@types/react-native": "^0.72.8",
|
|
54
54
|
"@types/three": "^0.161.2",
|
|
55
55
|
"@types/uuid": "^9.0.8",
|
|
56
|
-
"jsdom": "^
|
|
57
|
-
"type-fest": "^4.10.
|
|
56
|
+
"jsdom": "^24.0.0",
|
|
57
|
+
"type-fest": "^4.10.3"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -21,13 +21,14 @@ export type SelectProps<V> = {
|
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
value?: V;
|
|
23
23
|
onValueChange: (value: V) => void;
|
|
24
|
+
isItemDisabled?: (value: V) => boolean | string;
|
|
24
25
|
hideErrors?: boolean;
|
|
25
26
|
id?: string;
|
|
26
27
|
error?: string;
|
|
27
28
|
readOnly?: boolean;
|
|
28
29
|
style?: StyleProp<ViewStyle>;
|
|
29
30
|
};
|
|
30
|
-
declare const LakeSelectWithRef: <V>({ title, items, valueStyle, size, color, disabled, mode, placeholder, readOnly, id, matchReferenceWidth, value, error, hideErrors, icon, onValueChange, PopoverFooter, style, }: SelectProps<V>, forwardedRef: ForwardedRef<View>) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
declare const LakeSelectWithRef: <V>({ title, items, valueStyle, size, color, disabled, mode, placeholder, readOnly, id, matchReferenceWidth, value, error, hideErrors, icon, onValueChange, isItemDisabled, PopoverFooter, style, }: SelectProps<V>, forwardedRef: ForwardedRef<View>) => import("react/jsx-runtime").JSX.Element;
|
|
31
32
|
export declare const LakeSelect: <I>(props: SelectProps<I> & {
|
|
32
33
|
ref?: ForwardedRef<View> | undefined;
|
|
33
34
|
}) => ReturnType<typeof LakeSelectWithRef>;
|
|
@@ -11,6 +11,7 @@ import { Box } from "./Box";
|
|
|
11
11
|
import { Fill } from "./Fill";
|
|
12
12
|
import { Icon } from "./Icon";
|
|
13
13
|
import { LakeText } from "./LakeText";
|
|
14
|
+
import { LakeTooltip } from "./LakeTooltip";
|
|
14
15
|
import { Popover } from "./Popover";
|
|
15
16
|
import { Pressable } from "./Pressable";
|
|
16
17
|
import { Separator } from "./Separator";
|
|
@@ -80,6 +81,9 @@ const styles = StyleSheet.create({
|
|
|
80
81
|
borderRadius: radii[4],
|
|
81
82
|
outlineStyle: "none",
|
|
82
83
|
},
|
|
84
|
+
itemDisabled: {
|
|
85
|
+
opacity: 0.5,
|
|
86
|
+
},
|
|
83
87
|
selectListTitle: {
|
|
84
88
|
paddingHorizontal: spacings[24],
|
|
85
89
|
paddingVertical: spacings[12],
|
|
@@ -107,7 +111,7 @@ const styles = StyleSheet.create({
|
|
|
107
111
|
borderColor: colors.negative[500],
|
|
108
112
|
},
|
|
109
113
|
});
|
|
110
|
-
const LakeSelectWithRef = ({ title, items, valueStyle, size, color = "current", disabled = false, mode = "normal", placeholder, readOnly = false, id, matchReferenceWidth = true, value, error, hideErrors = false, icon, onValueChange, PopoverFooter, style, }, forwardedRef) => {
|
|
114
|
+
const LakeSelectWithRef = ({ title, items, valueStyle, size, color = "current", disabled = false, mode = "normal", placeholder, readOnly = false, id, matchReferenceWidth = true, value, error, hideErrors = false, icon, onValueChange, isItemDisabled, PopoverFooter, style, }, forwardedRef) => {
|
|
111
115
|
var _a;
|
|
112
116
|
const inputRef = useRef(null);
|
|
113
117
|
const listRef = useRef(null);
|
|
@@ -184,14 +188,16 @@ const LakeSelectWithRef = ({ title, items, valueStyle, size, color = "current",
|
|
|
184
188
|
}
|
|
185
189
|
}, keyExtractor: (_, index) => `select-item-${index}`, renderItem: ({ item, index }) => {
|
|
186
190
|
const isSelected = value === item.value;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
const isDisabled = isNotNullish(isItemDisabled) && isItemDisabled(item.value);
|
|
192
|
+
return (_jsx(LakeTooltip, { placement: "right", content: isDisabled, disabled: typeof isDisabled !== "string", children: _jsxs(Pressable, { ref: element => (listItemRefs.current[index] = element), onKeyDown: onKeyDown, disabled: isDisabled !== false, style: ({ hovered, focused }) => [
|
|
193
|
+
styles.item,
|
|
194
|
+
(hovered || isSelected) && styles.itemHighlighted,
|
|
195
|
+
focused && styles.itemFocused,
|
|
196
|
+
isDisabled !== false && styles.itemDisabled,
|
|
197
|
+
], role: "option", "aria-selected": true, onPress: () => {
|
|
198
|
+
onValueChange(item.value);
|
|
199
|
+
close();
|
|
200
|
+
}, children: [isNotNullish(item.icon) && (_jsxs(_Fragment, { children: [item.icon, _jsx(Space, { width: 12 })] })), _jsx(LakeText, { color: colors.gray[900], numberOfLines: 1, style: [styles.itemText, isSelected && styles.selected], children: item.name }), _jsx(Fill, { minWidth: 12 }), isSelected && (_jsx(Icon, { color: colors.positive[500], name: "checkmark-filled", size: 14 }))] }) }));
|
|
195
201
|
} }), PopoverFooter] })] }));
|
|
196
202
|
};
|
|
197
203
|
export const LakeSelect = forwardRef(LakeSelectWithRef);
|
package/src/utils/function.d.ts
CHANGED
|
@@ -4,4 +4,10 @@ export declare const stubFalse: () => false;
|
|
|
4
4
|
export declare const stubTrue: () => true;
|
|
5
5
|
export declare const unionToArray: <T extends PropertyKey>(object: Record<T, true>) => T[];
|
|
6
6
|
export declare const getUnionGuard: <T extends PropertyKey>(object: Record<T, true>) => (value: unknown) => value is T;
|
|
7
|
+
export declare const deriveUnion: <T extends PropertyKey>(object: Record<T, true>) => {
|
|
8
|
+
array: T[];
|
|
9
|
+
set: Set<T>;
|
|
10
|
+
is: (value: unknown) => value is T;
|
|
11
|
+
P: import("ts-pattern/dist/types/Pattern").GuardP<unknown, T>;
|
|
12
|
+
};
|
|
7
13
|
export declare const memoize: <Input extends unknown[], Output>(func: (...input: Input) => Output, getCacheKey: (...input: Input) => string) => (...input: Input) => Output;
|
package/src/utils/function.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dict } from "@swan-io/boxed";
|
|
2
|
+
import { P } from "ts-pattern";
|
|
2
3
|
export const identity = (value) => value;
|
|
3
4
|
export const noop = () => { };
|
|
4
5
|
export const stubFalse = () => false;
|
|
@@ -8,6 +9,12 @@ export const getUnionGuard = (object) => {
|
|
|
8
9
|
const set = new Set(unionToArray(object));
|
|
9
10
|
return (value) => set.has(value);
|
|
10
11
|
};
|
|
12
|
+
export const deriveUnion = (object) => {
|
|
13
|
+
const array = Dict.keys(object);
|
|
14
|
+
const set = new Set(array);
|
|
15
|
+
const is = (value) => set.has(value);
|
|
16
|
+
return { array, set, is, P: P.when(is) };
|
|
17
|
+
};
|
|
11
18
|
export const memoize = (func, getCacheKey) => {
|
|
12
19
|
const cache = new Map();
|
|
13
20
|
return (...input) => {
|