x-ui-design 0.6.100 → 0.7.22
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.
- package/dist/esm/types/components/Select/Select.d.ts +1 -1
- package/dist/esm/types/types/select.d.ts +1 -0
- package/dist/index.esm.js +14 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +14 -13
- package/lib/types/select.ts +2 -1
- package/package.json +1 -1
- package/src/app/page.tsx +33 -12
|
@@ -2,7 +2,7 @@ import { ReactElement } from 'react';
|
|
|
2
2
|
import { SelectProps } from '../../types/select';
|
|
3
3
|
import './style.css';
|
|
4
4
|
declare const Select: {
|
|
5
|
-
({ prefixCls, prefixClsV3, id, searchValue, autoClearSearchValue, filterOption, optionFilterProp, children, options, listHeight, menuItemSelectedIcon, mode, value, defaultValue, maxCount, disabled, loading, placeholder, allowClear, filterable, defaultOpen, size, error, dropdownClassName, className, suffixIcon, searchIcon, style, showSearch, open, closeFromParent, showArrow, notFoundContent, noStyle, feedbackIcons, placement, removeIcon, maxTagCount, iconClickClear, onSearch, onSelect, onDeselect, onClear, onChange, onClose, tagRender, getPopupContainer, dropdownRender, onDropdownVisibleChange, iconClick, ref }: SelectProps): ReactElement;
|
|
5
|
+
({ prefixCls, prefixClsV3, id, searchValue, autoClearSearchValue, filterOption, optionFilterProp, children, options, listHeight, menuItemSelectedIcon, mode, value, defaultValue, maxCount, disabled, loading, placeholder, allowClear, filterable, defaultOpen, size, error, dropdownClassName, className, suffixIcon, searchIcon, style, showSearch, open, closeFromParent, showArrow, notFoundContent, noStyle, feedbackIcons, placement, removeIcon, maxTagCount, iconClickClear, onSearch, onSelect, onDeselect, onClear, onChange, onClose, tagRender, getPopupContainer, dropdownRender, onDropdownVisibleChange, iconClick, ref, controlled }: SelectProps): ReactElement;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
8
|
export default Select;
|
package/dist/index.esm.js
CHANGED
|
@@ -3507,7 +3507,8 @@ const Select = ({
|
|
|
3507
3507
|
dropdownRender,
|
|
3508
3508
|
onDropdownVisibleChange,
|
|
3509
3509
|
iconClick,
|
|
3510
|
-
ref
|
|
3510
|
+
ref,
|
|
3511
|
+
controlled
|
|
3511
3512
|
}) => {
|
|
3512
3513
|
const asTag = mode === 'tags';
|
|
3513
3514
|
const asMultiple = mode === 'multiple';
|
|
@@ -3557,7 +3558,7 @@ const Select = ({
|
|
|
3557
3558
|
}
|
|
3558
3559
|
}, [autoClearSearchValue, prefixCls, prefixClsV3]);
|
|
3559
3560
|
useEffect(() => {
|
|
3560
|
-
setSelected(hasMode ? checkModeInitialValue : initialValue);
|
|
3561
|
+
!controlled && setSelected(hasMode ? checkModeInitialValue : initialValue);
|
|
3561
3562
|
}, [checkModeInitialValue, hasMode, initialValue]);
|
|
3562
3563
|
const handleClickOutside = useCallback(event => {
|
|
3563
3564
|
if (!selectRef.current) return;
|
|
@@ -3683,12 +3684,12 @@ const Select = ({
|
|
|
3683
3684
|
}
|
|
3684
3685
|
const updatedSelected = [...selected, newOptionValue];
|
|
3685
3686
|
onChange?.(updatedSelected);
|
|
3686
|
-
onSelect?.(updatedSelected);
|
|
3687
|
+
!controlled && onSelect?.(updatedSelected);
|
|
3687
3688
|
const input = selectRef.current?.querySelector('input');
|
|
3688
3689
|
if (input) {
|
|
3689
3690
|
input.value = '';
|
|
3690
3691
|
}
|
|
3691
|
-
setSelected(updatedSelected);
|
|
3692
|
+
!controlled && setSelected(updatedSelected);
|
|
3692
3693
|
handleClearInputValue();
|
|
3693
3694
|
};
|
|
3694
3695
|
const handleSelect = (e, optionValue, option) => {
|
|
@@ -3697,26 +3698,26 @@ const Select = ({
|
|
|
3697
3698
|
return;
|
|
3698
3699
|
}
|
|
3699
3700
|
const newSelection = selected.includes(optionValue) ? selected.filter(item => item !== optionValue) : [...selected, optionValue];
|
|
3700
|
-
setSelected(newSelection);
|
|
3701
|
+
!controlled && setSelected(newSelection);
|
|
3701
3702
|
onChange?.(newSelection, option);
|
|
3702
3703
|
if (selected.includes(optionValue)) {
|
|
3703
|
-
onDeselect?.(optionValue, option);
|
|
3704
|
+
!controlled && onDeselect?.(optionValue, option);
|
|
3704
3705
|
} else {
|
|
3705
|
-
onSelect?.(optionValue, option);
|
|
3706
|
+
!controlled && onSelect?.(optionValue, option);
|
|
3706
3707
|
}
|
|
3707
3708
|
} else {
|
|
3708
3709
|
setIsOpen(defaultOpen);
|
|
3709
|
-
setSelected(optionValue);
|
|
3710
|
+
!controlled && setSelected(optionValue);
|
|
3710
3711
|
onChange?.(optionValue, option);
|
|
3711
|
-
onSelect?.(optionValue, option);
|
|
3712
|
+
!controlled && onSelect?.(optionValue, option);
|
|
3712
3713
|
}
|
|
3713
3714
|
handleClearInputValue();
|
|
3714
3715
|
};
|
|
3715
3716
|
const handleClear = () => {
|
|
3716
3717
|
const value = hasMode ? [] : '';
|
|
3717
|
-
setSelected(value);
|
|
3718
|
+
!controlled && setSelected(value);
|
|
3718
3719
|
onChange?.('');
|
|
3719
|
-
onSelect?.('');
|
|
3720
|
+
!controlled && onSelect?.('');
|
|
3720
3721
|
onClear?.();
|
|
3721
3722
|
handleClearInputValue();
|
|
3722
3723
|
};
|
|
@@ -3746,10 +3747,10 @@ const Select = ({
|
|
|
3746
3747
|
if (hasMode && !e.target.value.trim().length) {
|
|
3747
3748
|
const updatedSelected = hasMode ? selected.filter(item => item !== selected[selected.length - 1]) : e.target.value.trim();
|
|
3748
3749
|
if (selected[selected.length - 1]) {
|
|
3749
|
-
onDeselect?.(selected[selected.length - 1]);
|
|
3750
|
+
!controlled && onDeselect?.(selected[selected.length - 1]);
|
|
3750
3751
|
}
|
|
3751
3752
|
onChange?.(updatedSelected);
|
|
3752
|
-
setSelected(updatedSelected);
|
|
3753
|
+
!controlled && setSelected(updatedSelected);
|
|
3753
3754
|
setSearchFocused(false);
|
|
3754
3755
|
}
|
|
3755
3756
|
}
|