fis-component 0.0.72 → 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/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
- calculateVisibleTags();
70786
+ if (isMounted) {
70787
+ calculateVisibleTags();
70788
+ }
70767
70789
  };
70768
- calculateVisibleTags();
70769
70790
  window.addEventListener("resize", handleResize);
70770
- return () => window.removeEventListener("resize", handleResize);
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}`) }))), hiddenTagCount > 0 && (jsx(DivTagSC, { "$isVisible": true, children: jsx(FISChipButton, { label: `+${hiddenTagCount}`, size: "xs" }) }))] }));
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) => {
@@ -71819,7 +71845,7 @@ const DivSuffixIconSC = styled.div `
71819
71845
  `;
71820
71846
 
71821
71847
  const { RangePicker } = DatePicker;
71822
- const FISDateRange = ({ placeholder = ["dd/mm/yyyy", "dd/mm/yyyy"], label, required = true, message, negative = false, positive = false, disabled = true, ...rest }) => {
71848
+ const FISDateRange = ({ placeholder = ["dd/mm/yyyy", "dd/mm/yyyy"], label, required, message, negative, positive, disabled, ...rest }) => {
71823
71849
  const [open, setOpen] = useState(false);
71824
71850
  const handleOpenCalendar = () => {
71825
71851
  setOpen(!open);