x-ui-design 0.5.32 → 0.5.33
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 +26 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -27
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +31 -31
- package/lib/components/Select/Tag/style.css +5 -0
- package/package.json +1 -1
- package/src/app/page.tsx +0 -3
package/dist/index.esm.js
CHANGED
|
@@ -3177,7 +3177,7 @@ var Option$1 = /*#__PURE__*/Object.freeze({
|
|
|
3177
3177
|
default: Option
|
|
3178
3178
|
});
|
|
3179
3179
|
|
|
3180
|
-
var css_248z$6 = ".xUi-select .xUi-select-tag-container{display:flex;flex:auto;flex-wrap:wrap;gap:4px;line-height:12px;position:relative}.xUi-select.large .xUi-select-tag-container,.xUi-select.middle .xUi-select-tag-container{line-height:22px}.xUi-select .xUi-select-tag{align-items:center;align-self:center;background:rgba(0,0,0,.06);border:1px solid transparent;border-radius:var(--xui-border-radius-sm);box-sizing:border-box;cursor:default;display:flex;flex:none;height:100%;max-width:100%;overflow:hidden;padding:2px;text-overflow:ellipsis;transition:font-size .3s,line-height .3s,height .3s;white-space:nowrap}.xUi-select.middle .xUi-select-tag{padding:4px 8px}.xUi-select.large .xUi-select-tag{font-size:var(--xui-font-size-lg);padding:4px 8px}.xUi-select .xUi-select-tag span{font-size:var(--xui-font-size-sm);margin:0 2px}.xUi-select .xUi-select-tag .xUi-select-tag-close-icon{color:rgba(0,0,0,.5);cursor:pointer;font-size:var(--xui-font-size-xs)}.xUi-select .xUi-select-tag .xUi-select-tag-close-icon:hover{color:var(--xui-text-color)}.xUi-select .xUi-select-tag:has([class=xUi-select-tag-input]){background:transparent;border:none;color:var(--xui-text-color);font-size:var(--xui-font-size-md);outline:none;padding:0}.xUi-select .xUi-select-tag:has([class=xUi-select-tag-input]) input{background-color:transparent;border:none;font-size:var(--xui-font-size-md);height:-webkit-fill-available;padding:0}.xUi-select .xUi-select-tag-input:focus{border:none;box-shadow:none;outline:none}";
|
|
3180
|
+
var css_248z$6 = ".xUi-select .xUi-select-tag-container{display:flex;flex:auto;flex-wrap:wrap;gap:4px;line-height:12px;position:relative}.xUi-select .xUi-select-tag-container-fixHeight{height:32px;overflow:hidden}.xUi-select.large .xUi-select-tag-container,.xUi-select.middle .xUi-select-tag-container{line-height:22px}.xUi-select .xUi-select-tag{align-items:center;align-self:center;background:rgba(0,0,0,.06);border:1px solid transparent;border-radius:var(--xui-border-radius-sm);box-sizing:border-box;cursor:default;display:flex;flex:none;height:100%;max-width:100%;overflow:hidden;padding:2px;text-overflow:ellipsis;transition:font-size .3s,line-height .3s,height .3s;white-space:nowrap}.xUi-select.middle .xUi-select-tag{padding:4px 8px}.xUi-select.large .xUi-select-tag{font-size:var(--xui-font-size-lg);padding:4px 8px}.xUi-select .xUi-select-tag span{font-size:var(--xui-font-size-sm);margin:0 2px}.xUi-select .xUi-select-tag .xUi-select-tag-close-icon{color:rgba(0,0,0,.5);cursor:pointer;font-size:var(--xui-font-size-xs)}.xUi-select .xUi-select-tag .xUi-select-tag-close-icon:hover{color:var(--xui-text-color)}.xUi-select .xUi-select-tag:has([class=xUi-select-tag-input]){background:transparent;border:none;color:var(--xui-text-color);font-size:var(--xui-font-size-md);outline:none;padding:0}.xUi-select .xUi-select-tag:has([class=xUi-select-tag-input]) input{background-color:transparent;border:none;font-size:var(--xui-font-size-md);height:-webkit-fill-available;padding:0}.xUi-select .xUi-select-tag-input:focus{border:none;box-shadow:none;outline:none}";
|
|
3181
3181
|
styleInject(css_248z$6);
|
|
3182
3182
|
|
|
3183
3183
|
const Tag = ({
|
|
@@ -3298,6 +3298,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3298
3298
|
const [isOpenChecker, setIsOpenChecker] = useState(isOpen);
|
|
3299
3299
|
const [searchQuery, setSearchQuery] = useState(searchValue || '');
|
|
3300
3300
|
const [dropdownPosition, setDropdownPosition] = useState({});
|
|
3301
|
+
const [lastTagWidth, setLastTagWidth] = useState(0);
|
|
3301
3302
|
const tagContainerRef = useRef(null);
|
|
3302
3303
|
const searchInputRef = useRef(null);
|
|
3303
3304
|
const [responsiveTagCount, setResponsiveTagCount] = useState(null);
|
|
@@ -3664,36 +3665,32 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3664
3665
|
const displayTagCount = maxTagCount === 'responsive' ? responsiveTagCount : maxTagCount;
|
|
3665
3666
|
const tagsToDisplay = hasMaxTagCount ? selectedTags.slice(0, displayTagCount || selectedTags.length) : selectedTags;
|
|
3666
3667
|
const overflowCount = hasMaxTagCount ? selectedTags.length - (displayTagCount || selectedTags.length) : 0;
|
|
3667
|
-
const tags = Array.from(container?.querySelectorAll(`.${prefixCls}-tag:not(.contentEditable)`) || []);
|
|
3668
|
+
const tags = Array.from(container?.querySelectorAll(`.${prefixCls}-tag:not(.contentEditable):not(.${prefixCls}-tag-overflow)`) || []);
|
|
3668
3669
|
useLayoutEffect(() => {
|
|
3669
3670
|
if (maxTagCount === 'responsive' && container) {
|
|
3670
|
-
const
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
if (currentWidth + 40 < containerWidth) {
|
|
3678
|
-
count++;
|
|
3679
|
-
} else {
|
|
3680
|
-
break;
|
|
3681
|
-
}
|
|
3671
|
+
const containerWidth = container?.clientWidth || 0;
|
|
3672
|
+
let currentWidth = 0;
|
|
3673
|
+
let count = 0;
|
|
3674
|
+
for (let i = 0; i < tags.length; i++) {
|
|
3675
|
+
const tag = tags[i];
|
|
3676
|
+
if (tags.length - 1 === i && overflowCount) {
|
|
3677
|
+
setLastTagWidth(tag.offsetWidth);
|
|
3682
3678
|
}
|
|
3683
|
-
|
|
3684
|
-
|
|
3679
|
+
currentWidth += tag.offsetWidth + PADDING_PLACEMENT;
|
|
3680
|
+
if (currentWidth + 40 < containerWidth) {
|
|
3681
|
+
count++;
|
|
3682
|
+
} else {
|
|
3683
|
+
break;
|
|
3685
3684
|
}
|
|
3686
|
-
}
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
}
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
observer.disconnect();
|
|
3694
|
-
};
|
|
3685
|
+
}
|
|
3686
|
+
if (overflowCount === 1 && lastTagWidth) {
|
|
3687
|
+
setResponsiveTagCount(0);
|
|
3688
|
+
}
|
|
3689
|
+
if (currentWidth >= containerWidth) {
|
|
3690
|
+
setResponsiveTagCount(count);
|
|
3691
|
+
}
|
|
3695
3692
|
}
|
|
3696
|
-
}, [maxTagCount,
|
|
3693
|
+
}, [maxTagCount, container, tags, overflowCount]);
|
|
3697
3694
|
return /*#__PURE__*/React.createElement("div", {
|
|
3698
3695
|
id: id,
|
|
3699
3696
|
ref: selectRef,
|
|
@@ -3722,7 +3719,9 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3722
3719
|
} : {}),
|
|
3723
3720
|
minWidth: `${searchInputWidth}px`
|
|
3724
3721
|
},
|
|
3725
|
-
className: `${prefixCls}-tag-container
|
|
3722
|
+
className: clsx([`${prefixCls}-tag-container`, {
|
|
3723
|
+
[`${prefixCls}-tag-container-fixHeight`]: !tagContainerRef.current
|
|
3724
|
+
}])
|
|
3726
3725
|
}, hasMode ? /*#__PURE__*/React.createElement(React.Fragment, null, selectedTags.length ? /*#__PURE__*/React.createElement(React.Fragment, null, tagsToDisplay.map((tag, index) => tagRender ? /*#__PURE__*/React.createElement("div", {
|
|
3727
3726
|
key: `${index}_${tag}`
|
|
3728
3727
|
}, tagRender?.({
|