@megha-ui/react 1.2.370 → 1.2.371

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.
@@ -15,7 +15,7 @@ import { MdFilterAltOff, MdGroupOff, MdSave } from "react-icons/md";
15
15
  import SummariseDetails from "./utils/SummariseDetails";
16
16
  import GlobalSearchChiProps from "./utils/globalSearchChips";
17
17
  import GroupedGridDetails from "./utils/groupedGridDetails";
18
- import { MdFullscreen, MdFullscreenExit, } from "react-icons/md";
18
+ import { MdFullscreen, MdFullscreenExit } from "react-icons/md";
19
19
  import Dropdown from "../dropdown";
20
20
  import Loader from "../loader";
21
21
  import Button from "../button";
@@ -367,14 +367,18 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
367
367
  const columnLevelTokens = groupedColumns
368
368
  ? groupedColumns.split(">").filter(Boolean)
369
369
  : [];
370
- const expandedColumnTokens = columnLevelTokens
371
- .flatMap((tok) => tok.split("+").map((s) => s.trim()).filter(Boolean));
370
+ const expandedColumnTokens = columnLevelTokens.flatMap((tok) => tok
371
+ .split("+")
372
+ .map((s) => s.trim())
373
+ .filter(Boolean));
372
374
  // Values are always flattened and separated by '>'
373
375
  const filterTokens = filterValue
374
376
  ? filterValue.split(">").filter(Boolean)
375
377
  : [];
376
- const expandedValueTokens = filterTokens
377
- .flatMap((tok) => tok.split("+").map((s) => s.trim()).filter(Boolean));
378
+ const expandedValueTokens = filterTokens.flatMap((tok) => tok
379
+ .split("+")
380
+ .map((s) => s.trim())
381
+ .filter(Boolean));
378
382
  const filteredValues = filteredData
379
383
  .filter((row) => {
380
384
  var _a, _b, _c, _d;
@@ -1205,6 +1209,23 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
1205
1209
  .filter((item) => item !== chip)
1206
1210
  .join(","));
1207
1211
  };
1212
+ const comparator = (a, b, type, order) => {
1213
+ const isNumeric = type === "currency" || typeof a === "number" || typeof b === "number";
1214
+ let cmp = 0;
1215
+ if (isNumeric) {
1216
+ const an = a == null || a === "" ? Number.NEGATIVE_INFINITY : Number(a);
1217
+ const bn = b == null || b === "" ? Number.NEGATIVE_INFINITY : Number(b);
1218
+ cmp = an === bn ? 0 : an < bn ? -1 : 1;
1219
+ }
1220
+ else {
1221
+ const as = a == null ? "" : String(a).toLowerCase();
1222
+ const bs = b == null ? "" : String(b).toLowerCase();
1223
+ cmp = as.localeCompare(bs);
1224
+ }
1225
+ if (cmp !== 0)
1226
+ return order === "asc" ? cmp : -cmp;
1227
+ return 0;
1228
+ };
1208
1229
  // const handleReset = () => {
1209
1230
  // const popped = changed[changed.length - 1];
1210
1231
  // setChanged((prev) => prev.filter((item) => item !== popped));
@@ -1398,7 +1419,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
1398
1419
  ? (_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()
1399
1420
  : "";
1400
1421
  }),
1401
- ];
1422
+ ].sort((a, b) => { var _a, _b; return comparator(a, b, (_a = column.dataType) !== null && _a !== void 0 ? _a : "", (_b = column.fixedFilterOrder) !== null && _b !== void 0 ? _b : "asc"); });
1402
1423
  selectedValues.forEach((item) => {
1403
1424
  if (!options.includes(item)) {
1404
1425
  options.push(item);
@@ -1434,7 +1455,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
1434
1455
  updateFixedFilterValues(updatedValues);
1435
1456
  }
1436
1457
  }
1437
- : undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 mt-2", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
1458
+ : undefined, isSort: column.fixedFilterOrder ? false : undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 mt-2", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
1438
1459
  }
1439
1460
  return null;
1440
1461
  }) }), _jsxs("div", { style: {
@@ -5,6 +5,7 @@ export interface Column {
5
5
  hidden?: any;
6
6
  fixed?: boolean;
7
7
  fixedFilter?: string;
8
+ fixedFilterOrder?: "asc" | "desc";
8
9
  freeze?: boolean;
9
10
  overflowHidden?: boolean;
10
11
  searchType?: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.370",
3
+ "version": "1.2.371",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",