fis-component 0.0.73 → 0.0.74
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/cjs/index.js +31 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +31 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -70701,6 +70701,7 @@ const MultipleValue = ({ options, onRemove }) => {
|
|
|
70701
70701
|
const [hiddenTagCount, setHiddenTagCount] = useState(0);
|
|
70702
70702
|
const theme = useTheme$1();
|
|
70703
70703
|
const calculateVisibleTags = useCallback(() => {
|
|
70704
|
+
// Đảm bảo containerRef đã được khởi tạo và có phần tử
|
|
70704
70705
|
if (!containerRef.current || options.length === 0)
|
|
70705
70706
|
return;
|
|
70706
70707
|
const container = containerRef.current;
|
|
@@ -70712,7 +70713,7 @@ const MultipleValue = ({ options, onRemove }) => {
|
|
|
70712
70713
|
for (let i = 0; i < options.length; i++) {
|
|
70713
70714
|
const tagElement = tagRefs.current[i];
|
|
70714
70715
|
if (!tagElement)
|
|
70715
|
-
continue;
|
|
70716
|
+
continue; // Skip if tag ref is null
|
|
70716
70717
|
const tagWidth = tagElement.offsetWidth;
|
|
70717
70718
|
if (firstTotalWidth + tagWidth + gap <= containerClientWidth) {
|
|
70718
70719
|
newFirstTag.push(options[i]);
|
|
@@ -70762,14 +70763,39 @@ const MultipleValue = ({ options, onRemove }) => {
|
|
|
70762
70763
|
const isVisible = useCallback((option) => firstTag.some((t) => t.value === option.value) ||
|
|
70763
70764
|
secondTag.some((t) => t.value === option.value), [firstTag, secondTag]);
|
|
70764
70765
|
useLayoutEffect$2(() => {
|
|
70766
|
+
// Tạo một flag để theo dõi trạng thái mounted
|
|
70767
|
+
let isMounted = true;
|
|
70768
|
+
// Sử dụng RAF để đảm bảo DOM đã render
|
|
70769
|
+
let rafId = requestAnimationFrame(() => {
|
|
70770
|
+
// Chỉ tính toán nếu component vẫn mounted
|
|
70771
|
+
if (isMounted && containerRef.current) {
|
|
70772
|
+
calculateVisibleTags();
|
|
70773
|
+
}
|
|
70774
|
+
});
|
|
70775
|
+
// Tạo ResizeObserver để theo dõi khi container được render và có kích thước
|
|
70776
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
70777
|
+
if (isMounted && containerRef.current) {
|
|
70778
|
+
calculateVisibleTags();
|
|
70779
|
+
}
|
|
70780
|
+
});
|
|
70781
|
+
// Observe container nếu nó đã tồn tại
|
|
70782
|
+
if (containerRef.current) {
|
|
70783
|
+
resizeObserver.observe(containerRef.current);
|
|
70784
|
+
}
|
|
70765
70785
|
const handleResize = () => {
|
|
70766
|
-
|
|
70786
|
+
if (isMounted) {
|
|
70787
|
+
calculateVisibleTags();
|
|
70788
|
+
}
|
|
70767
70789
|
};
|
|
70768
|
-
calculateVisibleTags();
|
|
70769
70790
|
window.addEventListener("resize", handleResize);
|
|
70770
|
-
return () =>
|
|
70791
|
+
return () => {
|
|
70792
|
+
isMounted = false;
|
|
70793
|
+
cancelAnimationFrame(rafId);
|
|
70794
|
+
resizeObserver.disconnect();
|
|
70795
|
+
window.removeEventListener("resize", handleResize);
|
|
70796
|
+
};
|
|
70771
70797
|
}, [calculateVisibleTags, options]);
|
|
70772
|
-
return (jsxs(DivChipButtonWrapperSC, { ref: containerRef, children: [options.map((option, index) => (jsx(DivChipButtonSC, { "$isVisible": isVisible(option), children: jsx(FISChipButton, { ref: (el) => (tagRefs.current[index] = el), size: "xs", label: option.label, closeable: true, onClickClose: () => handleRemove(option) }, `${option.value}-${index}`)
|
|
70798
|
+
return (jsxs(DivChipButtonWrapperSC, { ref: containerRef, children: [options.map((option, index) => (jsx(DivChipButtonSC, { "$isVisible": isVisible(option), children: jsx(FISChipButton, { ref: (el) => (tagRefs.current[index] = el), size: "xs", label: option.label, closeable: true, onClickClose: () => handleRemove(option) }) }, `${option.value}-${index}`))), hiddenTagCount > 0 && (jsx(DivTagSC, { "$isVisible": true, children: jsx(FISChipButton, { label: `+${hiddenTagCount}`, size: "xs" }) }))] }));
|
|
70773
70799
|
};
|
|
70774
70800
|
|
|
70775
70801
|
const FISCombobox = forwardRef(({ className, options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, noResultText = "Không tìm thấy kết quả", maxHeight, ...restProps }, ref) => {
|