asma-ui-table 1.2.0 → 1.2.1
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/asma-ui-table.es.js +20 -4
- package/package.json +1 -1
package/dist/asma-ui-table.es.js
CHANGED
|
@@ -8026,13 +8026,14 @@ const useStyledTable = (props) => {
|
|
|
8026
8026
|
} = props;
|
|
8027
8027
|
const columnOrder = usePersistedColumnOrder(persistColumnOrderKey);
|
|
8028
8028
|
const persistedPageSize = usePersistedPageSize(uniqueKey);
|
|
8029
|
+
const resolvedPageSize = persistedPageSize ?? pageSize ?? 50;
|
|
8029
8030
|
const table = useReactTable({
|
|
8030
8031
|
_features: [ExpandedRowsFeature, FocusedRowsFeature, OrderColumnsFeature],
|
|
8031
8032
|
columns,
|
|
8032
8033
|
data,
|
|
8033
8034
|
meta: { locale: locale ?? "en" },
|
|
8034
8035
|
initialState: {
|
|
8035
|
-
pagination: { pageIndex: 0, pageSize:
|
|
8036
|
+
pagination: { pageIndex: 0, pageSize: resolvedPageSize },
|
|
8036
8037
|
columnVisibility: {
|
|
8037
8038
|
...initialState == null ? void 0 : initialState.columnVisibility,
|
|
8038
8039
|
[SELECT_COLUMN_ID]: false
|
|
@@ -8057,17 +8058,32 @@ const useStyledTable = (props) => {
|
|
|
8057
8058
|
tableInstanceRef.current = table;
|
|
8058
8059
|
}
|
|
8059
8060
|
usePersistColumnOrder(table, persistColumnOrderKey);
|
|
8061
|
+
const storageKey = getPersistedPageSizeKey(uniqueKey);
|
|
8060
8062
|
const pageSizeState = (_a = table.getState().pagination) == null ? void 0 : _a.pageSize;
|
|
8063
|
+
const hydratedStorageKeyRef = useRef(void 0);
|
|
8061
8064
|
useEffect(() => {
|
|
8062
|
-
|
|
8063
|
-
|
|
8065
|
+
var _a2;
|
|
8066
|
+
hydratedStorageKeyRef.current = void 0;
|
|
8067
|
+
const currentPageSize = (_a2 = table.getState().pagination) == null ? void 0 : _a2.pageSize;
|
|
8068
|
+
if (currentPageSize === resolvedPageSize)
|
|
8069
|
+
return;
|
|
8070
|
+
table.setPageIndex(0);
|
|
8071
|
+
table.setPageSize(resolvedPageSize);
|
|
8072
|
+
}, [resolvedPageSize, storageKey, table]);
|
|
8073
|
+
useEffect(() => {
|
|
8074
|
+
if (!storageKey || pageSizeState == null)
|
|
8064
8075
|
return;
|
|
8076
|
+
if (hydratedStorageKeyRef.current !== storageKey) {
|
|
8077
|
+
if (pageSizeState !== resolvedPageSize)
|
|
8078
|
+
return;
|
|
8079
|
+
hydratedStorageKeyRef.current = storageKey;
|
|
8080
|
+
}
|
|
8065
8081
|
try {
|
|
8066
8082
|
localStorage.setItem(storageKey, JSON.stringify(pageSizeState));
|
|
8067
8083
|
} catch (e) {
|
|
8068
8084
|
console.error(e);
|
|
8069
8085
|
}
|
|
8070
|
-
}, [pageSizeState,
|
|
8086
|
+
}, [pageSizeState, resolvedPageSize, storageKey]);
|
|
8071
8087
|
return { table };
|
|
8072
8088
|
};
|
|
8073
8089
|
const CheckboxWrapper = "_CheckboxWrapper_1b4zf_1";
|