@homecode/ui 4.30.12 → 4.30.14
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.
|
@@ -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, selectedChipClassName, 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);
|
|
@@ -180,7 +183,7 @@ function Select2(props) {
|
|
|
180
183
|
const label = getLabel(id);
|
|
181
184
|
if (!label)
|
|
182
185
|
return null;
|
|
183
|
-
return (jsx(Chip, { className: S.chip, size: size, selected: selectedChipIds?.includes(id), onRemove: () => onItemToggle(id), onClick: () => onChipClick?.(id), removeTooltip: selectedChipRemoveTooltip, children: label }, id));
|
|
186
|
+
return (jsx(Chip, { className: cn(S.chip, selectedChipIds?.includes(id) && selectedChipClassName, ids.items[id]?.chipClassName), size: size, selected: selectedChipIds?.includes(id), onRemove: () => onItemToggle(id), onClick: () => onChipClick?.(id), removeTooltip: selectedChipRemoveTooltip, children: label }, id));
|
|
184
187
|
});
|
|
185
188
|
};
|
|
186
189
|
const triggerArrow = useMemo(() => {
|
|
@@ -12,6 +12,8 @@ export type Option = {
|
|
|
12
12
|
sortingKey?: string | number;
|
|
13
13
|
children?: Option[];
|
|
14
14
|
render?: (label: string) => string;
|
|
15
|
+
/** Applied to the selected chip in multi-select mode */
|
|
16
|
+
chipClassName?: string;
|
|
15
17
|
};
|
|
16
18
|
type Preset = {
|
|
17
19
|
label: string;
|
|
@@ -24,7 +26,7 @@ export type PresetButtonProps = {
|
|
|
24
26
|
};
|
|
25
27
|
type SelectPopupProps = Omit<PopupProps, 'disabled' | 'direction' | 'autoClose' | 'onOpen' | 'onClose' | 'trigger' | 'content'> & Partial<{
|
|
26
28
|
direction: PopupProps['direction'];
|
|
27
|
-
}
|
|
29
|
+
}> & Partial<Pick<PopupProps, 'onOpen' | 'onClose'>>;
|
|
28
30
|
type Selected = Record<string, true | Id[]>;
|
|
29
31
|
export type Value = Id | Id[] | null;
|
|
30
32
|
type InheritedInputProps = Partial<Pick<InputProps, 'onFocus' | 'onBlur'>>;
|
|
@@ -34,6 +36,7 @@ export type Props = FormControl<Value> & InheritedInputProps & {
|
|
|
34
36
|
closeOnSelect?: boolean;
|
|
35
37
|
optionsClassName?: string;
|
|
36
38
|
optionClassName?: string;
|
|
39
|
+
selectedChipClassName?: string;
|
|
37
40
|
additionalLabel?: ReactNode;
|
|
38
41
|
size?: Size;
|
|
39
42
|
variant?: 'default' | 'outlined';
|