nillud-data-table 1.2.3 → 1.2.5

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -418,6 +418,7 @@ var DataTable = forwardRef(({
418
418
  groupBy = null,
419
419
  isTitles = false
420
420
  }, ref) => {
421
+ const [isInitialLoad, setIsInitialLoad] = useState(true);
421
422
  const [filters, setFilters] = useState({});
422
423
  const [sortBy, setSortBy] = useState({ col: "", type: "asc" });
423
424
  const [paginationSize, setPaginationSize] = useState((paginationCounts == null ? void 0 : paginationCounts[0]) || 0);
@@ -446,8 +447,10 @@ var DataTable = forwardRef(({
446
447
  console.error("Error parsing localStorage data:", e);
447
448
  setSortBy({ col: "", type: "asc" });
448
449
  setFilters({});
449
- setPaginationSize((paginationCounts == null ? void 0 : paginationCounts[0]) || 10);
450
+ setPaginationSize((paginationCounts == null ? void 0 : paginationCounts[0]) || 0);
450
451
  setPaginationPage(0);
452
+ } finally {
453
+ setIsInitialLoad(false);
451
454
  }
452
455
  }, [tableName, paginationCounts]);
453
456
  useEffect2(() => {
@@ -474,8 +477,10 @@ var DataTable = forwardRef(({
474
477
  return processedData.slice(start, start + paginationSize);
475
478
  }, [processedData, paginationPage, paginationSize]);
476
479
  useEffect2(() => {
477
- setPaginationPage(0);
478
- }, [filters, sortBy]);
480
+ if (Object.values(filters).some((value) => {
481
+ return value !== null && value !== void 0 && value !== "";
482
+ })) setPaginationPage(0);
483
+ }, [filters]);
479
484
  useDebouncedEffect(() => {
480
485
  localStorage.setItem(`${tableName}-filters`, JSON.stringify(filters));
481
486
  }, [filters, tableName], 500);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nillud-data-table",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",