x-ui-design 0.3.37 → 0.3.39
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 +32 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -27
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +42 -32
- package/lib/components/Select/style.css +0 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2920,7 +2920,7 @@ var Tag$1 = /*#__PURE__*/Object.freeze({
|
|
|
2920
2920
|
default: Tag
|
|
2921
2921
|
});
|
|
2922
2922
|
|
|
2923
|
-
var css_248z$5 = "@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.xUi-select{background-color:transparent;border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);box-sizing:border-box;color:var(--xui-text-color);display:inline-flex;flex-direction:row-reverse;min-height:24px;padding:2px 8px;position:relative;width:100%}.xUi-select-disabled{background:rgba(0,0,0,.04)}.xUi-select-arrow{align-items:center;color:var(--xui-text-color-light);display:flex;gap:6px;margin:0 4px}.xUi-select-arrow svg{align-items:center;display:flex;justify-content:center}.xUi-select-loading{animation:spin 1s linear infinite;color:var(--xui-text-color-light);display:inline-block;margin:0 8px}.xUi-select .xUi-select-trigger{align-items:center;background:transparent;border-radius:var(--xui-border-radius-sm);cursor:pointer;display:flex;justify-content:space-between;width:100%}.xUi-select .xUi-select-clear-btn{background:none;border:none;color:#999;cursor:pointer;font-size:var(--xui-font-size-lg);line-height:1;margin:0 8px;padding:0}.xUi-select .xUi-select-clear-btn:hover{color:var(--xui-primary-color)}.xUi-select-dropdown{background-color:var(--xui-select-background-color);border-radius:var(--xui-border-radius-sm);box-shadow:0 4px 12px rgba(0,0,0,.15);left:0;margin-top:5px;max-height:350px;
|
|
2923
|
+
var css_248z$5 = "@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.xUi-select{background-color:transparent;border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);box-sizing:border-box;color:var(--xui-text-color);display:inline-flex;flex-direction:row-reverse;min-height:24px;padding:2px 8px;position:relative;width:100%}.xUi-select-disabled{background:rgba(0,0,0,.04)}.xUi-select-arrow{align-items:center;color:var(--xui-text-color-light);display:flex;gap:6px;margin:0 4px}.xUi-select-arrow svg{align-items:center;display:flex;justify-content:center}.xUi-select-loading{animation:spin 1s linear infinite;color:var(--xui-text-color-light);display:inline-block;margin:0 8px}.xUi-select .xUi-select-trigger{align-items:center;background:transparent;border-radius:var(--xui-border-radius-sm);cursor:pointer;display:flex;justify-content:space-between;width:100%}.xUi-select .xUi-select-clear-btn{background:none;border:none;color:#999;cursor:pointer;font-size:var(--xui-font-size-lg);line-height:1;margin:0 8px;padding:0}.xUi-select .xUi-select-clear-btn:hover{color:var(--xui-primary-color)}.xUi-select-dropdown{background-color:var(--xui-select-background-color);border-radius:var(--xui-border-radius-sm);box-shadow:0 4px 12px rgba(0,0,0,.15);left:0;margin-top:5px;max-height:350px;overflow-y:auto;position:absolute;right:unset;top:100%;width:inherit;z-index:10}.xUi-select-dropdown.bottomRight,.xUi-select-dropdown.topRight{left:unset;right:0}.xUi-select .xUi-select-loading-spinner{color:#999;padding:10px;text-align:center}.xUi-select:focus-within{border-color:var(--xui-primary-color-light);box-shadow:none}.xUi-select:hover:not(.xUi-select-disabled){border-color:var(--xui-primary-color)}.xUi-select-disabled,.xUi-select-disabled .xUi-select-input,.xUi-select-disabled .xUi-select-trigger{cursor:not-allowed!important;opacity:.6!important}.xUi-select-selected-icon{color:var(--xui-primary-color-light)}.xUi-select-error{border-color:var(--xui-error-color)}.xUi-select-arrow .error-svg-icon,.xUi-select-error .error-svg-icon{color:var(--xui-error-color)}.xUi-select .xUi-select-input{align-items:center;background:transparent;border:none;color:var(--xui-text-color);cursor:pointer;display:inline-flex;font-size:var(--xui-font-size-md);height:-webkit-fill-available;outline:none;padding:0;user-select:none;width:100%}.xUi-select .xUi-select-input:focus{border:none;box-shadow:none;outline:none}.xUi-select.middle{border-radius:var(--xui-border-radius-md);min-height:30px}.xUi-select.middle,.xUi-select.middle input{font-size:var(--xui-font-size-md)}.xUi-select.middle .xUi-select-trigger{border-radius:var(--xui-border-radius-md)}.xUi-select.large{font-size:var(--xui-font-size-lg);min-height:40px}.xUi-select.large,.xUi-select.large .xUi-select-trigger{border-radius:var(--xui-border-radius-lg)}.xUi-select input{font-size:var(--xui-font-size-lg)}";
|
|
2924
2924
|
styleInject(css_248z$5);
|
|
2925
2925
|
|
|
2926
2926
|
const LIST_HEIGHT = 200;
|
|
@@ -3037,34 +3037,39 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3037
3037
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
3038
3038
|
};
|
|
3039
3039
|
}, [handleClearInputValue, open, hasMode, prefixCls]);
|
|
3040
|
-
const updateDropdownPosition = useCallback(
|
|
3041
|
-
if (!selectRef.current)
|
|
3040
|
+
const updateDropdownPosition = useCallback(searchQueryUpdated => {
|
|
3041
|
+
if (!selectRef.current) {
|
|
3042
|
+
return;
|
|
3043
|
+
}
|
|
3042
3044
|
const triggerNode = selectRef.current?.querySelector(`.${prefixCls}-trigger`);
|
|
3043
3045
|
const selectBox = triggerNode.getBoundingClientRect();
|
|
3044
3046
|
const dropdownHeight = (getPopupContainer ? getPopupContainer(triggerNode) : selectRef.current)?.querySelector(`.${prefixCls}-dropdown`)?.clientHeight || listHeight;
|
|
3045
|
-
const windowHeight =
|
|
3047
|
+
const windowHeight = window.innerHeight;
|
|
3046
3048
|
const spaceBelow = windowHeight - selectBox.bottom;
|
|
3047
3049
|
const spaceAbove = selectBox.top;
|
|
3048
3050
|
let positionStyle = {
|
|
3049
3051
|
width: `${triggerNode.offsetWidth + PADDING_PLACEMENT}px`,
|
|
3050
3052
|
position: 'absolute'
|
|
3051
3053
|
};
|
|
3052
|
-
const shouldShowAbove = spaceBelow
|
|
3054
|
+
const shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
3055
|
+
const shouldShowBelow = spaceAbove < dropdownHeight && spaceBelow > dropdownHeight;
|
|
3053
3056
|
const inForm = !!triggerNode.closest(`.${prefixClsForm}`) ? FORM_MARGIN_BOTTOM : 0;
|
|
3054
|
-
if (
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3057
|
+
if (shouldShowAbove || shouldShowBelow || searchQueryUpdated) {
|
|
3058
|
+
if (getPopupContainer) {
|
|
3059
|
+
positionStyle = {
|
|
3060
|
+
...positionStyle,
|
|
3061
|
+
top: shouldShowAbove ? `${selectBox.top + document.documentElement.scrollTop - dropdownHeight + PADDING_PLACEMENT / 2 - inForm}px` : `${selectBox.top + document.documentElement.scrollTop + triggerNode.offsetHeight}px`,
|
|
3062
|
+
left: `${selectBox.left - PADDING_PLACEMENT / 2}px`
|
|
3063
|
+
};
|
|
3064
|
+
} else {
|
|
3065
|
+
positionStyle = {
|
|
3066
|
+
...positionStyle,
|
|
3067
|
+
top: shouldShowAbove ? `${triggerNode.offsetTop - dropdownHeight + PADDING_PLACEMENT / 2 - inForm}px` : `${triggerNode.offsetTop + triggerNode.offsetHeight}px`,
|
|
3068
|
+
left: `${triggerNode.offsetLeft - PADDING_PLACEMENT / 2}px`
|
|
3069
|
+
};
|
|
3070
|
+
}
|
|
3071
|
+
setDropdownPosition(positionStyle);
|
|
3066
3072
|
}
|
|
3067
|
-
setDropdownPosition(positionStyle);
|
|
3068
3073
|
}, [prefixCls, listHeight, getPopupContainer]);
|
|
3069
3074
|
useEffect(() => {
|
|
3070
3075
|
if (!isOpen) {
|
|
@@ -3073,20 +3078,21 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3073
3078
|
}, [isOpen]);
|
|
3074
3079
|
useEffect(() => {
|
|
3075
3080
|
if (!isOpen) return;
|
|
3076
|
-
updateDropdownPosition();
|
|
3081
|
+
const _updateDropdownPosition = () => updateDropdownPosition();
|
|
3082
|
+
_updateDropdownPosition();
|
|
3077
3083
|
const controller = new AbortController();
|
|
3078
3084
|
const scrollableParents = getScrollParents(selectRef.current);
|
|
3079
3085
|
scrollableParents.forEach(el => {
|
|
3080
|
-
el.addEventListener('scroll',
|
|
3086
|
+
el.addEventListener('scroll', _updateDropdownPosition, {
|
|
3081
3087
|
passive: true,
|
|
3082
3088
|
signal: controller.signal
|
|
3083
3089
|
});
|
|
3084
3090
|
});
|
|
3085
|
-
window.addEventListener('scroll',
|
|
3091
|
+
window.addEventListener('scroll', _updateDropdownPosition, {
|
|
3086
3092
|
passive: true,
|
|
3087
3093
|
signal: controller.signal
|
|
3088
3094
|
});
|
|
3089
|
-
window.addEventListener('resize',
|
|
3095
|
+
window.addEventListener('resize', _updateDropdownPosition, {
|
|
3090
3096
|
signal: controller.signal
|
|
3091
3097
|
});
|
|
3092
3098
|
return () => {
|
|
@@ -3094,7 +3100,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3094
3100
|
};
|
|
3095
3101
|
}, [isOpen, getPopupContainer, updateDropdownPosition]);
|
|
3096
3102
|
useEffect(() => {
|
|
3097
|
-
updateDropdownPosition();
|
|
3103
|
+
updateDropdownPosition(true);
|
|
3098
3104
|
}, [searchQuery.length]);
|
|
3099
3105
|
const getScrollParents = element => {
|
|
3100
3106
|
const parents = [];
|
|
@@ -3298,8 +3304,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3298
3304
|
}]),
|
|
3299
3305
|
style: {
|
|
3300
3306
|
...dropdownPosition,
|
|
3301
|
-
maxHeight: listHeight
|
|
3302
|
-
opacity: Object.keys(dropdownPosition).length ? 1 : 0
|
|
3307
|
+
maxHeight: listHeight
|
|
3303
3308
|
}
|
|
3304
3309
|
}, filterable && /*#__PURE__*/React$1.createElement("input", {
|
|
3305
3310
|
type: "text",
|
|
@@ -3374,14 +3379,14 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3374
3379
|
},
|
|
3375
3380
|
onKeyDown: handleOnKeyDown,
|
|
3376
3381
|
style: {
|
|
3377
|
-
width: 'auto',
|
|
3382
|
+
width: showSearch && !searchQuery.length ? 0 : 'auto',
|
|
3378
3383
|
display: 'ruby',
|
|
3379
3384
|
textAlign: 'center'
|
|
3380
3385
|
},
|
|
3381
3386
|
contentEditable: "plaintext-only",
|
|
3382
3387
|
id: `${prefixCls}-search-tag-input`,
|
|
3383
3388
|
className: `${prefixCls}-tag-input`
|
|
3384
|
-
})) : !hasMode ? /*#__PURE__*/React$1.createElement("div", {
|
|
3389
|
+
}), !searchQuery.length ? selected === '' ? placeholder : extractedOptions.find(e => e.value === selected)?.children || selected : null) : !hasMode ? /*#__PURE__*/React$1.createElement("div", {
|
|
3385
3390
|
className: `${prefixCls}-input globalEllipsis`,
|
|
3386
3391
|
style: {
|
|
3387
3392
|
opacity: isOpen || selected === '' ? '0.6' : '1'
|