@bigbinary/neeto-atoms 1.0.85 → 1.0.87
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/{DataTable-Cqrk769H.js → DataTable-C4_wD2t1.js} +27 -22
- package/dist/DataTable-C4_wD2t1.js.map +1 -0
- package/dist/cjs/{DataTable-ONkM1J3v.js → DataTable-BNeEEAKb.js} +27 -22
- package/dist/cjs/DataTable-BNeEEAKb.js.map +1 -0
- package/dist/cjs/components/DataTable.js +2 -2
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/primitives/Button.js +1 -0
- package/dist/cjs/primitives/Button.js.map +1 -1
- package/dist/components/DataTable.js +2 -2
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/primitives/Button.js +1 -0
- package/dist/primitives/Button.js.map +1 -1
- package/package.json +1 -1
- package/dist/DataTable-Cqrk769H.js.map +0 -1
- package/dist/cjs/DataTable-ONkM1J3v.js.map +0 -1
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useState, useCallback, useEffect, useMemo, useRef, useLayoutEffect } from 'react';
|
|
4
4
|
import { TableRow, TableCell, Table, TableHeader, TableHead, TableBody } from './primitives/Table.js';
|
|
5
5
|
import { c as cn } from './utils-BJnb9o5c.js';
|
|
6
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
6
7
|
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import { Checkbox } from './primitives/Checkbox.js';
|
|
8
9
|
import { Spinner } from './primitives/Spinner.js';
|
|
@@ -3182,20 +3183,6 @@ const writeSortToURL = (sorting) => {
|
|
|
3182
3183
|
}
|
|
3183
3184
|
window.history.pushState({}, "", url.toString());
|
|
3184
3185
|
};
|
|
3185
|
-
const readPageFromURL = () => {
|
|
3186
|
-
const params = new URLSearchParams(window.location.search);
|
|
3187
|
-
const page = params.get(URL_PAGE_PARAM);
|
|
3188
|
-
return page ? Math.max(1, parseInt(page, 10)) : 1;
|
|
3189
|
-
};
|
|
3190
|
-
const writePageToURL = (page) => {
|
|
3191
|
-
const url = new URL(window.location.href);
|
|
3192
|
-
if (page <= 1) {
|
|
3193
|
-
url.searchParams.delete(URL_PAGE_PARAM);
|
|
3194
|
-
} else {
|
|
3195
|
-
url.searchParams.set(URL_PAGE_PARAM, String(page));
|
|
3196
|
-
}
|
|
3197
|
-
window.history.pushState({}, "", url.toString());
|
|
3198
|
-
};
|
|
3199
3186
|
const keysToRowSelection = (keys) => Object.fromEntries(keys.map((key) => [key, true]));
|
|
3200
3187
|
const rowSelectionToKeys = (selection) => Object.keys(selection).filter((key) => selection[key]);
|
|
3201
3188
|
const hashPathname = () => {
|
|
@@ -3339,23 +3326,41 @@ const useTablePagination = ({
|
|
|
3339
3326
|
enableURLPagination = true
|
|
3340
3327
|
}) => {
|
|
3341
3328
|
const isControlled = controlledPage !== void 0;
|
|
3342
|
-
const
|
|
3343
|
-
|
|
3344
|
-
)
|
|
3345
|
-
|
|
3329
|
+
const history = useHistory();
|
|
3330
|
+
const location = useLocation();
|
|
3331
|
+
const pageFromURL = useMemo(() => {
|
|
3332
|
+
if (!enableURLPagination) return 1;
|
|
3333
|
+
const params = new URLSearchParams(location.search);
|
|
3334
|
+
const page = params.get(URL_PAGE_PARAM);
|
|
3335
|
+
return page ? Math.max(1, parseInt(page, 10) || 1) : 1;
|
|
3336
|
+
}, [location.search, enableURLPagination]);
|
|
3337
|
+
const [internalPage, setInternalPage] = useState(1);
|
|
3338
|
+
const currentPage = isControlled ? controlledPage : enableURLPagination ? pageFromURL : internalPage;
|
|
3346
3339
|
const pageCount = Math.max(1, Math.ceil(totalCount / pageSize));
|
|
3347
3340
|
const onPageChange = useCallback(
|
|
3348
3341
|
(page) => {
|
|
3349
3342
|
const clampedPage = Math.min(Math.max(1, page), pageCount);
|
|
3350
|
-
if (!isControlled) {
|
|
3343
|
+
if (!isControlled && !enableURLPagination) {
|
|
3351
3344
|
setInternalPage(clampedPage);
|
|
3352
3345
|
}
|
|
3353
3346
|
controlledOnPageChange?.(clampedPage);
|
|
3354
3347
|
if (enableURLPagination) {
|
|
3355
|
-
|
|
3348
|
+
const searchParams = new URLSearchParams(history.location.search);
|
|
3349
|
+
if (clampedPage <= 1) {
|
|
3350
|
+
searchParams.delete(URL_PAGE_PARAM);
|
|
3351
|
+
} else {
|
|
3352
|
+
searchParams.set(URL_PAGE_PARAM, String(clampedPage));
|
|
3353
|
+
}
|
|
3354
|
+
history.push({ search: searchParams.toString() });
|
|
3356
3355
|
}
|
|
3357
3356
|
},
|
|
3358
|
-
[
|
|
3357
|
+
[
|
|
3358
|
+
pageCount,
|
|
3359
|
+
isControlled,
|
|
3360
|
+
controlledOnPageChange,
|
|
3361
|
+
enableURLPagination,
|
|
3362
|
+
history
|
|
3363
|
+
]
|
|
3359
3364
|
);
|
|
3360
3365
|
useEffect(() => {
|
|
3361
3366
|
if (currentPage > pageCount && pageCount > 0) {
|
|
@@ -4529,4 +4534,4 @@ const DataTable = ({
|
|
|
4529
4534
|
};
|
|
4530
4535
|
|
|
4531
4536
|
export { DataTable as D, useColumnPinning as a, useColumnVisibility as b, useTablePagination as c, useTableSelection as d, useTableSort as e, useColumnOrdering as u };
|
|
4532
|
-
//# sourceMappingURL=DataTable-
|
|
4537
|
+
//# sourceMappingURL=DataTable-C4_wD2t1.js.map
|