fis-component 0.0.73 → 0.0.76
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 +39 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/Select/Select.stories.d.ts +1 -0
- package/dist/cjs/types/src/components/Select/types.d.ts +2 -1
- package/dist/esm/index.js +39 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/Select/Select.stories.d.ts +1 -0
- package/dist/esm/types/src/components/Select/types.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -70556,9 +70556,12 @@ ${({ $disabled }) => {
|
|
|
70556
70556
|
`;
|
|
70557
70557
|
const SpanLabel$1 = styled.span `
|
|
70558
70558
|
margin: 0;
|
|
70559
|
-
|
|
70560
|
-
|
|
70561
|
-
|
|
70559
|
+
overflow: hidden;
|
|
70560
|
+
text-overflow: ellipsis;
|
|
70561
|
+
white-space: nowrap;
|
|
70562
|
+
// display: flex;
|
|
70563
|
+
// align-items: center;
|
|
70564
|
+
// justify-content: center;
|
|
70562
70565
|
|
|
70563
70566
|
&.no-padding {
|
|
70564
70567
|
padding-right: 0;
|
|
@@ -70721,6 +70724,7 @@ const MultipleValue = ({ options, onRemove }) => {
|
|
|
70721
70724
|
const [hiddenTagCount, setHiddenTagCount] = React.useState(0);
|
|
70722
70725
|
const theme = styled.useTheme();
|
|
70723
70726
|
const calculateVisibleTags = React.useCallback(() => {
|
|
70727
|
+
// Đảm bảo containerRef đã được khởi tạo và có phần tử
|
|
70724
70728
|
if (!containerRef.current || options.length === 0)
|
|
70725
70729
|
return;
|
|
70726
70730
|
const container = containerRef.current;
|
|
@@ -70732,7 +70736,7 @@ const MultipleValue = ({ options, onRemove }) => {
|
|
|
70732
70736
|
for (let i = 0; i < options.length; i++) {
|
|
70733
70737
|
const tagElement = tagRefs.current[i];
|
|
70734
70738
|
if (!tagElement)
|
|
70735
|
-
continue;
|
|
70739
|
+
continue; // Skip if tag ref is null
|
|
70736
70740
|
const tagWidth = tagElement.offsetWidth;
|
|
70737
70741
|
if (firstTotalWidth + tagWidth + gap <= containerClientWidth) {
|
|
70738
70742
|
newFirstTag.push(options[i]);
|
|
@@ -70782,14 +70786,39 @@ const MultipleValue = ({ options, onRemove }) => {
|
|
|
70782
70786
|
const isVisible = React.useCallback((option) => firstTag.some((t) => t.value === option.value) ||
|
|
70783
70787
|
secondTag.some((t) => t.value === option.value), [firstTag, secondTag]);
|
|
70784
70788
|
React.useLayoutEffect(() => {
|
|
70789
|
+
// Tạo một flag để theo dõi trạng thái mounted
|
|
70790
|
+
let isMounted = true;
|
|
70791
|
+
// Sử dụng RAF để đảm bảo DOM đã render
|
|
70792
|
+
let rafId = requestAnimationFrame(() => {
|
|
70793
|
+
// Chỉ tính toán nếu component vẫn mounted
|
|
70794
|
+
if (isMounted && containerRef.current) {
|
|
70795
|
+
calculateVisibleTags();
|
|
70796
|
+
}
|
|
70797
|
+
});
|
|
70798
|
+
// Tạo ResizeObserver để theo dõi khi container được render và có kích thước
|
|
70799
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
70800
|
+
if (isMounted && containerRef.current) {
|
|
70801
|
+
calculateVisibleTags();
|
|
70802
|
+
}
|
|
70803
|
+
});
|
|
70804
|
+
// Observe container nếu nó đã tồn tại
|
|
70805
|
+
if (containerRef.current) {
|
|
70806
|
+
resizeObserver.observe(containerRef.current);
|
|
70807
|
+
}
|
|
70785
70808
|
const handleResize = () => {
|
|
70786
|
-
|
|
70809
|
+
if (isMounted) {
|
|
70810
|
+
calculateVisibleTags();
|
|
70811
|
+
}
|
|
70787
70812
|
};
|
|
70788
|
-
calculateVisibleTags();
|
|
70789
70813
|
window.addEventListener("resize", handleResize);
|
|
70790
|
-
return () =>
|
|
70814
|
+
return () => {
|
|
70815
|
+
isMounted = false;
|
|
70816
|
+
cancelAnimationFrame(rafId);
|
|
70817
|
+
resizeObserver.disconnect();
|
|
70818
|
+
window.removeEventListener("resize", handleResize);
|
|
70819
|
+
};
|
|
70791
70820
|
}, [calculateVisibleTags, options]);
|
|
70792
|
-
return (jsxRuntime.jsxs(DivChipButtonWrapperSC, { ref: containerRef, children: [options.map((option, index) => (jsxRuntime.jsx(DivChipButtonSC, { "$isVisible": isVisible(option), children: jsxRuntime.jsx(FISChipButton, { ref: (el) => (tagRefs.current[index] = el), size: "xs", label: option.label, closeable: true, onClickClose: () => handleRemove(option) }, `${option.value}-${index}`)
|
|
70821
|
+
return (jsxRuntime.jsxs(DivChipButtonWrapperSC, { ref: containerRef, children: [options.map((option, index) => (jsxRuntime.jsx(DivChipButtonSC, { "$isVisible": isVisible(option), children: jsxRuntime.jsx(FISChipButton, { ref: (el) => (tagRefs.current[index] = el), size: "xs", label: option.label, closeable: true, onClickClose: () => handleRemove(option) }) }, `${option.value}-${index}`))), hiddenTagCount > 0 && (jsxRuntime.jsx(DivTagSC, { "$isVisible": true, children: jsxRuntime.jsx(FISChipButton, { label: `+${hiddenTagCount}`, size: "xs" }) }))] }));
|
|
70793
70822
|
};
|
|
70794
70823
|
|
|
70795
70824
|
const FISCombobox = React.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) => {
|
|
@@ -73411,7 +73440,7 @@ function isMenuSize(value) {
|
|
|
73411
73440
|
return value === "sm" || value === "md";
|
|
73412
73441
|
}
|
|
73413
73442
|
|
|
73414
|
-
const FISSelect = React.forwardRef(({ className, style, size = "md", options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, searchValue, onSearchChange, portal, maxHeight, ...restProps }, ref) => {
|
|
73443
|
+
const FISSelect = React.forwardRef(({ className, style, size = "md", options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholder, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, searchValue, onSearchChange, portal, maxHeight, ...restProps }, ref) => {
|
|
73415
73444
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
73416
73445
|
const [referenceElement, setReferenceElement] = React.useState(null);
|
|
73417
73446
|
const [popperElement, setPopperElement] = React.useState(null);
|
|
@@ -73550,7 +73579,7 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
|
|
|
73550
73579
|
document.addEventListener("mousedown", handleClickOutside);
|
|
73551
73580
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
73552
73581
|
}, [referenceElement, popperElement]);
|
|
73553
|
-
return (jsxRuntime.jsxs(DivWrapperSC$1, { className: className, style: style, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsx(DivInputWrapperSC, { ref: setReferenceElement, onClick: handleToggle, "$hasValue": !!value, children: jsxRuntime.jsx(FISSelectItem, { ...restProps, ref: ref, size: size, iconSuffix: isOpen ? jsxRuntime.jsx(ArrowUpIcon, {}) : jsxRuntime.jsx(ArrowDownIcon, {}), value: computedDisplayValue(), disabled: disabled, activeDropdown: isOpen, negative: negative }) }), message && (jsxRuntime.jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsxRuntime.jsx(SelectedTagsWrapper, { children: jsxRuntime.jsx(MultipleValue, { options: selectedItems, onRemove: handleOptionRemove }) })), isOpen && (jsxRuntime.jsx(Portal, { portal: portal, children: jsxRuntime.jsx(DivDropdownMenuSC, { ref: setPopperElement, style: {
|
|
73582
|
+
return (jsxRuntime.jsxs(DivWrapperSC$1, { className: className, style: style, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsx(DivInputWrapperSC, { ref: setReferenceElement, onClick: handleToggle, "$hasValue": !!value, children: jsxRuntime.jsx(FISSelectItem, { ...restProps, ref: ref, size: size, placeholder: placeholder, iconSuffix: isOpen ? jsxRuntime.jsx(ArrowUpIcon, {}) : jsxRuntime.jsx(ArrowDownIcon, {}), value: computedDisplayValue(), disabled: disabled, activeDropdown: isOpen, negative: negative }) }), message && (jsxRuntime.jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsxRuntime.jsx(SelectedTagsWrapper, { children: jsxRuntime.jsx(MultipleValue, { options: selectedItems, onRemove: handleOptionRemove }) })), isOpen && (jsxRuntime.jsx(Portal, { portal: portal, children: jsxRuntime.jsx(DivDropdownMenuSC, { ref: setPopperElement, style: {
|
|
73554
73583
|
...styles.popper,
|
|
73555
73584
|
width: referenceElement?.offsetWidth,
|
|
73556
73585
|
zIndex: 9999,
|