@bitrise/bitkit 10.9.1 → 10.10.0-alpha-dropdown-release.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.
@@ -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 - 5}px`);
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
- onClose: () => setOpen(false),
82
+ close: () => setOpen(false),
77
83
  isOpen,
78
84
  getItemProps,
79
85
  activeIndex,
80
86
  setActiveIndex,
81
87
  setSelectedIndex,
82
- referenceProps: getReferenceProps({ ref: reference }),
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, useEffect, useMemo, useState } from 'react';
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
  }
@@ -6,6 +6,7 @@ const InputTheme = {
6
6
  height: '48',
7
7
  borderRadius: '4',
8
8
  borderStyle: 'solid',
9
+ borderColor: 'neutral.90',
9
10
  borderWidth: '1px',
10
11
  boxShadow: 'inner',
11
12
  _focusVisible: {
package/src/index.ts CHANGED
@@ -142,4 +142,14 @@ export { default as BreadcrumbLink } from './Components/Breadcrumb/BreadcrumbLin
142
142
  export type { RibbonProps } from './Components/Ribbon/Ribbon';
143
143
  export { default as Ribbon } from './Components/Ribbon/Ribbon';
144
144
 
145
+ export type { DropdownProps } from './Components/Dropdown/Dropdown';
146
+ export {
147
+ default as Dropdown,
148
+ DropdownOption,
149
+ DropdownGroup,
150
+ DropdownSearch,
151
+ NoResultsFound as DropdownNoResultsFound,
152
+ typedDropdown,
153
+ } from './Components/Dropdown/Dropdown';
154
+
145
155
  export { BREAKPOINTS } from './Foundations/Breakpoints/Breakpoints';
package/src/old.ts CHANGED
@@ -15,9 +15,6 @@ export { default as Base } from './Old/Base/Base';
15
15
  export type { Props as DatePickerProps } from './Old/DatePicker/DatePicker';
16
16
  export { default as DatePicker } from './Old/DatePicker/DatePicker';
17
17
 
18
- export type { Props as DropdownProps } from './Old/Dropdown/Dropdown';
19
- export { default as Dropdown } from './Old/Dropdown/Dropdown';
20
-
21
18
  export type { Props as DropdownMenuProps } from './Old/Dropdown/DropdownMenu';
22
19
  export { default as DropdownMenu } from './Old/Dropdown/DropdownMenu';
23
20