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/cjs/index.js CHANGED
@@ -70721,6 +70721,7 @@ const MultipleValue = ({ options, onRemove }) => {
70721
70721
  const [hiddenTagCount, setHiddenTagCount] = React.useState(0);
70722
70722
  const theme = styled.useTheme();
70723
70723
  const calculateVisibleTags = React.useCallback(() => {
70724
+ // Đảm bảo containerRef đã được khởi tạo và có phần tử
70724
70725
  if (!containerRef.current || options.length === 0)
70725
70726
  return;
70726
70727
  const container = containerRef.current;
@@ -70732,7 +70733,7 @@ const MultipleValue = ({ options, onRemove }) => {
70732
70733
  for (let i = 0; i < options.length; i++) {
70733
70734
  const tagElement = tagRefs.current[i];
70734
70735
  if (!tagElement)
70735
- continue;
70736
+ continue; // Skip if tag ref is null
70736
70737
  const tagWidth = tagElement.offsetWidth;
70737
70738
  if (firstTotalWidth + tagWidth + gap <= containerClientWidth) {
70738
70739
  newFirstTag.push(options[i]);
@@ -70782,14 +70783,39 @@ const MultipleValue = ({ options, onRemove }) => {
70782
70783
  const isVisible = React.useCallback((option) => firstTag.some((t) => t.value === option.value) ||
70783
70784
  secondTag.some((t) => t.value === option.value), [firstTag, secondTag]);
70784
70785
  React.useLayoutEffect(() => {
70786
+ // Tạo một flag để theo dõi trạng thái mounted
70787
+ let isMounted = true;
70788
+ // Sử dụng RAF để đảm bảo DOM đã render
70789
+ let rafId = requestAnimationFrame(() => {
70790
+ // Chỉ tính toán nếu component vẫn mounted
70791
+ if (isMounted && containerRef.current) {
70792
+ calculateVisibleTags();
70793
+ }
70794
+ });
70795
+ // Tạo ResizeObserver để theo dõi khi container được render và có kích thước
70796
+ const resizeObserver = new ResizeObserver(() => {
70797
+ if (isMounted && containerRef.current) {
70798
+ calculateVisibleTags();
70799
+ }
70800
+ });
70801
+ // Observe container nếu nó đã tồn tại
70802
+ if (containerRef.current) {
70803
+ resizeObserver.observe(containerRef.current);
70804
+ }
70785
70805
  const handleResize = () => {
70786
- calculateVisibleTags();
70806
+ if (isMounted) {
70807
+ calculateVisibleTags();
70808
+ }
70787
70809
  };
70788
- calculateVisibleTags();
70789
70810
  window.addEventListener("resize", handleResize);
70790
- return () => window.removeEventListener("resize", handleResize);
70811
+ return () => {
70812
+ isMounted = false;
70813
+ cancelAnimationFrame(rafId);
70814
+ resizeObserver.disconnect();
70815
+ window.removeEventListener("resize", handleResize);
70816
+ };
70791
70817
  }, [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}`) }))), hiddenTagCount > 0 && (jsxRuntime.jsx(DivTagSC, { "$isVisible": true, children: jsxRuntime.jsx(FISChipButton, { label: `+${hiddenTagCount}`, size: "xs" }) }))] }));
70818
+ 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
70819
  };
70794
70820
 
70795
70821
  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) => {
@@ -71839,7 +71865,7 @@ const DivSuffixIconSC = styled.div `
71839
71865
  `;
71840
71866
 
71841
71867
  const { RangePicker } = DatePicker;
71842
- const FISDateRange = ({ placeholder = ["dd/mm/yyyy", "dd/mm/yyyy"], label, required = true, message, negative = false, positive = false, disabled = true, ...rest }) => {
71868
+ const FISDateRange = ({ placeholder = ["dd/mm/yyyy", "dd/mm/yyyy"], label, required, message, negative, positive, disabled, ...rest }) => {
71843
71869
  const [open, setOpen] = React.useState(false);
71844
71870
  const handleOpenCalendar = () => {
71845
71871
  setOpen(!open);