x-ui-design 0.4.50 → 0.4.52

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
@@ -3264,26 +3264,25 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3264
3264
  inputContainer.innerText = '';
3265
3265
  }
3266
3266
  }, [autoClearSearchValue, prefixCls]);
3267
- // eslint-disable-next-line react-hooks/exhaustive-deps
3268
- const handleClickOutside = event => {
3269
- if (!selectRef.current) return;
3270
- const dropdown = document.querySelector(`.${prefixCls}-dropdown`);
3271
- const clickedInside = event?.target && (selectRef.current.contains(event.target) || dropdown && dropdown.contains(event.target));
3272
- if (!clickedInside) {
3273
- setIsOpen(false);
3274
- handleClearInputValue();
3275
- onClose?.();
3276
- }
3277
- };
3278
3267
  useEffect(() => {
3279
3268
  setSelected(hasMode ? checkModeInitialValue : initialValue);
3280
3269
  }, [checkModeInitialValue, hasMode, initialValue]);
3281
3270
  useEffect(() => {
3271
+ const handleClickOutside = event => {
3272
+ if (!selectRef.current) return;
3273
+ const dropdown = document.querySelector(`.${prefixCls}-dropdown`);
3274
+ const clickedInside = selectRef.current.contains(event.target) || dropdown && dropdown.contains(event.target);
3275
+ if (!clickedInside) {
3276
+ setIsOpen(false);
3277
+ handleClearInputValue();
3278
+ onClose?.();
3279
+ }
3280
+ };
3282
3281
  document.addEventListener('mousedown', handleClickOutside);
3283
3282
  return () => {
3284
3283
  document.removeEventListener('mousedown', handleClickOutside);
3285
3284
  };
3286
- }, [handleClickOutside]);
3285
+ }, [handleClearInputValue, defaultOpen, hasMode, prefixCls]);
3287
3286
  const updateDropdownPosition = useCallback(searchQueryUpdated => {
3288
3287
  if (!selectRef.current) {
3289
3288
  return;
@@ -3325,7 +3324,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3325
3324
  setDropdownPosition({});
3326
3325
  setSearchFocused(false);
3327
3326
  }
3328
- }, [isOpen, onDropdownVisibleChange]);
3327
+ }, [isOpen]);
3329
3328
  useEffect(() => {
3330
3329
  if (!isOpen) return;
3331
3330
  const _updateDropdownPosition = () => updateDropdownPosition();
@@ -3397,6 +3396,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3397
3396
  const newSelection = selected.includes(optionValue) ? selected.filter(item => item !== optionValue) : [...selected, optionValue];
3398
3397
  setSelected(newSelection);
3399
3398
  onChange?.(newSelection, option);
3399
+ // onSelect?.(newSelection, option);
3400
3400
  if (selected.includes(optionValue)) {
3401
3401
  onDeselect?.(optionValue, option);
3402
3402
  } else {
@@ -3445,8 +3445,8 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3445
3445
  if (e.key === 'Backspace') {
3446
3446
  if (hasMode && !e.target.value.trim().length) {
3447
3447
  const updatedSelected = hasMode ? selected.filter(item => item !== selected[selected.length - 1]) : e.target.value.trim();
3448
- onDeselect?.(e.target.value);
3449
3448
  onChange?.(updatedSelected);
3449
+ onSelect?.(updatedSelected);
3450
3450
  setSelected(updatedSelected);
3451
3451
  }
3452
3452
  }