@homecode/ui 4.30.11 → 4.30.13
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.
|
@@ -105,7 +105,7 @@ function Autocomplete(props) {
|
|
|
105
105
|
? filteredItems
|
|
106
106
|
: itemsWithoutFilter.length
|
|
107
107
|
? itemsWithoutFilter
|
|
108
|
-
: items ?? [];
|
|
108
|
+
: (items ?? []);
|
|
109
109
|
const displayCount = displayItems.length;
|
|
110
110
|
const hasMore = totalCount > 0 && displayCount < totalCount;
|
|
111
111
|
const classes = cn(S.root, className, popupProps.className);
|
|
@@ -272,6 +272,9 @@ function Autocomplete(props) {
|
|
|
272
272
|
if (typeof value !== 'string')
|
|
273
273
|
return;
|
|
274
274
|
setSearchValue(value);
|
|
275
|
+
if (selectable && value) {
|
|
276
|
+
setSelectedLabel(value);
|
|
277
|
+
}
|
|
275
278
|
if (!value) {
|
|
276
279
|
savedScrollTopRef.current = undefined;
|
|
277
280
|
setCurrentFilter('');
|
|
@@ -288,7 +291,7 @@ function Autocomplete(props) {
|
|
|
288
291
|
setScrollTop(0); // Reset scroll when filter changes
|
|
289
292
|
fetchOptions(value, 0);
|
|
290
293
|
}
|
|
291
|
-
}, [value]);
|
|
294
|
+
}, [value, selectable]);
|
|
292
295
|
useEffect(() => {
|
|
293
296
|
if (selectable && !value) {
|
|
294
297
|
setSelectedId(null);
|
|
@@ -18,7 +18,7 @@ import useEvent from '../../hooks/useEvent.js';
|
|
|
18
18
|
import S from './Select.styl.js';
|
|
19
19
|
|
|
20
20
|
function Select2(props) {
|
|
21
|
-
const { className, value, onChange, onChipClick, onSearchChange, disableTriggerArrow, inputProps, popupProps, scrollProps, size = 'm', round, optionClassName, additionalOptions = [], options, variant, label, additionalLabel, error, blur, disabled, trigger, required, hideRequiredStar, isSearchable, presets = [], selectAllButton, clearButton, showSelectedCount, disableLabel, selectedChipRemoveTooltip, selectedChipIds, } = props;
|
|
21
|
+
const { className, value, onChange, onChipClick, onSearchChange, disableTriggerArrow, inputProps, popupProps, scrollProps, size = 'm', round, optionClassName, additionalOptions = [], options, variant, label, additionalLabel, error, blur, disabled, trigger, required, hideRequiredStar, isSearchable, presets = [], selectAllButton, clearButton, showSelectedCount, disableLabel, selectedChipRemoveTooltip, selectedChipIds, onOpen, onClose, } = props;
|
|
22
22
|
const isMultiple$1 = isMultiple(value);
|
|
23
23
|
const closeOnSelect = props.closeOnSelect ?? !isMultiple$1;
|
|
24
24
|
const contentRef = useRef(null);
|
|
@@ -66,7 +66,6 @@ function Select2(props) {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
const setItemFocus = index => {
|
|
69
|
-
console.log('setItemFocus::', index);
|
|
70
69
|
focusedItemId.current = items[index]?.id;
|
|
71
70
|
setFocusedItemIndex(index);
|
|
72
71
|
};
|
|
@@ -108,12 +107,16 @@ function Select2(props) {
|
|
|
108
107
|
if (focusedItemIndex === -1) {
|
|
109
108
|
setItemFocus(0);
|
|
110
109
|
}
|
|
110
|
+
popupProps?.onOpen?.();
|
|
111
|
+
onOpen?.();
|
|
111
112
|
};
|
|
112
113
|
const onPopupClose = () => {
|
|
113
114
|
setIsOpen(false);
|
|
114
115
|
setSearchVal('');
|
|
115
116
|
setIsSearchActive(false);
|
|
116
117
|
setItemFocus(0);
|
|
118
|
+
popupProps?.onClose?.();
|
|
119
|
+
onClose?.();
|
|
117
120
|
};
|
|
118
121
|
const onFocus = () => {
|
|
119
122
|
setIsFocused(true);
|
|
@@ -24,7 +24,7 @@ export type PresetButtonProps = {
|
|
|
24
24
|
};
|
|
25
25
|
type SelectPopupProps = Omit<PopupProps, 'disabled' | 'direction' | 'autoClose' | 'onOpen' | 'onClose' | 'trigger' | 'content'> & Partial<{
|
|
26
26
|
direction: PopupProps['direction'];
|
|
27
|
-
}
|
|
27
|
+
}> & Partial<Pick<PopupProps, 'onOpen' | 'onClose'>>;
|
|
28
28
|
type Selected = Record<string, true | Id[]>;
|
|
29
29
|
export type Value = Id | Id[] | null;
|
|
30
30
|
type InheritedInputProps = Partial<Pick<InputProps, 'onFocus' | 'onBlur'>>;
|