x-ui-design 0.5.28 → 0.5.30
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 +17 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -13
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +38 -33
- package/lib/components/Select/Tag/Tag.tsx +3 -2
- package/package.json +1 -1
- package/src/app/page.tsx +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$1 from 'react/jsx-runtime';
|
|
2
|
-
import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useContext, useMemo, useEffect, forwardRef, createContext, useImperativeHandle, useCallback } from 'react';
|
|
2
|
+
import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useContext, useMemo, useEffect, forwardRef, createContext, useImperativeHandle, useCallback, useLayoutEffect } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import ReactDOMServer from 'react-dom/server';
|
|
5
5
|
|
|
@@ -3188,7 +3188,8 @@ const Tag = ({
|
|
|
3188
3188
|
label,
|
|
3189
3189
|
closable,
|
|
3190
3190
|
color,
|
|
3191
|
-
icon
|
|
3191
|
+
icon,
|
|
3192
|
+
className = ''
|
|
3192
3193
|
}) => {
|
|
3193
3194
|
const handleOnClick = e => {
|
|
3194
3195
|
e.preventDefault();
|
|
@@ -3201,7 +3202,7 @@ const Tag = ({
|
|
|
3201
3202
|
...style,
|
|
3202
3203
|
backgroundColor: color
|
|
3203
3204
|
},
|
|
3204
|
-
className: `${prefixCls}-tag`
|
|
3205
|
+
className: `${prefixCls}-tag ${className}`
|
|
3205
3206
|
}, /*#__PURE__*/React.createElement("span", null, label !== undefined ? label : value), closable && /*#__PURE__*/React.createElement("span", {
|
|
3206
3207
|
className: `${prefixCls}-tag-close-icon`,
|
|
3207
3208
|
onClick: handleOnClick
|
|
@@ -3658,39 +3659,41 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3658
3659
|
return option?.children || option?.label || option?.value || null;
|
|
3659
3660
|
})() || selected || null;
|
|
3660
3661
|
const hasMaxTagCount = hasMode && (typeof maxTagCount === 'number' || maxTagCount === 'responsive');
|
|
3661
|
-
const displayTagCount = maxTagCount === 'responsive' ? responsiveTagCount : maxTagCount;
|
|
3662
3662
|
const selectedTags = hasMode ? selected : [];
|
|
3663
|
+
const displayTagCount = maxTagCount === 'responsive' ? responsiveTagCount : maxTagCount;
|
|
3663
3664
|
const tagsToDisplay = hasMaxTagCount ? selectedTags.slice(0, displayTagCount || selectedTags.length) : selectedTags;
|
|
3664
3665
|
const overflowCount = hasMaxTagCount ? selectedTags.length - (displayTagCount || selectedTags.length) : 0;
|
|
3665
|
-
|
|
3666
|
-
|
|
3666
|
+
const container = tagContainerRef.current;
|
|
3667
|
+
const tags = Array.from(container?.querySelectorAll(`.${prefixCls}-tag:not(.contentEditable)`) || []);
|
|
3668
|
+
useLayoutEffect(() => {
|
|
3669
|
+
if (maxTagCount === 'responsive' && container) {
|
|
3667
3670
|
const calculateTagsToDisplay = () => {
|
|
3668
|
-
const container = tagContainerRef.current;
|
|
3669
|
-
const tags = Array.from(container?.querySelectorAll(`.${prefixCls}-tag`) || []);
|
|
3670
3671
|
const containerWidth = container?.clientWidth || 0;
|
|
3671
3672
|
let currentWidth = 0;
|
|
3672
3673
|
let count = 0;
|
|
3673
3674
|
for (let i = 0; i < tags.length; i++) {
|
|
3674
3675
|
const tag = tags[i];
|
|
3675
|
-
currentWidth += tag.offsetWidth +
|
|
3676
|
-
if (currentWidth < containerWidth) {
|
|
3676
|
+
currentWidth += tag.offsetWidth + PADDING_PLACEMENT;
|
|
3677
|
+
if (currentWidth + 40 < containerWidth) {
|
|
3677
3678
|
count++;
|
|
3678
3679
|
} else {
|
|
3679
3680
|
break;
|
|
3680
3681
|
}
|
|
3681
3682
|
}
|
|
3682
|
-
|
|
3683
|
+
if (currentWidth >= containerWidth) {
|
|
3684
|
+
setResponsiveTagCount(count);
|
|
3685
|
+
}
|
|
3683
3686
|
};
|
|
3684
3687
|
const observer = new ResizeObserver(() => {
|
|
3685
3688
|
calculateTagsToDisplay();
|
|
3686
3689
|
});
|
|
3687
|
-
observer.observe(
|
|
3690
|
+
observer.observe(container);
|
|
3688
3691
|
calculateTagsToDisplay();
|
|
3689
3692
|
return () => {
|
|
3690
3693
|
observer.disconnect();
|
|
3691
3694
|
};
|
|
3692
3695
|
}
|
|
3693
|
-
}, [maxTagCount, selected
|
|
3696
|
+
}, [maxTagCount, selected]);
|
|
3694
3697
|
return /*#__PURE__*/React.createElement("div", {
|
|
3695
3698
|
id: id,
|
|
3696
3699
|
ref: selectRef,
|
|
@@ -3747,7 +3750,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
|
|
|
3747
3750
|
opacity: 0.5
|
|
3748
3751
|
}
|
|
3749
3752
|
}, searchFocused ? '' : placeholder)) : null, isOpen ? /*#__PURE__*/React.createElement("div", {
|
|
3750
|
-
className: `${prefixCls}-tag`
|
|
3753
|
+
className: `${prefixCls}-tag contentEditable`
|
|
3751
3754
|
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
3752
3755
|
ref: searchInputRef,
|
|
3753
3756
|
onClick: e => {
|