x-ui-design 0.4.13 → 0.4.15
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 +16 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +22 -12
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3179,7 +3179,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3179
3179
|
onChange,
|
|
3180
3180
|
onClose,
|
|
3181
3181
|
showSearch = false,
|
|
3182
|
-
open =
|
|
3182
|
+
open = true,
|
|
3183
3183
|
showArrow = true,
|
|
3184
3184
|
notFoundContent = false,
|
|
3185
3185
|
tagRender,
|
|
@@ -3198,7 +3198,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3198
3198
|
const [isHover, setIsHover] = useState(false);
|
|
3199
3199
|
const selectRef = useRef(null);
|
|
3200
3200
|
const [searchInputWidth, setSearchInputWidth] = useState(0);
|
|
3201
|
-
const [isOpen, setIsOpen] = useState(defaultOpen
|
|
3201
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
3202
3202
|
const [isOpenChecker, setIsOpenChecker] = useState(isOpen);
|
|
3203
3203
|
const [searchQuery, setSearchQuery] = useState(searchValue || '');
|
|
3204
3204
|
const [dropdownPosition, setDropdownPosition] = useState({});
|
|
@@ -3247,7 +3247,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3247
3247
|
return () => {
|
|
3248
3248
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
3249
3249
|
};
|
|
3250
|
-
}, [handleClearInputValue,
|
|
3250
|
+
}, [handleClearInputValue, defaultOpen, hasMode, prefixCls]);
|
|
3251
3251
|
const updateDropdownPosition = useCallback(searchQueryUpdated => {
|
|
3252
3252
|
if (!selectRef.current) {
|
|
3253
3253
|
return;
|
|
@@ -3329,7 +3329,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3329
3329
|
setSearchQuery(e.target.value);
|
|
3330
3330
|
onSearch?.(e.target.value);
|
|
3331
3331
|
if (!isOpen) {
|
|
3332
|
-
setIsOpen(!isOpen ||
|
|
3332
|
+
setIsOpen(!isOpen || defaultOpen);
|
|
3333
3333
|
handleClearInputValue();
|
|
3334
3334
|
}
|
|
3335
3335
|
};
|
|
@@ -3366,7 +3366,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3366
3366
|
onSelect?.(optionValue, option);
|
|
3367
3367
|
}
|
|
3368
3368
|
} else {
|
|
3369
|
-
setIsOpen(
|
|
3369
|
+
setIsOpen(defaultOpen);
|
|
3370
3370
|
setSelected(optionValue);
|
|
3371
3371
|
onChange?.(optionValue, option);
|
|
3372
3372
|
onSelect?.(optionValue, option);
|
|
@@ -3519,7 +3519,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3519
3519
|
});
|
|
3520
3520
|
return dropdownRender ? dropdownRender(options) : options;
|
|
3521
3521
|
})();
|
|
3522
|
-
const dropdownContent = !loading && isOpen && /*#__PURE__*/React.createElement("div", {
|
|
3522
|
+
const dropdownContent = !loading && open && isOpen && /*#__PURE__*/React.createElement("div", {
|
|
3523
3523
|
className: clsx([`${prefixCls}-dropdown`, {
|
|
3524
3524
|
[placement]: placement,
|
|
3525
3525
|
[dropdownClassName]: dropdownClassName
|
|
@@ -3535,7 +3535,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3535
3535
|
value: searchQuery,
|
|
3536
3536
|
onChange: handleSearch,
|
|
3537
3537
|
placeholder: "Search..."
|
|
3538
|
-
}), !loading &&
|
|
3538
|
+
}), !loading && /*#__PURE__*/React.createElement("div", {
|
|
3539
3539
|
className: `${prefixCls}-options`,
|
|
3540
3540
|
style: {
|
|
3541
3541
|
maxHeight: listHeight,
|
|
@@ -3584,14 +3584,20 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3584
3584
|
}, hasMode ? /*#__PURE__*/React.createElement(React.Fragment, null, selected.length ? selected.map((tag, index) => tagRender ? /*#__PURE__*/React.createElement("div", {
|
|
3585
3585
|
key: `${index}_${tag}`
|
|
3586
3586
|
}, tagRender?.({
|
|
3587
|
-
label:
|
|
3587
|
+
label: (() => {
|
|
3588
|
+
const option = extractedOptions.find(e => e.value === tag || e.label === tag || e.children === tag);
|
|
3589
|
+
return option?.children || option?.label || option?.value || null;
|
|
3590
|
+
})() || tag || null,
|
|
3588
3591
|
value: tag,
|
|
3589
3592
|
onClose: handleRemoveTag,
|
|
3590
3593
|
closable: true
|
|
3591
3594
|
})) : /*#__PURE__*/React.createElement(Tag, {
|
|
3592
3595
|
closable: true,
|
|
3593
3596
|
value: tag,
|
|
3594
|
-
label:
|
|
3597
|
+
label: (() => {
|
|
3598
|
+
const option = extractedOptions.find(e => e.value === tag || e.label === tag || e.children === tag);
|
|
3599
|
+
return option?.children || option?.label || option?.value || null;
|
|
3600
|
+
})() || tag || null,
|
|
3595
3601
|
onClose: handleRemoveTag,
|
|
3596
3602
|
key: `${index}_${tag}`
|
|
3597
3603
|
})) : /*#__PURE__*/React.createElement("span", {
|
|
@@ -3624,7 +3630,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3624
3630
|
}
|
|
3625
3631
|
}, selected === '' ? placeholder : selectedOption) : null) : !hasMode ? /*#__PURE__*/React.createElement("div", {
|
|
3626
3632
|
className: `${prefixCls}-input globalEllipsis`,
|
|
3627
|
-
onClick: () => !disabled && setIsOpen(!isOpen ||
|
|
3633
|
+
onClick: () => !disabled && setIsOpen(!isOpen || defaultOpen),
|
|
3628
3634
|
style: {
|
|
3629
3635
|
opacity: isOpen || selected === '' ? '0.6' : '1'
|
|
3630
3636
|
}
|