x-ui-design 0.3.38 → 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 +14 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +17 -9
- 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,8 +3037,10 @@ 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;
|
|
@@ -3052,7 +3054,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3052
3054
|
const shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
3053
3055
|
const shouldShowBelow = spaceAbove < dropdownHeight && spaceBelow > dropdownHeight;
|
|
3054
3056
|
const inForm = !!triggerNode.closest(`.${prefixClsForm}`) ? FORM_MARGIN_BOTTOM : 0;
|
|
3055
|
-
if (shouldShowAbove || shouldShowBelow) {
|
|
3057
|
+
if (shouldShowAbove || shouldShowBelow || searchQueryUpdated) {
|
|
3056
3058
|
if (getPopupContainer) {
|
|
3057
3059
|
positionStyle = {
|
|
3058
3060
|
...positionStyle,
|
|
@@ -3076,20 +3078,21 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3076
3078
|
}, [isOpen]);
|
|
3077
3079
|
useEffect(() => {
|
|
3078
3080
|
if (!isOpen) return;
|
|
3079
|
-
updateDropdownPosition();
|
|
3081
|
+
const _updateDropdownPosition = () => updateDropdownPosition();
|
|
3082
|
+
_updateDropdownPosition();
|
|
3080
3083
|
const controller = new AbortController();
|
|
3081
3084
|
const scrollableParents = getScrollParents(selectRef.current);
|
|
3082
3085
|
scrollableParents.forEach(el => {
|
|
3083
|
-
el.addEventListener('scroll',
|
|
3086
|
+
el.addEventListener('scroll', _updateDropdownPosition, {
|
|
3084
3087
|
passive: true,
|
|
3085
3088
|
signal: controller.signal
|
|
3086
3089
|
});
|
|
3087
3090
|
});
|
|
3088
|
-
window.addEventListener('scroll',
|
|
3091
|
+
window.addEventListener('scroll', _updateDropdownPosition, {
|
|
3089
3092
|
passive: true,
|
|
3090
3093
|
signal: controller.signal
|
|
3091
3094
|
});
|
|
3092
|
-
window.addEventListener('resize',
|
|
3095
|
+
window.addEventListener('resize', _updateDropdownPosition, {
|
|
3093
3096
|
signal: controller.signal
|
|
3094
3097
|
});
|
|
3095
3098
|
return () => {
|
|
@@ -3097,7 +3100,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3097
3100
|
};
|
|
3098
3101
|
}, [isOpen, getPopupContainer, updateDropdownPosition]);
|
|
3099
3102
|
useEffect(() => {
|
|
3100
|
-
updateDropdownPosition();
|
|
3103
|
+
updateDropdownPosition(true);
|
|
3101
3104
|
}, [searchQuery.length]);
|
|
3102
3105
|
const getScrollParents = element => {
|
|
3103
3106
|
const parents = [];
|
|
@@ -3376,14 +3379,14 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3376
3379
|
},
|
|
3377
3380
|
onKeyDown: handleOnKeyDown,
|
|
3378
3381
|
style: {
|
|
3379
|
-
width: 'auto',
|
|
3382
|
+
width: showSearch && !searchQuery.length ? 0 : 'auto',
|
|
3380
3383
|
display: 'ruby',
|
|
3381
3384
|
textAlign: 'center'
|
|
3382
3385
|
},
|
|
3383
3386
|
contentEditable: "plaintext-only",
|
|
3384
3387
|
id: `${prefixCls}-search-tag-input`,
|
|
3385
3388
|
className: `${prefixCls}-tag-input`
|
|
3386
|
-
})) : !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", {
|
|
3387
3390
|
className: `${prefixCls}-input globalEllipsis`,
|
|
3388
3391
|
style: {
|
|
3389
3392
|
opacity: isOpen || selected === '' ? '0.6' : '1'
|