@bigbinary/neeto-atoms 1.0.121 → 1.0.122
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-BNhOcmQ8.js → DataTable-DI4qPCmM.js} +36 -30
- package/dist/DataTable-DI4qPCmM.js.map +1 -0
- package/dist/cjs/{DataTable-CzMzW8tr.js → DataTable-Cu5Gon12.js} +35 -29
- package/dist/cjs/DataTable-Cu5Gon12.js.map +1 -0
- package/dist/cjs/components/DataTable.js +1 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/components/DataTable/utils.d.ts +2 -3
- package/dist/components/DataTable.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/DataTable-BNhOcmQ8.js.map +0 -1
- package/dist/cjs/DataTable-CzMzW8tr.js.map +0 -1
|
@@ -3182,28 +3182,26 @@ const STORAGE_KEY_PREFIX = "NEETOUI";
|
|
|
3182
3182
|
const STORAGE_KEY_SUFFIX = "FIXED_COLUMNS";
|
|
3183
3183
|
const COLUMN_SIZING_STORAGE_KEY_SUFFIX = "COLUMN_SIZING";
|
|
3184
3184
|
|
|
3185
|
-
const
|
|
3186
|
-
const
|
|
3187
|
-
const params = getSearchParams();
|
|
3185
|
+
const readSortFromURL = (search) => {
|
|
3186
|
+
const params = new URLSearchParams(search);
|
|
3188
3187
|
const sortBy = params.get(URL_SORT_PARAMS.SORT_BY);
|
|
3189
3188
|
const orderBy = params.get(URL_SORT_PARAMS.ORDER_BY);
|
|
3190
|
-
|
|
3191
|
-
return [{ id: sortBy, desc: orderBy === SORT_DIRECTIONS.DESC }];
|
|
3189
|
+
return sortBy ? [{ id: sortBy, desc: orderBy === SORT_DIRECTIONS.DESC }] : [];
|
|
3192
3190
|
};
|
|
3193
|
-
const
|
|
3194
|
-
const
|
|
3191
|
+
const buildSortQuery = (search, sorting) => {
|
|
3192
|
+
const searchParams = new URLSearchParams(search);
|
|
3195
3193
|
if (sorting.length === 0) {
|
|
3196
|
-
|
|
3197
|
-
|
|
3194
|
+
searchParams.delete(URL_SORT_PARAMS.SORT_BY);
|
|
3195
|
+
searchParams.delete(URL_SORT_PARAMS.ORDER_BY);
|
|
3198
3196
|
} else {
|
|
3199
3197
|
const { id, desc } = sorting[0];
|
|
3200
|
-
|
|
3201
|
-
|
|
3198
|
+
searchParams.set(URL_SORT_PARAMS.SORT_BY, id);
|
|
3199
|
+
searchParams.set(
|
|
3202
3200
|
URL_SORT_PARAMS.ORDER_BY,
|
|
3203
3201
|
desc ? SORT_DIRECTIONS.DESC : SORT_DIRECTIONS.ASC
|
|
3204
3202
|
);
|
|
3205
3203
|
}
|
|
3206
|
-
|
|
3204
|
+
return searchParams.toString();
|
|
3207
3205
|
};
|
|
3208
3206
|
const keysToRowSelection = (keys) => Object.fromEntries(keys.map((key) => [key, true]));
|
|
3209
3207
|
const rowSelectionToKeys = (selection) => Object.keys(selection).filter((key) => selection[key]);
|
|
@@ -3303,17 +3301,22 @@ const useTableSort = ({
|
|
|
3303
3301
|
sorting: controlledSorting,
|
|
3304
3302
|
onSortingChange: controlledOnSortingChange,
|
|
3305
3303
|
onSort,
|
|
3306
|
-
enableURLSort
|
|
3304
|
+
enableURLSort
|
|
3307
3305
|
}) => {
|
|
3308
3306
|
const isControlled = controlledSorting !== void 0;
|
|
3309
|
-
const
|
|
3310
|
-
|
|
3311
|
-
);
|
|
3312
|
-
const
|
|
3307
|
+
const isURLSortEnabled = enableURLSort ?? (!isControlled && controlledOnSortingChange === void 0 && !onSort);
|
|
3308
|
+
const history = reactRouterDom.useHistory();
|
|
3309
|
+
const location = reactRouterDom.useLocation();
|
|
3310
|
+
const sortingFromURL = React.useMemo(() => {
|
|
3311
|
+
if (!isURLSortEnabled) return [];
|
|
3312
|
+
return readSortFromURL(location.search);
|
|
3313
|
+
}, [location.search, isURLSortEnabled]);
|
|
3314
|
+
const [internalSorting, setInternalSorting] = React.useState([]);
|
|
3315
|
+
const sorting = isControlled ? controlledSorting : isURLSortEnabled ? sortingFromURL : internalSorting;
|
|
3313
3316
|
const onSortingChange = React.useCallback(
|
|
3314
3317
|
(updaterOrValue) => {
|
|
3315
3318
|
const newSorting = typeof updaterOrValue === "function" ? updaterOrValue(sorting) : updaterOrValue;
|
|
3316
|
-
if (!isControlled) {
|
|
3319
|
+
if (!isControlled && !isURLSortEnabled) {
|
|
3317
3320
|
setInternalSorting(newSorting);
|
|
3318
3321
|
}
|
|
3319
3322
|
controlledOnSortingChange?.(updaterOrValue);
|
|
@@ -3325,18 +3328,21 @@ const useTableSort = ({
|
|
|
3325
3328
|
} : null
|
|
3326
3329
|
);
|
|
3327
3330
|
}
|
|
3328
|
-
if (
|
|
3329
|
-
|
|
3331
|
+
if (isURLSortEnabled) {
|
|
3332
|
+
history.push({
|
|
3333
|
+
search: buildSortQuery(history.location.search, newSorting)
|
|
3334
|
+
});
|
|
3330
3335
|
}
|
|
3331
3336
|
},
|
|
3332
|
-
[
|
|
3337
|
+
[
|
|
3338
|
+
sorting,
|
|
3339
|
+
isControlled,
|
|
3340
|
+
controlledOnSortingChange,
|
|
3341
|
+
onSort,
|
|
3342
|
+
isURLSortEnabled,
|
|
3343
|
+
history
|
|
3344
|
+
]
|
|
3333
3345
|
);
|
|
3334
|
-
React.useEffect(() => {
|
|
3335
|
-
if (enableURLSort && !isControlled) {
|
|
3336
|
-
const urlSorting = readSortFromURL();
|
|
3337
|
-
setInternalSorting(urlSorting);
|
|
3338
|
-
}
|
|
3339
|
-
}, [enableURLSort, isControlled]);
|
|
3340
3346
|
return { sorting, onSortingChange };
|
|
3341
3347
|
};
|
|
3342
3348
|
|
|
@@ -4171,7 +4177,7 @@ const DataTable = ({
|
|
|
4171
4177
|
onSortingChange: onSortingChangeProp,
|
|
4172
4178
|
onSort: onSortProp,
|
|
4173
4179
|
enableSorting = false,
|
|
4174
|
-
enableURLSort
|
|
4180
|
+
enableURLSort,
|
|
4175
4181
|
totalCount,
|
|
4176
4182
|
pageSize = DEFAULT_PAGE_SIZE,
|
|
4177
4183
|
currentPage: currentPageProp,
|
|
@@ -4627,4 +4633,4 @@ exports.useColumnVisibility = useColumnVisibility;
|
|
|
4627
4633
|
exports.useTablePagination = useTablePagination;
|
|
4628
4634
|
exports.useTableSelection = useTableSelection;
|
|
4629
4635
|
exports.useTableSort = useTableSort;
|
|
4630
|
-
//# sourceMappingURL=DataTable-
|
|
4636
|
+
//# sourceMappingURL=DataTable-Cu5Gon12.js.map
|