@axzydev/axzy_ui_system 1.2.14 → 1.2.15

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.cjs CHANGED
@@ -2755,6 +2755,7 @@ function ITDataTable({
2755
2755
  handleItemsPerPageChange
2756
2756
  } = useTableState({ defaultItemsPerPage });
2757
2757
  const debounceTimerRef = (0, import_react11.useRef)(null);
2758
+ const hasFetchedRef = (0, import_react11.useRef)(false);
2758
2759
  const computedTotalPages = Math.ceil(totalItems / itemsPerPage) || 1;
2759
2760
  const performFetch = (0, import_react11.useCallback)(async () => {
2760
2761
  setIsLoading(true);
@@ -2767,16 +2768,18 @@ function ITDataTable({
2767
2768
  });
2768
2769
  setData(response.data || []);
2769
2770
  setTotalItems(response.total || 0);
2771
+ hasFetchedRef.current = true;
2770
2772
  } catch (error) {
2771
2773
  console.error("ITDataTable: Error fetching data", error);
2772
2774
  setData([]);
2773
2775
  setTotalItems(0);
2776
+ hasFetchedRef.current = true;
2774
2777
  } finally {
2775
2778
  setIsLoading(false);
2776
2779
  }
2777
2780
  }, [currentPage, itemsPerPage, filters, sortConfig, fetchData, externalFilters]);
2778
2781
  (0, import_react11.useEffect)(() => {
2779
- if (!fetchOnMount && data.length === 0 && !isLoading) return;
2782
+ if (!fetchOnMount && !hasFetchedRef.current) return;
2780
2783
  if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
2781
2784
  debounceTimerRef.current = setTimeout(() => {
2782
2785
  performFetch();
@@ -2784,7 +2787,7 @@ function ITDataTable({
2784
2787
  return () => {
2785
2788
  if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
2786
2789
  };
2787
- }, [currentPage, itemsPerPage, sortConfig, filters, externalFilters, reloadTrigger, fetchOnMount, performFetch, data.length, isLoading, debounceMs]);
2790
+ }, [currentPage, itemsPerPage, sortConfig, filters, externalFilters, reloadTrigger, fetchOnMount, performFetch, debounceMs]);
2788
2791
  const renderFilterInput = (col) => {
2789
2792
  if (!col.filter) return null;
2790
2793
  if (col.type === "boolean") {