x-ui-design 0.4.47 → 0.4.49
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 +18 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +21 -33
- package/package.json +1 -1
- package/src/app/page.tsx +4 -2
package/dist/index.esm.js
CHANGED
|
@@ -3264,25 +3264,26 @@ 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
|
+
};
|
|
3267
3278
|
useEffect(() => {
|
|
3268
3279
|
setSelected(hasMode ? checkModeInitialValue : initialValue);
|
|
3269
3280
|
}, [checkModeInitialValue, hasMode, initialValue]);
|
|
3270
3281
|
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
|
-
};
|
|
3281
3282
|
document.addEventListener('mousedown', handleClickOutside);
|
|
3282
3283
|
return () => {
|
|
3283
3284
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
3284
3285
|
};
|
|
3285
|
-
}, [
|
|
3286
|
+
}, [handleClickOutside]);
|
|
3286
3287
|
const updateDropdownPosition = useCallback(searchQueryUpdated => {
|
|
3287
3288
|
if (!selectRef.current) {
|
|
3288
3289
|
return;
|
|
@@ -3324,8 +3325,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3324
3325
|
setDropdownPosition({});
|
|
3325
3326
|
setSearchFocused(false);
|
|
3326
3327
|
}
|
|
3327
|
-
}, [isOpen]);
|
|
3328
|
-
useEffect(() => {}, []);
|
|
3328
|
+
}, [isOpen, onDropdownVisibleChange]);
|
|
3329
3329
|
useEffect(() => {
|
|
3330
3330
|
if (!isOpen) return;
|
|
3331
3331
|
const _updateDropdownPosition = () => updateDropdownPosition();
|
|
@@ -3397,7 +3397,6 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3397
3397
|
const newSelection = selected.includes(optionValue) ? selected.filter(item => item !== optionValue) : [...selected, optionValue];
|
|
3398
3398
|
setSelected(newSelection);
|
|
3399
3399
|
onChange?.(newSelection, option);
|
|
3400
|
-
onSelect?.(newSelection, option);
|
|
3401
3400
|
if (selected.includes(optionValue)) {
|
|
3402
3401
|
onDeselect?.(optionValue, option);
|
|
3403
3402
|
} else {
|
|
@@ -3445,10 +3444,11 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3445
3444
|
}
|
|
3446
3445
|
if (e.key === 'Backspace') {
|
|
3447
3446
|
if (hasMode && !e.target.value.trim().length) {
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3447
|
+
handleRemoveTag({
|
|
3448
|
+
target: {
|
|
3449
|
+
value: selected[selected.length - 1]
|
|
3450
|
+
}
|
|
3451
|
+
});
|
|
3452
3452
|
}
|
|
3453
3453
|
}
|
|
3454
3454
|
clearTimeout(timeout);
|