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