@megha-ui/react 1.2.641 → 1.2.642
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.
|
@@ -9,19 +9,25 @@ export const useSort = (data, columns, uniqueSearch, multiSorting, withAscii) =>
|
|
|
9
9
|
const column = columns.find((col) => col.key === key);
|
|
10
10
|
const order = orders[i] === "asc" ? 1 : -1;
|
|
11
11
|
const aValue = ((_a = a[key]) === null || _a === void 0 ? void 0 : _a.value)
|
|
12
|
-
? (column === null || column === void 0 ? void 0 : column.dataType) &&
|
|
12
|
+
? (column === null || column === void 0 ? void 0 : column.dataType) &&
|
|
13
|
+
((column === null || column === void 0 ? void 0 : column.dataType) === "number" || (column === null || column === void 0 ? void 0 : column.dataType) === "currency")
|
|
13
14
|
? parseFloat((_c = (_b = a[key]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.toString())
|
|
14
15
|
: withAscii
|
|
15
16
|
? (_e = (_d = a[key]) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.toString()
|
|
16
17
|
: (_g = (_f = a[key]) === null || _f === void 0 ? void 0 : _f.value) === null || _g === void 0 ? void 0 : _g.toString().toUpperCase()
|
|
17
|
-
: (
|
|
18
|
+
: (column === null || column === void 0 ? void 0 : column.dataType) === "number" || (column === null || column === void 0 ? void 0 : column.dataType) === "currency"
|
|
19
|
+
? 0
|
|
20
|
+
: "";
|
|
18
21
|
const bValue = ((_h = b[key]) === null || _h === void 0 ? void 0 : _h.value)
|
|
19
|
-
? (column === null || column === void 0 ? void 0 : column.dataType) &&
|
|
22
|
+
? (column === null || column === void 0 ? void 0 : column.dataType) &&
|
|
23
|
+
((column === null || column === void 0 ? void 0 : column.dataType) === "number" || (column === null || column === void 0 ? void 0 : column.dataType) === "currency")
|
|
20
24
|
? parseFloat((_k = (_j = b[key]) === null || _j === void 0 ? void 0 : _j.value) === null || _k === void 0 ? void 0 : _k.toString())
|
|
21
25
|
: withAscii
|
|
22
26
|
? (_m = (_l = b[key]) === null || _l === void 0 ? void 0 : _l.value) === null || _m === void 0 ? void 0 : _m.toString()
|
|
23
27
|
: (_p = (_o = b[key]) === null || _o === void 0 ? void 0 : _o.value) === null || _p === void 0 ? void 0 : _p.toString().toUpperCase()
|
|
24
|
-
: (
|
|
28
|
+
: (column === null || column === void 0 ? void 0 : column.dataType) === "number" || (column === null || column === void 0 ? void 0 : column.dataType) === "currency"
|
|
29
|
+
? 0
|
|
30
|
+
: "";
|
|
25
31
|
if (aValue < bValue)
|
|
26
32
|
return -1 * order;
|
|
27
33
|
if (aValue > bValue)
|
|
@@ -35,10 +41,17 @@ export const useSort = (data, columns, uniqueSearch, multiSorting, withAscii) =>
|
|
|
35
41
|
let returnData = [...data];
|
|
36
42
|
const _sortQueries = sortQueries;
|
|
37
43
|
returnData = returnData.sort(hierarchicalSort(Object.keys(_sortQueries), Object.values(_sortQueries)));
|
|
44
|
+
const gridKeyWithUniqData = keys.reduce((acc, key) => {
|
|
45
|
+
const gridKeyData = returnData.map((item) => item[key].value);
|
|
46
|
+
acc[key] = uniqueSearch[key].length > 0 && !(gridKeyData === null || gridKeyData === void 0 ? void 0 : gridKeyData.every((item) => uniqueSearch.includes(item)));
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
38
49
|
returnData = returnData.filter((data) => {
|
|
39
50
|
return keys.every((key) => {
|
|
40
|
-
if (
|
|
41
|
-
return uniqueSearch[key]
|
|
51
|
+
if (gridKeyWithUniqData[key]) {
|
|
52
|
+
return uniqueSearch[key]
|
|
53
|
+
.map((item) => item.toString())
|
|
54
|
+
.includes(data[key] ? data[key].value.toString() : "");
|
|
42
55
|
}
|
|
43
56
|
return false;
|
|
44
57
|
});
|
package/package.json
CHANGED