x-ui-design 0.7.21 → 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/index.js CHANGED
@@ -3560,7 +3560,7 @@ const Select = ({
3560
3560
  }
3561
3561
  }, [autoClearSearchValue, prefixCls, prefixClsV3]);
3562
3562
  React.useEffect(() => {
3563
- setSelected(hasMode ? checkModeInitialValue : initialValue);
3563
+ !controlled && setSelected(hasMode ? checkModeInitialValue : initialValue);
3564
3564
  }, [checkModeInitialValue, hasMode, initialValue]);
3565
3565
  const handleClickOutside = React.useCallback(event => {
3566
3566
  if (!selectRef.current) return;
@@ -3686,12 +3686,12 @@ const Select = ({
3686
3686
  }
3687
3687
  const updatedSelected = [...selected, newOptionValue];
3688
3688
  onChange?.(updatedSelected);
3689
- onSelect?.(updatedSelected);
3689
+ !controlled && onSelect?.(updatedSelected);
3690
3690
  const input = selectRef.current?.querySelector('input');
3691
3691
  if (input) {
3692
3692
  input.value = '';
3693
3693
  }
3694
- setSelected(updatedSelected);
3694
+ !controlled && setSelected(updatedSelected);
3695
3695
  handleClearInputValue();
3696
3696
  };
3697
3697
  const handleSelect = (e, optionValue, option) => {
@@ -3749,10 +3749,10 @@ const Select = ({
3749
3749
  if (hasMode && !e.target.value.trim().length) {
3750
3750
  const updatedSelected = hasMode ? selected.filter(item => item !== selected[selected.length - 1]) : e.target.value.trim();
3751
3751
  if (selected[selected.length - 1]) {
3752
- onDeselect?.(selected[selected.length - 1]);
3752
+ !controlled && onDeselect?.(selected[selected.length - 1]);
3753
3753
  }
3754
3754
  onChange?.(updatedSelected);
3755
- setSelected(updatedSelected);
3755
+ !controlled && setSelected(updatedSelected);
3756
3756
  setSearchFocused(false);
3757
3757
  }
3758
3758
  }