@homecode/ui 4.28.3 → 4.28.5
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.
|
@@ -494,7 +494,7 @@ class Select extends Component {
|
|
|
494
494
|
renderTriggerArrow() {
|
|
495
495
|
const { size, inputProps, disableTriggerArrow } = this.props;
|
|
496
496
|
const { isOpen, searchVal } = this.store;
|
|
497
|
-
if (disableTriggerArrow
|
|
497
|
+
if (disableTriggerArrow || (inputProps?.hasClear && searchVal))
|
|
498
498
|
return null;
|
|
499
499
|
return (jsx(Icon, { type: "chevronDown", className: cn(S.triggerArrow, isOpen && S.isOpen), size: size }));
|
|
500
500
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { useRef, useState, useMemo, useEffect, useCallback, createElement } from 'react';
|
|
1
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
3
|
import { mapById, isMultiple, renderLabel } from './Select.helpers.js';
|
|
3
|
-
import { useRef, useState, useMemo, useEffect, useCallback } from 'react';
|
|
4
4
|
import { INTERACTION_MODE, getInteractionMode } from '../../tools/dom.js';
|
|
5
5
|
import cn from 'classnames';
|
|
6
6
|
import omit from 'lodash.omit';
|
|
@@ -17,7 +17,7 @@ import useEvent from '../../hooks/useEvent.js';
|
|
|
17
17
|
import S from './Select.styl.js';
|
|
18
18
|
|
|
19
19
|
function Select2(props) {
|
|
20
|
-
const { className, value, onChange, onSearchChange, disableTriggerArrow, inputProps, popupProps, size = 'm', round, optionClassName, additionalOptions = [], options, variant, label, error, blur, disabled, trigger, required, hideRequiredStar, isSearchable, presets = [], selectAllButton, clearButton, showSelectedCount, disableLabel, } = props;
|
|
20
|
+
const { className, value, onChange, onSearchChange, disableTriggerArrow, inputProps, popupProps, scrollProps, size = 'm', round, optionClassName, additionalOptions = [], options, variant, label, error, blur, disabled, trigger, required, hideRequiredStar, isSearchable, presets = [], selectAllButton, clearButton, showSelectedCount, disableLabel, } = props;
|
|
21
21
|
const isMultiple$1 = isMultiple(value);
|
|
22
22
|
const closeOnSelect = props.closeOnSelect ?? !isMultiple$1;
|
|
23
23
|
const contentRef = useRef(null);
|
|
@@ -174,7 +174,7 @@ function Select2(props) {
|
|
|
174
174
|
}, [isMultiple$1, value, ids]);
|
|
175
175
|
// console.log('selectedLabel::', selectedLabel);
|
|
176
176
|
const triggerArrow = useMemo(() => {
|
|
177
|
-
if (disableTriggerArrow
|
|
177
|
+
if (disableTriggerArrow || (inputProps?.hasClear && searchVal))
|
|
178
178
|
return null;
|
|
179
179
|
return (jsx(Icon, { type: "chevronDown", className: cn(S.triggerArrow, isOpen && S.isOpen), size: size }));
|
|
180
180
|
}, [isOpen, searchVal]);
|
|
@@ -300,7 +300,7 @@ function Select2(props) {
|
|
|
300
300
|
}
|
|
301
301
|
},
|
|
302
302
|
});
|
|
303
|
-
const optionsList = useMemo(() => (jsxs("div", { ref: contentRef, children: [renderPresets(),
|
|
303
|
+
const optionsList = useMemo(() => (jsxs("div", { ref: contentRef, children: [renderPresets(), createElement(Scroll, { y: true, ...scrollProps, offset: { y: { before: 10, after: 10 } }, className: cn(S.options, S[`size-${size}`], scrollProps?.className), onInnerRef: elem => (scrollInnerRef.current = elem), key: "items-scroll" }, renderOptions())] })), [items, searchVal, focusedItemIndex]);
|
|
304
304
|
const classes = cn(S.root, className, S[`size-${size}`]);
|
|
305
305
|
return (jsxs(Fragment, { children: [jsx(Popup, { className: classes, direction: "bottom", size: size, focusControl: true, hoverControl: isFocused, blur: blur, isOpen: isOpen, disabled: disabled, ...popupProps, onOpen: onPopupOpen, onClose: onPopupClose, trigger: renderTrigger(), triggerProps: {
|
|
306
306
|
onFocus: onFocus,
|
|
@@ -2,6 +2,7 @@ import { RefObject, ReactNode, HTMLAttributes } from 'react';
|
|
|
2
2
|
import type { FormControl, Size } from 'uilib/types';
|
|
3
3
|
import { InputProps } from '../Input/Input';
|
|
4
4
|
import { PopupProps } from '../Popup/Popup';
|
|
5
|
+
import { ScrollProps } from 'uilib/components/Scroll/Scroll';
|
|
5
6
|
export type Id = string | number;
|
|
6
7
|
export type Option = {
|
|
7
8
|
id: Id;
|
|
@@ -53,6 +54,7 @@ export type Props = FormControl<Value> & InheritedInputProps & {
|
|
|
53
54
|
onClose?: () => void;
|
|
54
55
|
isSearchable?: boolean;
|
|
55
56
|
inputProps?: Omit<InputProps, 'value' | 'onChange' | 'onFocus' | 'onBlur' | 'size'>;
|
|
57
|
+
scrollProps?: Partial<ScrollProps>;
|
|
56
58
|
round?: boolean;
|
|
57
59
|
trigger?: ReactNode;
|
|
58
60
|
triggerProps?: any;
|