nntc-ui 0.0.38 → 0.0.40
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.d.ts +5 -1
- package/index.js +33 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -266,6 +266,8 @@ interface FilterBy {
|
|
|
266
266
|
|
|
267
267
|
type ColumnAlign = 'Left' | 'Right' | 'Center';
|
|
268
268
|
|
|
269
|
+
type SortType = 'alphanumeric' | 'locale';
|
|
270
|
+
|
|
269
271
|
type VerticalAlign = 'FlexStart' | 'Center' | 'FlexEnd';
|
|
270
272
|
|
|
271
273
|
interface TableColumn {
|
|
@@ -275,6 +277,7 @@ interface TableColumn {
|
|
|
275
277
|
columns?: TableColumn[];
|
|
276
278
|
editable?: boolean;
|
|
277
279
|
sortable?: boolean;
|
|
280
|
+
sortType?: SortType;
|
|
278
281
|
sortAnotherName?: string;
|
|
279
282
|
filtrationByNumber?: boolean;
|
|
280
283
|
filtrationByDate?: boolean;
|
|
@@ -321,6 +324,7 @@ declare function VirtualTable(props: UiProps<Props$7>): react_jsx_runtime.JSX.El
|
|
|
321
324
|
interface SortBy {
|
|
322
325
|
columnName: string;
|
|
323
326
|
direction: 'asc' | 'desc';
|
|
327
|
+
sortType?: SortType;
|
|
324
328
|
}
|
|
325
329
|
|
|
326
330
|
interface Item {
|
|
@@ -402,4 +406,4 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<PropsWithChildren<Prop
|
|
|
402
406
|
classes?: PropsObject;
|
|
403
407
|
} & HTMLProps<HTMLDivElement>>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
404
408
|
|
|
405
|
-
export { type AdditionalButton, Button, ButtonsGroup, Card, Checkbox, Checklist, type Item$3 as ChecklistItem, type SelectedItems as ChecklistSelectedItems, ColorPicker, type ColumnAlign, DateTime, type FilterBy, Input, Layout, Menu, type Divider as MenuDivider, type Item$2 as MenuItem, Modal, MultiSelect, type Item$4 as MultiSelectItem, type TitleVariant as MultiSelectTitleVariant, type Pair, Pairs, Popover, SearchInput, Select, type Divider$1 as SelectDivider, type Item$5 as SelectItem, type SortBy, Surface, type TableCell, type TableColumn, type TableRow, Tabs, type Item$1 as TabsItem, Tooltip, _default as TreeView, type Item as TreeViewItem, Typography, type VerticalAlign, VirtualTable, WrapForLabel };
|
|
409
|
+
export { type AdditionalButton, Button, ButtonsGroup, Card, Checkbox, Checklist, type Item$3 as ChecklistItem, type SelectedItems as ChecklistSelectedItems, ColorPicker, type ColumnAlign, DateTime, type FilterBy, Input, Layout, Menu, type Divider as MenuDivider, type Item$2 as MenuItem, Modal, MultiSelect, type Item$4 as MultiSelectItem, type TitleVariant as MultiSelectTitleVariant, type Pair, Pairs, Popover, SearchInput, Select, type Divider$1 as SelectDivider, type Item$5 as SelectItem, type SortBy, type SortType, Surface, type TableCell, type TableColumn, type TableRow, Tabs, type Item$1 as TabsItem, Tooltip, _default as TreeView, type Item as TreeViewItem, Typography, type VerticalAlign, VirtualTable, WrapForLabel };
|
package/index.js
CHANGED
|
@@ -2901,6 +2901,7 @@ function HeaderDropdown(props) {
|
|
|
2901
2901
|
const {
|
|
2902
2902
|
headerMeta: {
|
|
2903
2903
|
sortable = false,
|
|
2904
|
+
sortType,
|
|
2904
2905
|
sortAnotherName,
|
|
2905
2906
|
filtrationByNumber = false,
|
|
2906
2907
|
filtrationByDate = false,
|
|
@@ -2955,7 +2956,7 @@ function HeaderDropdown(props) {
|
|
|
2955
2956
|
if (prev.some((p) => p.columnName === headerResultName)) {
|
|
2956
2957
|
return prev.map((p) => p.columnName === headerResultName ? { ...p, direction } : { ...p });
|
|
2957
2958
|
} else {
|
|
2958
|
-
return prev.concat([{ columnName: headerResultName, direction }]);
|
|
2959
|
+
return prev.concat([{ columnName: headerResultName, direction, sortType }]);
|
|
2959
2960
|
}
|
|
2960
2961
|
}
|
|
2961
2962
|
});
|
|
@@ -3084,6 +3085,7 @@ var createMeta = (column) => {
|
|
|
3084
3085
|
return {
|
|
3085
3086
|
editable: column.editable,
|
|
3086
3087
|
sortable: column.sortable,
|
|
3088
|
+
sortType: column.sortType,
|
|
3087
3089
|
sortAnotherName: column.sortAnotherName,
|
|
3088
3090
|
filtrationByNumber: column.filtrationByNumber,
|
|
3089
3091
|
filtrationByDate: column.filtrationByDate,
|
|
@@ -3163,6 +3165,32 @@ var recursiveFilter = (rows, filterBy) => {
|
|
|
3163
3165
|
return rows;
|
|
3164
3166
|
};
|
|
3165
3167
|
|
|
3168
|
+
// src/components/view/VirtualTable/utils/alphanumericCompare.ts
|
|
3169
|
+
var alphanumericCompare = (a, b) => {
|
|
3170
|
+
const aParts = a.match(/(\d+|\D+)/g) || [];
|
|
3171
|
+
const bParts = b.match(/(\d+|\D+)/g) || [];
|
|
3172
|
+
const maxLength = Math.max(aParts.length, bParts.length);
|
|
3173
|
+
for (let i = 0; i < maxLength; i++) {
|
|
3174
|
+
const aPart = aParts[i] || "";
|
|
3175
|
+
const bPart = bParts[i] || "";
|
|
3176
|
+
const aIsNumber = /^\d+$/.test(aPart);
|
|
3177
|
+
const bIsNumber = /^\d+$/.test(bPart);
|
|
3178
|
+
if (aIsNumber && bIsNumber) {
|
|
3179
|
+
const numA = parseInt(aPart, 10);
|
|
3180
|
+
const numB = parseInt(bPart, 10);
|
|
3181
|
+
if (numA !== numB) {
|
|
3182
|
+
return numA - numB;
|
|
3183
|
+
}
|
|
3184
|
+
} else {
|
|
3185
|
+
const comparison = aPart.localeCompare(bPart);
|
|
3186
|
+
if (comparison !== 0) {
|
|
3187
|
+
return comparison;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
return 0;
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3166
3194
|
// src/components/view/VirtualTable/utils/recursiveSort.ts
|
|
3167
3195
|
var recursiveSort = (items2, sortBy) => {
|
|
3168
3196
|
if (sortBy.length) {
|
|
@@ -3170,6 +3198,10 @@ var recursiveSort = (items2, sortBy) => {
|
|
|
3170
3198
|
const sorted = items2.sort((a, b) => {
|
|
3171
3199
|
const aValue = a[sortByItem.columnName]?.value?.toString() ?? "";
|
|
3172
3200
|
const bValue = b[sortByItem.columnName]?.value?.toString() ?? "";
|
|
3201
|
+
if (sortByItem.sortType === "alphanumeric") {
|
|
3202
|
+
const compare2 = alphanumericCompare(aValue, bValue);
|
|
3203
|
+
return sortByItem.direction === "asc" ? compare2 : -compare2;
|
|
3204
|
+
}
|
|
3173
3205
|
const compare = aValue.localeCompare(bValue);
|
|
3174
3206
|
return sortByItem.direction === "asc" ? compare : -compare;
|
|
3175
3207
|
});
|