nntc-ui 0.0.46 → 0.0.48
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/index.js +41 -32
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2735,6 +2735,32 @@ import { useMemo as useMemo5 } from "react";
|
|
|
2735
2735
|
var root18 = "headerDropdown_root";
|
|
2736
2736
|
var checklistWrap = "headerDropdown_checklistWrap";
|
|
2737
2737
|
|
|
2738
|
+
// src/components/view/VirtualTable/utils/alphanumericCompare.ts
|
|
2739
|
+
var alphanumericCompare = (a, b) => {
|
|
2740
|
+
const aParts = a.match(/(\d+|\D+)/g) || [];
|
|
2741
|
+
const bParts = b.match(/(\d+|\D+)/g) || [];
|
|
2742
|
+
const maxLength = Math.max(aParts.length, bParts.length);
|
|
2743
|
+
for (let i = 0; i < maxLength; i++) {
|
|
2744
|
+
const aPart = aParts[i] || "";
|
|
2745
|
+
const bPart = bParts[i] || "";
|
|
2746
|
+
const aIsNumber = /^\d+$/.test(aPart);
|
|
2747
|
+
const bIsNumber = /^\d+$/.test(bPart);
|
|
2748
|
+
if (aIsNumber && bIsNumber) {
|
|
2749
|
+
const numA = parseInt(aPart, 10);
|
|
2750
|
+
const numB = parseInt(bPart, 10);
|
|
2751
|
+
if (numA !== numB) {
|
|
2752
|
+
return numA - numB;
|
|
2753
|
+
}
|
|
2754
|
+
} else {
|
|
2755
|
+
const comparison = aPart.localeCompare(bPart);
|
|
2756
|
+
if (comparison !== 0) {
|
|
2757
|
+
return comparison;
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
return 0;
|
|
2762
|
+
};
|
|
2763
|
+
|
|
2738
2764
|
// src/components/view/VirtualTable/ui/DateFiltration/DateFiltration.tsx
|
|
2739
2765
|
import classnames19 from "classnames";
|
|
2740
2766
|
import { useEffect as useEffect7, useState as useState14 } from "react";
|
|
@@ -2923,12 +2949,21 @@ function HeaderDropdown(props) {
|
|
|
2923
2949
|
} = props;
|
|
2924
2950
|
const headerResultName = sortAnotherName ?? headerName;
|
|
2925
2951
|
const filterItems3 = useMemo5(() => {
|
|
2926
|
-
const checklistItems = items2.
|
|
2952
|
+
const checklistItems = items2.map(
|
|
2927
2953
|
(i) => ({
|
|
2928
|
-
name: valueFormat ? valueFormat(i[headerResultName].value?.toString() ?? "") : toFixed !== void 0 && !Number.isNaN(parseFloat(i[headerResultName].value)) ? parseFloat(Number(i[headerResultName].value).toFixed(toFixed)) : i[headerResultName].value,
|
|
2929
|
-
value: i[headerResultName]
|
|
2954
|
+
name: i[headerResultName] ? valueFormat ? valueFormat(i[headerResultName].value?.toString() ?? "") : toFixed !== void 0 && !Number.isNaN(parseFloat(i[headerResultName].value)) ? parseFloat(Number(i[headerResultName].value).toFixed(toFixed)) : i[headerResultName].value || "< \u043D\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F >" : "< \u043D\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F >",
|
|
2955
|
+
value: i[headerResultName]?.value || ""
|
|
2930
2956
|
})
|
|
2931
|
-
)
|
|
2957
|
+
).sort((a, b) => {
|
|
2958
|
+
const aName = a.name.toString();
|
|
2959
|
+
const bName = b.name.toString();
|
|
2960
|
+
const noValue = "< \u043D\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F >";
|
|
2961
|
+
if (aName === noValue)
|
|
2962
|
+
return -1;
|
|
2963
|
+
if (bName === noValue)
|
|
2964
|
+
return 1;
|
|
2965
|
+
return alphanumericCompare(aName, bName);
|
|
2966
|
+
});
|
|
2932
2967
|
const uniqueChecklistItems = [
|
|
2933
2968
|
...checklistItems.reduce((a, c) => {
|
|
2934
2969
|
a.set(c.value, c);
|
|
@@ -3169,39 +3204,13 @@ var recursiveFilter = (rows, filterBy) => {
|
|
|
3169
3204
|
const endDate = filterByItem.type === "dateRange" ? dayjs3(filterByItem.values[1]) : null;
|
|
3170
3205
|
const filtered = filterByItem.values.length ? rows.filter((row) => {
|
|
3171
3206
|
const dateValue = filterByItem.type === "dateRange" ? dayjs3(row[filterByItem.columnName].value) : null;
|
|
3172
|
-
return row[filterByItem.columnName]
|
|
3207
|
+
return (row[filterByItem.columnName] ? filterByItem.type === "dateRange" ? (dateValue.isAfter(startDate) || dateValue.isSame(startDate)) && (dateValue.isBefore(endDate) || dateValue.isSame(endDate)) : filterByItem.type === "numberRange" ? row[filterByItem.columnName].value >= filterByItem.values[0] && row[filterByItem.columnName].value <= filterByItem.values[1] : filterByItem.values.includes((row[filterByItem.columnName].value || "")?.toString()) : filterByItem.values.includes("")) || row.isNew?.value === 1;
|
|
3173
3208
|
}) : rows;
|
|
3174
3209
|
return recursiveFilter(filtered, filterBy.slice(0, filterBy.length - 1));
|
|
3175
3210
|
}
|
|
3176
3211
|
return rows;
|
|
3177
3212
|
};
|
|
3178
3213
|
|
|
3179
|
-
// src/components/view/VirtualTable/utils/alphanumericCompare.ts
|
|
3180
|
-
var alphanumericCompare = (a, b) => {
|
|
3181
|
-
const aParts = a.match(/(\d+|\D+)/g) || [];
|
|
3182
|
-
const bParts = b.match(/(\d+|\D+)/g) || [];
|
|
3183
|
-
const maxLength = Math.max(aParts.length, bParts.length);
|
|
3184
|
-
for (let i = 0; i < maxLength; i++) {
|
|
3185
|
-
const aPart = aParts[i] || "";
|
|
3186
|
-
const bPart = bParts[i] || "";
|
|
3187
|
-
const aIsNumber = /^\d+$/.test(aPart);
|
|
3188
|
-
const bIsNumber = /^\d+$/.test(bPart);
|
|
3189
|
-
if (aIsNumber && bIsNumber) {
|
|
3190
|
-
const numA = parseInt(aPart, 10);
|
|
3191
|
-
const numB = parseInt(bPart, 10);
|
|
3192
|
-
if (numA !== numB) {
|
|
3193
|
-
return numA - numB;
|
|
3194
|
-
}
|
|
3195
|
-
} else {
|
|
3196
|
-
const comparison = aPart.localeCompare(bPart);
|
|
3197
|
-
if (comparison !== 0) {
|
|
3198
|
-
return comparison;
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
return 0;
|
|
3203
|
-
};
|
|
3204
|
-
|
|
3205
3214
|
// src/components/view/VirtualTable/utils/recursiveSort.ts
|
|
3206
3215
|
var recursiveSort = (items2, sortBy) => {
|
|
3207
3216
|
if (sortBy.length) {
|
|
@@ -3260,7 +3269,7 @@ function VirtualTable(props) {
|
|
|
3260
3269
|
const endDate = filterByItem.type === "dateRange" ? dayjs4(filterByItem.values[1]) : null;
|
|
3261
3270
|
return rows.some((row) => {
|
|
3262
3271
|
const dateValue = filterByItem.type === "dateRange" ? dayjs4(row[filterByItem.columnName].value) : null;
|
|
3263
|
-
return row[filterByItem.columnName]
|
|
3272
|
+
return row[filterByItem.columnName] ? filterByItem.type === "dateRange" ? (dateValue.isAfter(startDate) || dateValue.isSame(startDate)) && (dateValue.isBefore(endDate) || dateValue.isSame(endDate)) : filterByItem.type === "numberRange" ? row[filterByItem.columnName].value >= filterByItem.values[0] && row[filterByItem.columnName].value <= filterByItem.values[1] : filterByItem.values.includes((row[filterByItem.columnName].value || "")?.toString()) : filterByItem.values.includes("");
|
|
3264
3273
|
});
|
|
3265
3274
|
});
|
|
3266
3275
|
const filtered = nextFilterBy.length ? recursiveFilter(newRows, nextFilterBy) : filterBy.some(
|