@homecode/ui 4.21.0 → 4.21.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.
@@ -89,10 +89,10 @@ function Autocomplete(props) {
89
89
  fetchOptions(val);
90
90
  return true;
91
91
  };
92
- const handleSelect = (value) => {
93
- setSearchValue(value);
92
+ const handleSelect = (option) => {
93
+ setSearchValue(option.label);
94
94
  setOptions([]);
95
- onSelect(value);
95
+ onSelect(option);
96
96
  // set input caret to the end
97
97
  requestAnimationFrame(() => {
98
98
  const input = inputRef.current;
@@ -105,9 +105,7 @@ function Autocomplete(props) {
105
105
  const { focusedIndex, setFocusedIndex } = useListKeyboardControl({
106
106
  isActive: isOpen,
107
107
  itemsCount: options.length,
108
- onSelect: index => {
109
- handleSelect(options[index].label);
110
- },
108
+ onSelect: index => handleSelect(options[index]),
111
109
  });
112
110
  const fetchOptions = debounce(async (inputValue) => {
113
111
  if (!inputValue) {
@@ -140,7 +138,7 @@ function Autocomplete(props) {
140
138
  const optionsList = useMemo(() => {
141
139
  if (!options.length)
142
140
  return null;
143
- return (jsx(Menu, { className: S.options, size: size, offset: { y: { before: 20, after: 20 } }, children: options.map((option, index) => (jsx(Menu.Item, { focused: focusedIndex === index, className: S.option, onClick: () => handleSelect(option.label), onMouseEnter: () => setFocusedIndex(index), children: option.label }, option.id))) }));
141
+ return (jsx(Menu, { className: S.options, size: size, offset: { y: { before: 20, after: 20 } }, children: options.map((option, index) => (jsx(Menu.Item, { focused: focusedIndex === index, className: S.option, onClick: () => handleSelect(option), onMouseEnter: () => setFocusedIndex(index), children: option.label }, option.id))) }));
144
142
  }, [options, focusedIndex]);
145
143
  return (jsx(Popup, { className: classes, isOpen: isOpen, focusControl: true, size: size, direction: "bottom", ...popupProps, trigger: jsxs("div", { className: inputWrapperClassName, children: [jsx(Input, { ref: inputRef,
146
144
  // @ts-ignore
@@ -12,7 +12,7 @@ export type Props = FormControl<Value, HTMLInputElement> & {
12
12
  size?: Size;
13
13
  value: Value;
14
14
  getOptions: (value: Value) => Promise<Option[]>;
15
- onSelect: (value: Value) => void;
15
+ onSelect: (option: Option) => void;
16
16
  debounceDelay?: number;
17
17
  inputProps?: Partial<InputProps>;
18
18
  popupProps?: Partial<PopupProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.21.0",
3
+ "version": "4.21.1",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",