x-ui-design 0.5.56 → 0.5.57

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
@@ -3347,6 +3347,7 @@ const SelectComponent = ({
3347
3347
  const dropdown = document.querySelector(`.${prefixCls}-dropdown`);
3348
3348
  const clickedInside = selectRef.current.contains(event?.target) || dropdown && dropdown.contains(event?.target);
3349
3349
  if (!clickedInside) {
3350
+ setSearchFocused(false);
3350
3351
  setIsOpen(false);
3351
3352
  handleClearInputValue();
3352
3353
  onClose?.();
@@ -3398,8 +3399,13 @@ const SelectComponent = ({
3398
3399
  if (!isOpen) {
3399
3400
  setDropdownPosition({});
3400
3401
  setSearchFocused(false);
3402
+ } else {
3403
+ if (showSearch) {
3404
+ setSearchFocused(true);
3405
+ searchInputRef.current?.focus();
3406
+ }
3401
3407
  }
3402
- }, [isOpen]);
3408
+ }, [isOpen, showSearch]);
3403
3409
  useEffect(() => {
3404
3410
  if (!open && isOpen && closeFromParent) {
3405
3411
  handleClickOutside();
@@ -3499,11 +3505,13 @@ const SelectComponent = ({
3499
3505
  };
3500
3506
  const handleRemoveTag = e => handleSelect(e, e.target.value);
3501
3507
  const handleOnKeyDown = e => {
3502
- if (!isOpen) {
3508
+ if (!isOpen || e.which === 13) {
3509
+ e.stopPropagation();
3510
+ e.preventDefault();
3503
3511
  return;
3504
3512
  }
3505
3513
  const timeout = setTimeout(() => {
3506
- e.target.value = (searchInputRef.current?.innerText || e.target.innerText).replace('\n', '');
3514
+ e.target.value = searchInputRef.current?.innerText || e.target.innerText;
3507
3515
  setSearchQuery(e.target.value);
3508
3516
  onSearch?.(e.target.value);
3509
3517
  if (e.key === 'Enter' && searchQuery.trim() !== '') {
@@ -3588,14 +3596,6 @@ const SelectComponent = ({
3588
3596
  if (searchContent) {
3589
3597
  setSearchInputWidth(searchContent.clientWidth - PADDING_TAG_INPUT);
3590
3598
  }
3591
- const timeout = setTimeout(() => {
3592
- const searchInput = document.getElementById(`${prefixCls}-search-tag-input`);
3593
- if (searchInput) {
3594
- searchInput?.focus();
3595
- setSearchFocused(true);
3596
- }
3597
- clearTimeout(timeout);
3598
- }, 0);
3599
3599
  };
3600
3600
  const dataRender = (() => {
3601
3601
  const options = filteredOptions.map(({
@@ -3778,21 +3778,20 @@ const SelectComponent = ({
3778
3778
  style: {
3779
3779
  minWidth: showSearch && !searchQuery.length ? 1 : 'auto',
3780
3780
  display: 'ruby',
3781
- textAlign: 'center'
3781
+ textAlign: 'center',
3782
+ opacity: searchFocused ? 1 : 0
3782
3783
  }
3783
3784
  }, showSearch ? {
3784
3785
  contentEditable: true
3785
3786
  } : {}, {
3786
3787
  id: `${prefixCls}-search-tag-input`,
3787
3788
  className: `${prefixCls}-tag-input`
3788
- })), !hasMode && !searchQuery.length ? selected === '' ? placeholder : selectedOption : null) : !hasMode ? /*#__PURE__*/React.createElement("div", _extends({
3789
+ })), !hasMode && !searchQuery.length ? selected === '' ? placeholder : selectedOption : null) : !hasMode ? /*#__PURE__*/React.createElement("div", {
3789
3790
  className: `${prefixCls}-input globalEllipsis`,
3790
3791
  style: {
3791
3792
  opacity: isOpen ? '0.6' : '1'
3792
3793
  }
3793
- }, showSearch ? {
3794
- contentEditable: true
3795
- } : {}), selected === '' ? placeholder : selectedOption) : null) : !hasMode ? /*#__PURE__*/React.createElement("div", {
3794
+ }, selected === '' ? placeholder : selectedOption) : null) : !hasMode ? /*#__PURE__*/React.createElement("div", {
3796
3795
  className: `${prefixCls}-input globalEllipsis`,
3797
3796
  onClick: () => !disabled && setIsOpen(!isOpen || defaultOpen),
3798
3797
  style: {