nillud-data-table 1.2.2 → 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.
Files changed (2) hide show
  1. package/dist/index.js +19 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ var Column = ({ column, getSortField, sortBy, getFilters, filters }) => {
38
38
  return /* @__PURE__ */ jsxs("div", { className: "ndt-column", children: [
39
39
  /* @__PURE__ */ jsxs("div", { className: "ndt-column-head", children: [
40
40
  /* @__PURE__ */ jsx3("span", { children: column.title }),
41
- typeof column.autoinc === "undefined" && (typeof column.sortable === "undefined" || column.sortable) && /* @__PURE__ */ jsx3("div", { className: "ndt-sorter", onClick: toggleSort, children: currentSort === "asc" ? /* @__PURE__ */ jsx3(SortDown_default, {}) : currentSort === "desc" ? /* @__PURE__ */ jsx3(SortUp_default, {}) : null })
41
+ typeof column.autoinc === "undefined" && (typeof column.sortable === "undefined" || column.sortable) && /* @__PURE__ */ jsx3("div", { className: "ndt-sorter", onClick: toggleSort, children: currentSort === "asc" ? /* @__PURE__ */ jsx3(SortDown_default, {}) : currentSort === "desc" ? /* @__PURE__ */ jsx3(SortUp_default, {}) : /* @__PURE__ */ jsx3(SortDown_default, {}) })
42
42
  ] }),
43
43
  /* @__PURE__ */ jsx3("div", { className: "ndt-column-footer", children: typeof column.autoinc === "undefined" && (typeof column.filterable === "undefined" || column.filterable) && /* @__PURE__ */ jsx3(
44
44
  "input",
@@ -235,7 +235,16 @@ var TableFooter = ({
235
235
  }
236
236
  };
237
237
  const renderPageNumbers = () => {
238
- if (totalPages <= 1) return /* @__PURE__ */ jsx12("button", { onClick: () => handlePageChange(0), children: "1" }, "page-0");
238
+ if (totalPages <= 1) return /* @__PURE__ */ jsx12(
239
+ "button",
240
+ {
241
+ className: "btn-active",
242
+ onClick: () => handlePageChange(0),
243
+ disabled: true,
244
+ children: "1"
245
+ },
246
+ "page-0"
247
+ );
239
248
  const pages = [];
240
249
  const maxVisible = 5;
241
250
  let start = Math.max(0, paginationPage - Math.floor(maxVisible / 2));
@@ -409,6 +418,7 @@ var DataTable = forwardRef(({
409
418
  groupBy = null,
410
419
  isTitles = false
411
420
  }, ref) => {
421
+ const [isInitialLoad, setIsInitialLoad] = useState(true);
412
422
  const [filters, setFilters] = useState({});
413
423
  const [sortBy, setSortBy] = useState({ col: "", type: "asc" });
414
424
  const [paginationSize, setPaginationSize] = useState((paginationCounts == null ? void 0 : paginationCounts[0]) || 0);
@@ -437,8 +447,10 @@ var DataTable = forwardRef(({
437
447
  console.error("Error parsing localStorage data:", e);
438
448
  setSortBy({ col: "", type: "asc" });
439
449
  setFilters({});
440
- setPaginationSize((paginationCounts == null ? void 0 : paginationCounts[0]) || 10);
450
+ setPaginationSize((paginationCounts == null ? void 0 : paginationCounts[0]) || 0);
441
451
  setPaginationPage(0);
452
+ } finally {
453
+ setIsInitialLoad(false);
442
454
  }
443
455
  }, [tableName, paginationCounts]);
444
456
  useEffect2(() => {
@@ -465,8 +477,10 @@ var DataTable = forwardRef(({
465
477
  return processedData.slice(start, start + paginationSize);
466
478
  }, [processedData, paginationPage, paginationSize]);
467
479
  useEffect2(() => {
468
- setPaginationPage(0);
469
- }, [filters, sortBy]);
480
+ if (!isInitialLoad) {
481
+ setPaginationPage(0);
482
+ }
483
+ }, [filters, sortBy, isInitialLoad]);
470
484
  useDebouncedEffect(() => {
471
485
  localStorage.setItem(`${tableName}-filters`, JSON.stringify(filters));
472
486
  }, [filters, tableName], 500);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nillud-data-table",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",