@bitrise/bitkit 10.9.1 → 10.9.2
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 +1 -1
- package/src/Components/Dropdown/Dropdown.context.tsx +14 -9
- package/src/Components/Dropdown/Dropdown.stories.tsx +21 -0
- package/src/Components/Dropdown/Dropdown.test.tsx +121 -29
- package/src/Components/Dropdown/Dropdown.theme.ts +2 -1
- package/src/Components/Dropdown/Dropdown.tsx +92 -53
- package/src/Components/Dropdown/DropdownButton.tsx +3 -1
- package/src/Components/Dropdown/DropdownOption.tsx +18 -12
- package/src/Components/Dropdown/hooks/useFloatingDropdown.ts +11 -4
- package/src/Components/Dropdown/hooks/useSimpleSearch.tsx +2 -11
- package/src/Components/Input/Input.theme.ts +1 -0
- package/src/tsconfig.tsbuildinfo +1 -1
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useListNavigation,
|
|
9
9
|
useRole,
|
|
10
10
|
useDismiss,
|
|
11
|
+
flip,
|
|
11
12
|
} from '@floating-ui/react-dom-interactions';
|
|
12
13
|
import useAutoScroll from './useAutoScroll';
|
|
13
14
|
|
|
@@ -40,13 +41,15 @@ const useFloatingDropdown = ({ enabled, optionsRef }: { enabled: boolean; option
|
|
|
40
41
|
},
|
|
41
42
|
middleware: [
|
|
42
43
|
size({
|
|
44
|
+
padding: 5,
|
|
43
45
|
apply({ elements, availableHeight, rects }) {
|
|
44
46
|
Object.assign(elements.floating.style, {
|
|
45
47
|
width: `${rects.reference.width}px`,
|
|
46
48
|
});
|
|
47
|
-
elements.floating.style.setProperty('--floating-available-height', `${availableHeight
|
|
49
|
+
elements.floating.style.setProperty('--floating-available-height', `${availableHeight}px`);
|
|
48
50
|
},
|
|
49
51
|
}),
|
|
52
|
+
flip(),
|
|
50
53
|
],
|
|
51
54
|
});
|
|
52
55
|
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
|
|
@@ -62,6 +65,9 @@ const useFloatingDropdown = ({ enabled, optionsRef }: { enabled: boolean; option
|
|
|
62
65
|
loop: true,
|
|
63
66
|
onNavigate: setActiveIndex,
|
|
64
67
|
}),
|
|
68
|
+
{
|
|
69
|
+
floating: keyboardControlledHandlers,
|
|
70
|
+
},
|
|
65
71
|
]);
|
|
66
72
|
useAutoScroll({
|
|
67
73
|
listRef,
|
|
@@ -73,17 +79,18 @@ const useFloatingDropdown = ({ enabled, optionsRef }: { enabled: boolean; option
|
|
|
73
79
|
|
|
74
80
|
return {
|
|
75
81
|
listRef,
|
|
76
|
-
|
|
82
|
+
close: () => setOpen(false),
|
|
77
83
|
isOpen,
|
|
78
84
|
getItemProps,
|
|
79
85
|
activeIndex,
|
|
80
86
|
setActiveIndex,
|
|
81
87
|
setSelectedIndex,
|
|
82
|
-
|
|
88
|
+
getReferenceProps(props: React.HTMLProps<Element>) {
|
|
89
|
+
return getReferenceProps({ ...props, ref: reference });
|
|
90
|
+
},
|
|
83
91
|
floatingProps: getFloatingProps({
|
|
84
92
|
ref: floating,
|
|
85
93
|
style: { position: strategy, top: y ?? 0, left: x ?? 0 },
|
|
86
|
-
...keyboardControlledHandlers,
|
|
87
94
|
}),
|
|
88
95
|
context,
|
|
89
96
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children, cloneElement, isValidElement, ReactNode,
|
|
1
|
+
import { Children, cloneElement, isValidElement, ReactNode, useMemo, useState } from 'react';
|
|
2
2
|
import { chakra } from '@chakra-ui/react';
|
|
3
3
|
import { useDropdownStyles } from '../Dropdown.context';
|
|
4
4
|
import isNodeMatch from '../isNodeMatch';
|
|
@@ -8,15 +8,7 @@ const NoResultsFound = ({ children }: { children: ReactNode }) => {
|
|
|
8
8
|
const { item } = useDropdownStyles();
|
|
9
9
|
return <chakra.div __css={item}>{children}</chakra.div>;
|
|
10
10
|
};
|
|
11
|
-
function useSimpleSearch({
|
|
12
|
-
children,
|
|
13
|
-
onSearch,
|
|
14
|
-
isOpen,
|
|
15
|
-
}: {
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
onSearch?: () => void;
|
|
18
|
-
isOpen: boolean;
|
|
19
|
-
}) {
|
|
11
|
+
function useSimpleSearch({ children, onSearch }: { children?: ReactNode; onSearch?: () => void }) {
|
|
20
12
|
const [searchValue, setSearchValue] = useState('');
|
|
21
13
|
const searchOnChange = (newValue: string) => {
|
|
22
14
|
setSearchValue(newValue);
|
|
@@ -45,7 +37,6 @@ function useSimpleSearch({
|
|
|
45
37
|
|
|
46
38
|
return results.length ? results : <NoResultsFound>No results found for `{searchValue}`</NoResultsFound>;
|
|
47
39
|
}, [children, searchValue]);
|
|
48
|
-
useEffect(() => setSearchValue(''), [isOpen]);
|
|
49
40
|
|
|
50
41
|
return { children: options, searchValue, searchOnChange };
|
|
51
42
|
}
|