@datawheel/data-explorer 0.2.9 → 0.2.10
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/main.js +23 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1265,6 +1265,10 @@ var queriesSlice = createSlice({
|
|
|
1265
1265
|
query.params.sortDir = payload.dir;
|
|
1266
1266
|
query.params.sortKey = payload.key;
|
|
1267
1267
|
},
|
|
1268
|
+
clearSorting(state) {
|
|
1269
|
+
const query = taintCurrentQuery(state);
|
|
1270
|
+
query.params.sortKey = void 0;
|
|
1271
|
+
},
|
|
1268
1272
|
/**
|
|
1269
1273
|
* Registers the result of the current QueryItem in the store.
|
|
1270
1274
|
*/
|
|
@@ -1334,7 +1338,7 @@ var selectPaginationParams = createSelector(selectCurrentQueryParams, (params) =
|
|
|
1334
1338
|
limit: params.pagiLimit || 0,
|
|
1335
1339
|
offset: params.pagiOffset || 0
|
|
1336
1340
|
}));
|
|
1337
|
-
createSelector(selectCurrentQueryParams, (params) => ({
|
|
1341
|
+
var selectSortingParams = createSelector(selectCurrentQueryParams, (params) => ({
|
|
1338
1342
|
sortKey: params.sortKey || "",
|
|
1339
1343
|
sortDir: params.sortDir
|
|
1340
1344
|
}));
|
|
@@ -2797,6 +2801,9 @@ function FullScreenSVG() {
|
|
|
2797
2801
|
}
|
|
2798
2802
|
|
|
2799
2803
|
// src/components/TableView.tsx
|
|
2804
|
+
function isColumnSorted(column, key) {
|
|
2805
|
+
return column == key;
|
|
2806
|
+
}
|
|
2800
2807
|
var removeColumn = (actions2, entity, measures, drilldowns) => {
|
|
2801
2808
|
if ("aggregator" in entity) {
|
|
2802
2809
|
const measure = measures.find((d) => d.name === entity.name);
|
|
@@ -3026,6 +3033,7 @@ function useTable({
|
|
|
3026
3033
|
const { currentFormats, getAvailableKeys, getFormatter, getFormatterKey, setFormat } = useFormatter(
|
|
3027
3034
|
cube.measures
|
|
3028
3035
|
);
|
|
3036
|
+
const { sortKey, sortDir } = useSelector$1(selectSortingParams);
|
|
3029
3037
|
const columns = useMemo(() => {
|
|
3030
3038
|
const indexColumn = {
|
|
3031
3039
|
id: "#",
|
|
@@ -3066,15 +3074,26 @@ function useTable({
|
|
|
3066
3074
|
return 0;
|
|
3067
3075
|
},
|
|
3068
3076
|
Header: ({ column: column2 }) => {
|
|
3077
|
+
const isSorted = isColumnSorted(entity.name, sortKey);
|
|
3069
3078
|
return /* @__PURE__ */ React13__default.createElement(Box, { mb: rem(5), key: "header" }, /* @__PURE__ */ React13__default.createElement(Flex, { justify: "center", align: "center" }, /* @__PURE__ */ React13__default.createElement(Box, { sx: { flexGrow: 1 } }, /* @__PURE__ */ React13__default.createElement(Flex, { gap: "xs", align: "center" }, getActionIcon(entityType), /* @__PURE__ */ React13__default.createElement(Text, { size: "sm" }, header), /* @__PURE__ */ React13__default.createElement(
|
|
3070
3079
|
ActionIcon,
|
|
3071
3080
|
{
|
|
3072
3081
|
key: `sort-${header}`,
|
|
3073
3082
|
size: 22,
|
|
3074
3083
|
ml: rem(5),
|
|
3075
|
-
onClick:
|
|
3084
|
+
onClick: () => {
|
|
3085
|
+
if (!isSorted) {
|
|
3086
|
+
actions2.updateSorting({ key: entity.name, dir: "desc" });
|
|
3087
|
+
}
|
|
3088
|
+
if (isSorted && sortDir === "desc") {
|
|
3089
|
+
actions2.updateSorting({ key: entity.name, dir: "asc" });
|
|
3090
|
+
}
|
|
3091
|
+
if (isSorted && sortDir === "asc") {
|
|
3092
|
+
actions2.clearSorting();
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3076
3095
|
},
|
|
3077
|
-
getSortIcon(
|
|
3096
|
+
getSortIcon(isSorted ? sortDir : false, entityType)
|
|
3078
3097
|
))), /* @__PURE__ */ React13__default.createElement(
|
|
3079
3098
|
CustomActionIcon_default,
|
|
3080
3099
|
{
|
|
@@ -3197,7 +3216,7 @@ function useTable({
|
|
|
3197
3216
|
enableHiding: false,
|
|
3198
3217
|
manualFiltering: true,
|
|
3199
3218
|
manualPagination: true,
|
|
3200
|
-
manualSorting:
|
|
3219
|
+
manualSorting: true,
|
|
3201
3220
|
rowCount: totalRowCount,
|
|
3202
3221
|
state: {
|
|
3203
3222
|
isLoading: isLoading || data === void 0 || isTransitionState,
|