nillud-data-table 1.2.3 → 1.2.4
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.js +8 -3
- 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]) ||
|
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
|
-
|
478
|
-
|
480
|
+
if (!isInitialLoad) {
|
481
|
+
setPaginationPage(0);
|
482
|
+
}
|
483
|
+
}, [filters, sortBy, isInitialLoad]);
|
479
484
|
useDebouncedEffect(() => {
|
480
485
|
localStorage.setItem(`${tableName}-filters`, JSON.stringify(filters));
|
481
486
|
}, [filters, tableName], 500);
|