@swan-io/lake 1.9.1 → 2.0.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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/lake",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=14.0.0",
|
|
6
6
|
"yarn": "^1.20.0"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@popperjs/core": "^2.11.7",
|
|
30
|
-
"@swan-io/boxed": "^0.
|
|
30
|
+
"@swan-io/boxed": "^1.0.1",
|
|
31
31
|
"@swan-io/chicane": "^1.3.4",
|
|
32
32
|
"dayjs": "^1.11.7",
|
|
33
33
|
"polished": "^4.2.2",
|
|
@@ -37,7 +37,7 @@ export const ListRightPanelContent = ({ children, large, style, }) => {
|
|
|
37
37
|
const ListRightPanel_ = forwardRef(({ items, keyExtractor, activeId, onActiveIdChange, onClose, render, closeLabel, previousLabel, nextLabel, }, ref) => {
|
|
38
38
|
const activeItem = items.find(item => keyExtractor(item) === activeId);
|
|
39
39
|
// use `Array.getIndexBy` instead of `Array.findIndex` to avoid -1 value
|
|
40
|
-
const activeItemIndex = Array.
|
|
40
|
+
const activeItemIndex = Array.findIndex(items, item => keyExtractor(item) === activeId).toUndefined();
|
|
41
41
|
const previousId = usePreviousValue(activeId);
|
|
42
42
|
const previousItem = usePreviousValue(activeItem);
|
|
43
43
|
const previousIndex = usePreviousValue(activeItemIndex);
|
|
@@ -186,7 +186,7 @@ export const MultiSelect = memo(({ color = "gray", disabled = false, emptyResult
|
|
|
186
186
|
: remainingTags.filter(({ label }) => label.toLowerCase().includes(cleanedFilter));
|
|
187
187
|
}, [filter, items, values]);
|
|
188
188
|
const sections = useMemo(() => {
|
|
189
|
-
return Array.
|
|
189
|
+
return Array.filterMap(Dict.entries(groupBy(filteredItems, ({ group }) => group)), ([groupName, data]) => data === undefined ? Option.None() : Option.Some({ title: groupName, data }));
|
|
190
190
|
}, [filteredItems]);
|
|
191
191
|
const ListHeaderComponent = useMemo(() => (_jsxs(Box, { direction: "row", alignItems: "center", style: styles.filterContainer, children: [_jsx(PressableTextInput, { autoComplete: "off", inputMode: "search", multiline: false, rows: 1, onChangeText: filterValue => setFilter(filterValue), placeholder: filterPlaceholder, value: filter, style: ({ focused }) => [styles.filterInput, focused && styles.filterfocused] }), _jsx(Icon, { name: "search-filled", color: colors[color].primary, size: 20, style: styles.searchIcon })] })), [filter, filterPlaceholder, color]);
|
|
192
192
|
const ListEmptyComponent = useMemo(() => (_jsxs(Box, { justifyContent: "center", alignItems: "center", style: styles.emptyList, children: [_jsx(Icon, { name: "clipboard-search-regular", size: 24, color: colors.gray.primary }), isNotNullishOrEmpty(emptyResultText) && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 8 }), _jsx(Text, { style: styles.emptyListText, children: emptyResultText })] }))] })), [emptyResultText]);
|
|
@@ -12,14 +12,14 @@ export const TransitionGroupView = ({ children, enter, leave, style, childStyle
|
|
|
12
12
|
leavingKeysAndIndicesRef.current = leavingKeysAndIndicesRef.current.filter(leavingKey => leavingKey.key !== key);
|
|
13
13
|
forceUpdate();
|
|
14
14
|
};
|
|
15
|
-
const cleanedUpChildren = useMemo(() => Array.
|
|
15
|
+
const cleanedUpChildren = useMemo(() => Array.filterMap(Children.toArray(children), child => match(child)
|
|
16
16
|
.with({ key: P.string }, child => Option.Some({ key: child.key, child }))
|
|
17
17
|
.otherwise(() => Option.None())), [children]);
|
|
18
18
|
const previousChildren = usePreviousValue(cleanedUpChildren);
|
|
19
19
|
const newKeys = new Set(cleanedUpChildren.map(item => item.key));
|
|
20
20
|
leavingKeysAndIndicesRef.current = [
|
|
21
21
|
...leavingKeysAndIndicesRef.current,
|
|
22
|
-
...Array.
|
|
22
|
+
...Array.filterMap(previousChildren.map((item, index) => ({ item, index })), ({ item, index }) => newKeys.has(item.key) ||
|
|
23
23
|
leavingKeysAndIndicesRef.current.find(prev => prev.key === item.key)
|
|
24
24
|
? Option.None()
|
|
25
25
|
: Option.Some({ key: item.key, index })),
|
|
@@ -25,6 +25,6 @@ export const useUrqlMutation = (query) => {
|
|
|
25
25
|
}, [fetching, data, error]),
|
|
26
26
|
useCallback((input) => Future.fromPromise(execute(input))
|
|
27
27
|
.mapError(error => error) // Only used to cast error
|
|
28
|
-
.
|
|
28
|
+
.mapOkToResult(toResult), [execute]),
|
|
29
29
|
];
|
|
30
30
|
};
|