@synerise/ds-table 1.9.10 → 1.9.12
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/CHANGELOG.md +8 -0
- package/README.md +9 -10
- package/dist/Cell/Action/ActionCell.d.ts +2 -2
- package/dist/Cell/Action/ActionCell.js +15 -18
- package/dist/Cell/Action/ActionCell.styles.d.ts +2 -2
- package/dist/Cell/Action/ActionCell.styles.js +10 -11
- package/dist/Cell/Action/ActionCell.types.d.ts +2 -2
- package/dist/Cell/Action/ActionCell.types.js +1 -1
- package/dist/Cell/AvatarLabel/AvatarLabel.d.ts +2 -2
- package/dist/Cell/AvatarLabel/AvatarLabel.js +32 -43
- package/dist/Cell/AvatarLabel/AvatarLabel.styles.d.ts +13 -13
- package/dist/Cell/AvatarLabel/AvatarLabel.styles.js +27 -28
- package/dist/Cell/AvatarLabel/AvatarLabel.types.d.ts +2 -2
- package/dist/Cell/AvatarLabel/AvatarLabel.types.js +1 -1
- package/dist/Cell/Copyable/Copyable.styles.d.ts +2 -2
- package/dist/Cell/Copyable/Copyable.styles.js +9 -15
- package/dist/Cell/Copyable/Copyable.types.d.ts +1 -1
- package/dist/Cell/Copyable/Copyable.types.js +1 -1
- package/dist/Cell/Copyable/CopyableCell.d.ts +2 -2
- package/dist/Cell/Copyable/CopyableCell.js +23 -27
- package/dist/Cell/Editable/EditableCell.d.ts +2 -2
- package/dist/Cell/Editable/EditableCell.js +26 -39
- package/dist/Cell/Editable/EditableCell.styles.d.ts +2 -2
- package/dist/Cell/Editable/EditableCell.styles.js +9 -7
- package/dist/Cell/Editable/EditableCell.types.d.ts +1 -1
- package/dist/Cell/Editable/EditableCell.types.js +1 -1
- package/dist/Cell/FlagLabel/FlagLabelCell.d.ts +2 -2
- package/dist/Cell/FlagLabel/FlagLabelCell.js +15 -14
- package/dist/Cell/FlagLabel/FlagLabelCell.styles.d.ts +1 -1
- package/dist/Cell/FlagLabel/FlagLabelCell.styles.js +6 -3
- package/dist/Cell/FlagLabel/FlagLabelCell.types.d.ts +2 -2
- package/dist/Cell/FlagLabel/FlagLabelCell.types.js +1 -1
- package/dist/Cell/IconLabel/IconLabel.d.ts +2 -2
- package/dist/Cell/IconLabel/IconLabel.js +14 -15
- package/dist/Cell/IconLabel/IconLabel.styles.d.ts +1 -1
- package/dist/Cell/IconLabel/IconLabel.styles.js +7 -6
- package/dist/Cell/IconLabel/IconLabel.types.d.ts +3 -3
- package/dist/Cell/IconLabel/IconLabel.types.js +1 -1
- package/dist/Cell/IconTooltipCell/IconTooltipCell.d.ts +2 -2
- package/dist/Cell/IconTooltipCell/IconTooltipCell.js +18 -23
- package/dist/Cell/IconTooltipCell/IconTooltipCell.styles.d.ts +2 -2
- package/dist/Cell/IconTooltipCell/IconTooltipCell.styles.js +9 -11
- package/dist/Cell/IconTooltipCell/IconTooltipCell.types.d.ts +4 -4
- package/dist/Cell/IconTooltipCell/IconTooltipCell.types.js +1 -1
- package/dist/Cell/InputNumber/InputNumberCell.d.ts +2 -2
- package/dist/Cell/InputNumber/InputNumberCell.js +10 -17
- package/dist/Cell/InputNumber/InputNumberCell.styles.d.ts +1 -1
- package/dist/Cell/InputNumber/InputNumberCell.styles.js +9 -5
- package/dist/Cell/InputNumber/InputNumberCell.types.d.ts +2 -2
- package/dist/Cell/InputNumber/InputNumberCell.types.js +1 -1
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.d.ts +3 -3
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.js +29 -40
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.styles.d.ts +3 -3
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.styles.js +11 -8
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.types.d.ts +2 -2
- package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.types.js +1 -1
- package/dist/Cell/LabelsWithShowMore/Modal/Modal.d.ts +2 -2
- package/dist/Cell/LabelsWithShowMore/Modal/Modal.js +35 -64
- package/dist/Cell/LabelsWithShowMore/Modal/Modal.types.d.ts +3 -3
- package/dist/Cell/LabelsWithShowMore/Modal/Modal.types.js +1 -1
- package/dist/Cell/Star/StarCell.d.ts +45 -45
- package/dist/Cell/Star/StarCell.js +25 -31
- package/dist/Cell/Star/StarCell.styles.d.ts +2 -2
- package/dist/Cell/Star/StarCell.styles.js +11 -9
- package/dist/Cell/Star/StarCell.types.d.ts +2 -2
- package/dist/Cell/Star/StarCell.types.js +1 -1
- package/dist/Cell/StatusLabel/StatusLabel.d.ts +2 -2
- package/dist/Cell/StatusLabel/StatusLabel.js +17 -19
- package/dist/Cell/StatusLabel/StatusLabel.styles.d.ts +2 -2
- package/dist/Cell/StatusLabel/StatusLabel.styles.js +9 -9
- package/dist/Cell/StatusLabel/StatusLabel.types.d.ts +3 -3
- package/dist/Cell/StatusLabel/StatusLabel.types.js +1 -1
- package/dist/Cell/TagIcon/TagIcon.d.ts +2 -2
- package/dist/Cell/TagIcon/TagIcon.js +9 -13
- package/dist/Cell/TagIcon/TagIcon.styles.d.ts +1 -1
- package/dist/Cell/TagIcon/TagIcon.styles.js +7 -6
- package/dist/Cell/TagIcon/TagIcon.types.d.ts +2 -2
- package/dist/Cell/TagIcon/TagIcon.types.js +1 -1
- package/dist/Cell/TagsGroup/TagsGroup.d.ts +2 -2
- package/dist/Cell/TagsGroup/TagsGroup.js +22 -39
- package/dist/Cell/TagsGroup/TagsGroup.styles.d.ts +2 -2
- package/dist/Cell/TagsGroup/TagsGroup.styles.js +30 -9
- package/dist/Cell/TagsGroup/TagsGroup.types.d.ts +2 -2
- package/dist/Cell/TagsGroup/TagsGroup.types.js +1 -1
- package/dist/Cell/index.d.ts +12 -12
- package/dist/Cell/index.js +28 -14
- package/dist/ColumnSortMenu/SortIcons.d.ts +2 -2
- package/dist/ColumnSortMenu/SortIcons.js +26 -38
- package/dist/ColumnSortMenu/SortRender.styles.d.ts +34 -34
- package/dist/ColumnSortMenu/SortRender.styles.js +13 -10
- package/dist/ColumnSortMenu/SortRenderer.d.ts +2 -2
- package/dist/ColumnSortMenu/SortRenderer.js +74 -108
- package/dist/ColumnSortMenu/TitleWithSort.d.ts +2 -2
- package/dist/ColumnSortMenu/TitleWithSort.js +19 -16
- package/dist/ColumnSortMenu/columnWithSortButtons.d.ts +1 -2
- package/dist/ColumnSortMenu/columnWithSortButtons.js +26 -43
- package/dist/ColumnSortMenu/groupedColumnsSort.d.ts +3 -3
- package/dist/ColumnSortMenu/groupedColumnsSort.js +33 -28
- package/dist/ColumnSortMenu/replaceSortButtons.d.ts +1 -1
- package/dist/ColumnSortMenu/replaceSortButtons.js +14 -15
- package/dist/ColumnSortMenu/useSortState.d.ts +1 -1
- package/dist/ColumnSortMenu/useSortState.js +95 -93
- package/dist/DefaultTable/DefaultTable.d.ts +2 -2
- package/dist/DefaultTable/DefaultTable.js +147 -148
- package/dist/FilterTrigger/FilterTrigger.d.ts +2 -2
- package/dist/FilterTrigger/FilterTrigger.js +42 -67
- package/dist/FilterTrigger/FilterTrigger.styles.d.ts +53 -53
- package/dist/FilterTrigger/FilterTrigger.styles.js +19 -32
- package/dist/FilterTrigger/FilterTrigger.types.d.ts +1 -1
- package/dist/FilterTrigger/FilterTrigger.types.js +1 -1
- package/dist/GroupTable/GroupTable.d.ts +3 -4
- package/dist/GroupTable/GroupTable.js +97 -118
- package/dist/GroupTable/GroupTable.styles.d.ts +25 -25
- package/dist/GroupTable/GroupTable.styles.js +40 -37
- package/dist/GroupTable/GroupTable.types.d.ts +1 -1
- package/dist/GroupTable/GroupTable.types.js +9 -6
- package/dist/GroupTable/GroupTableBody/GroupTableBody.d.ts +1 -1
- package/dist/GroupTable/GroupTableBody/GroupTableBody.js +83 -107
- package/dist/GroupTable/GroupTableBody/GroupTableBody.types.d.ts +3 -3
- package/dist/GroupTable/GroupTableBody/GroupTableBody.types.js +1 -1
- package/dist/GroupTable/GroupTableHeader/GroupTableHeader.d.ts +1 -1
- package/dist/GroupTable/GroupTableHeader/GroupTableHeader.js +25 -28
- package/dist/GroupTable/GroupTableHeader/GroupTableHeader.types.js +1 -1
- package/dist/InfiniteScroll/BackToTopButton.d.ts +2 -2
- package/dist/InfiniteScroll/BackToTopButton.js +7 -15
- package/dist/InfiniteScroll/BackToTopButton.styles.d.ts +34 -34
- package/dist/InfiniteScroll/BackToTopButton.styles.js +11 -9
- package/dist/InfiniteScroll/ErrorItem.d.ts +1 -1
- package/dist/InfiniteScroll/ErrorItem.js +19 -23
- package/dist/InfiniteScroll/ErrorItem.styles.d.ts +1 -1
- package/dist/InfiniteScroll/ErrorItem.styles.js +6 -3
- package/dist/InfiniteScroll/InfiniteLoaderItem.d.ts +2 -2
- package/dist/InfiniteScroll/InfiniteLoaderItem.js +33 -28
- package/dist/InfiniteScroll/InfiniteLoaderItem.styles.d.ts +1 -1
- package/dist/InfiniteScroll/InfiniteLoaderItem.styles.js +7 -4
- package/dist/InfiniteScroll/InfiniteLoaderItem.types.d.ts +1 -1
- package/dist/InfiniteScroll/InfiniteLoaderItem.types.js +1 -1
- package/dist/InfiniteScroll/LoadingItem.d.ts +1 -1
- package/dist/InfiniteScroll/LoadingItem.js +10 -10
- package/dist/InfiniteScroll/NoMoreItem.d.ts +1 -1
- package/dist/InfiniteScroll/NoMoreItem.js +10 -10
- package/dist/InfiniteScroll/OuterListElement.d.ts +1 -1
- package/dist/InfiniteScroll/OuterListElement.js +45 -58
- package/dist/InfiniteScroll/constants.js +4 -1
- package/dist/InfiniteScroll/utils.d.ts +1 -1
- package/dist/InfiniteScroll/utils.js +15 -12
- package/dist/ItemsMenu/ItemsMenu.d.ts +2 -2
- package/dist/ItemsMenu/ItemsMenu.js +7 -6
- package/dist/ItemsMenu/ItemsMenu.styles.d.ts +1 -1
- package/dist/ItemsMenu/ItemsMenu.styles.js +6 -3
- package/dist/ItemsMenu/ItemsMenu.types.d.ts +1 -1
- package/dist/ItemsMenu/ItemsMenu.types.js +1 -1
- package/dist/RowSelection/RowSelectionColumn.d.ts +3 -3
- package/dist/RowSelection/RowSelectionColumn.js +77 -81
- package/dist/RowSelection/RowSelectionColumn.types.d.ts +3 -3
- package/dist/RowSelection/RowSelectionColumn.types.js +1 -1
- package/dist/RowSelection/index.js +4 -1
- package/dist/Table.d.ts +2 -4
- package/dist/Table.js +94 -129
- package/dist/Table.styles.d.ts +23 -23
- package/dist/Table.styles.js +86 -110
- package/dist/Table.types.d.ts +7 -7
- package/dist/Table.types.js +1 -1
- package/dist/TableHeader/TableHeader.d.ts +2 -2
- package/dist/TableHeader/TableHeader.js +91 -129
- package/dist/TableHeader/TableHeader.types.d.ts +2 -2
- package/dist/TableHeader/TableHeader.types.js +1 -1
- package/dist/TableHeader/TableLimit/TableLimit.d.ts +2 -2
- package/dist/TableHeader/TableLimit/TableLimit.js +44 -36
- package/dist/TableHeader/TableLimit/TableLimit.styles.d.ts +4 -4
- package/dist/TableHeader/TableLimit/TableLimit.styles.js +15 -13
- package/dist/TableHeader/TableLimit/TableLimit.types.d.ts +3 -3
- package/dist/TableHeader/TableLimit/TableLimit.types.js +1 -1
- package/dist/TableHeader/TableLimit/index.js +4 -2
- package/dist/TableHeader/TableSelection.d.ts +2 -2
- package/dist/TableHeader/TableSelection.js +163 -180
- package/dist/TableHeader/TableSelection.types.d.ts +1 -1
- package/dist/TableHeader/TableSelection.types.js +1 -1
- package/dist/TreeTable/TreeTable.d.ts +2 -3
- package/dist/TreeTable/TreeTable.js +51 -78
- package/dist/TreeTable/TreeTable.styles.d.ts +5 -5
- package/dist/TreeTable/TreeTable.styles.js +21 -20
- package/dist/VirtualTable/VirtualTable.d.ts +3 -3
- package/dist/VirtualTable/VirtualTable.js +342 -411
- package/dist/VirtualTable/VirtualTable.styles.d.ts +8 -8
- package/dist/VirtualTable/VirtualTable.styles.js +30 -40
- package/dist/VirtualTable/VirtualTable.types.d.ts +4 -4
- package/dist/VirtualTable/VirtualTable.types.js +1 -1
- package/dist/VirtualTable/VirtualTableRow.d.ts +4 -4
- package/dist/VirtualTable/VirtualTableRow.js +103 -111
- package/dist/VirtualTable/constants.js +8 -3
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/constants/Table.constants.js +11 -6
- package/dist/constants/TableSkeleton.constants.d.ts +1 -1
- package/dist/constants/TableSkeleton.constants.js +48 -100
- package/dist/hooks/useBulkSelection/index.js +4 -1
- package/dist/hooks/useBulkSelection/useBulkSelection.d.ts +1 -1
- package/dist/hooks/useBulkSelection/useBulkSelection.js +55 -40
- package/dist/hooks/useRowKey/index.js +4 -1
- package/dist/hooks/useRowKey/useRowKey.js +11 -11
- package/dist/hooks/useRowStar/index.js +4 -2
- package/dist/hooks/useRowStar/useRowStar.d.ts +1 -1
- package/dist/hooks/useRowStar/useRowStar.js +54 -62
- package/dist/hooks/useRowStar/useRowStar.types.d.ts +2 -2
- package/dist/hooks/useRowStar/useRowStar.types.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +18 -9
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/calculateColumnWidths.d.ts +1 -1
- package/dist/utils/calculateColumnWidths.js +17 -16
- package/dist/utils/calculatePixels.js +11 -12
- package/dist/utils/columnWithCellTooltip.d.ts +1 -1
- package/dist/utils/columnWithCellTooltip.js +18 -15
- package/dist/utils/getChildrenColumnName.js +6 -3
- package/dist/utils/getRecordSelectionStatus.d.ts +1 -1
- package/dist/utils/getRecordSelectionStatus.js +11 -7
- package/dist/utils/getSkeletonProps.d.ts +1 -1
- package/dist/utils/getSkeletonProps.js +26 -36
- package/dist/utils/getValueFromPath.js +9 -6
- package/dist/utils/index.js +23 -9
- package/dist/utils/isGrouped.d.ts +1 -1
- package/dist/utils/isGrouped.js +6 -3
- package/dist/utils/isRecordSelectable.d.ts +1 -1
- package/dist/utils/isRecordSelectable.js +10 -6
- package/dist/utils/locale.d.ts +3 -3
- package/dist/utils/locale.js +115 -111
- package/package.json +31 -31
- package/dist/Cell/TagsGroup/TagsGroup.spec.d.ts +0 -1
- package/dist/ColumnSortMenu/__spec__/groupedColumnsSort.spec.d.ts +0 -1
- package/dist/VirtualTable/VirtualTable.spec.d.ts +0 -1
- package/dist/utils/__specs__/getValueFromPath.spec.d.ts +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './useSortState';
|
|
1
|
+
import { DSColumnType, OnSortFn, SortStateAPI } from '../Table.types';
|
|
3
2
|
export declare const columnWithSortButtons: (sortStateApi: SortStateAPI, onSort?: OnSortFn) => <T>(column: DSColumnType<T>) => DSColumnType<T>;
|
|
4
3
|
declare const _default: {
|
|
5
4
|
columnWithSortButtons: (sortStateApi: SortStateAPI, onSort?: OnSortFn) => <T>(column: DSColumnType<T>) => DSColumnType<T>;
|
|
@@ -1,50 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
if (typeof sortRender === 'function') {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CommonRenderer, StringRenderer } from "./SortRenderer.js";
|
|
3
|
+
import { TitleWithSort } from "./TitleWithSort.js";
|
|
4
|
+
import "lodash.groupby";
|
|
5
|
+
import "lodash.merge";
|
|
6
|
+
import "react";
|
|
7
|
+
const getSortRenderer = (sortRender = "default", onSort) => {
|
|
8
|
+
if (typeof sortRender === "function") {
|
|
11
9
|
return sortRender;
|
|
12
10
|
}
|
|
13
11
|
switch (sortRender) {
|
|
14
|
-
case
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
sortStateApi: sortStateApi,
|
|
18
|
-
column: column,
|
|
19
|
-
onSort: onSort
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
case 'default':
|
|
12
|
+
case "string":
|
|
13
|
+
return (sortStateApi, column) => /* @__PURE__ */ jsx(StringRenderer, { sortStateApi, column, onSort });
|
|
14
|
+
case "default":
|
|
23
15
|
default:
|
|
24
|
-
return
|
|
25
|
-
return /*#__PURE__*/React.createElement(CommonRenderer, {
|
|
26
|
-
sortStateApi: sortStateApi,
|
|
27
|
-
column: column,
|
|
28
|
-
onSort: onSort
|
|
29
|
-
});
|
|
30
|
-
};
|
|
16
|
+
return (sortStateApi, column) => /* @__PURE__ */ jsx(CommonRenderer, { sortStateApi, column, onSort });
|
|
31
17
|
}
|
|
32
18
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
const columnWithSortButtons = (sortStateApi, onSort) => (column) => {
|
|
20
|
+
const sortRenderer = getSortRenderer(column.sortRender, onSort);
|
|
21
|
+
return column.sorter ? {
|
|
22
|
+
...column,
|
|
23
|
+
sortOrder: column.key ? sortStateApi.getColumnSortOrder(String(column.key)) : null,
|
|
24
|
+
title: (titleProps) => /* @__PURE__ */ jsx(TitleWithSort, { column, sortRender: sortRenderer(sortStateApi, column), titleProps })
|
|
25
|
+
} : column;
|
|
26
|
+
};
|
|
27
|
+
const columnWithSortButtons_default = {
|
|
28
|
+
columnWithSortButtons
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
columnWithSortButtons,
|
|
32
|
+
columnWithSortButtons_default as default
|
|
47
33
|
};
|
|
48
|
-
export default {
|
|
49
|
-
columnWithSortButtons: columnWithSortButtons
|
|
50
|
-
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CompareFn } from 'antd/lib/table/interface';
|
|
2
|
+
import { GroupType } from '../GroupTable/GroupTable.types';
|
|
3
|
+
import { ColumnSortOrder, DSColumnType, SortStateAPI } from '../Table.types';
|
|
4
4
|
export declare const getColumnsWithActiveSorting: <T extends GroupType<T>>(sortStateApi: SortStateAPI, columns?: DSColumnType<T>[]) => DSColumnType<T>[];
|
|
5
5
|
export declare const sortRows: <T>(sortOrder: ColumnSortOrder, compareFn: CompareFn<T>, rows: T[]) => T[];
|
|
6
6
|
export declare const sortDataSourceRows: <T extends GroupType<T>>(sortStateApi: SortStateAPI, sortingColumns?: DSColumnType<T>[], dataSource?: readonly T[]) => readonly T[];
|
|
@@ -1,42 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (sortOrder === 'ascend') {
|
|
14
|
-
return [].concat(rows).sort(compareFn);
|
|
1
|
+
const getColumnsWithActiveSorting = (sortStateApi, columns) => !columns ? [] : columns.filter(({
|
|
2
|
+
key,
|
|
3
|
+
sorter
|
|
4
|
+
}) => {
|
|
5
|
+
if (sortStateApi.getColumnSortOrder(String(key)) && typeof sorter === "function") {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
});
|
|
10
|
+
const sortRows = (sortOrder, compareFn, rows) => {
|
|
11
|
+
if (sortOrder === "ascend") {
|
|
12
|
+
return [...rows].sort(compareFn);
|
|
15
13
|
}
|
|
16
|
-
if (sortOrder ===
|
|
17
|
-
return [].
|
|
14
|
+
if (sortOrder === "descend") {
|
|
15
|
+
return [...rows].sort(compareFn).reverse();
|
|
18
16
|
}
|
|
19
17
|
return rows;
|
|
20
18
|
};
|
|
21
|
-
|
|
19
|
+
const sortDataSourceRows = (sortStateApi, sortingColumns, dataSource) => {
|
|
22
20
|
if (!dataSource) {
|
|
23
21
|
return [];
|
|
24
22
|
}
|
|
25
|
-
if (!
|
|
23
|
+
if (!sortingColumns?.length) {
|
|
26
24
|
return dataSource;
|
|
27
25
|
}
|
|
28
|
-
return dataSource
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
return dataSource?.map((dataItem) => {
|
|
27
|
+
const sortedRows = sortingColumns.reduce((currRows, {
|
|
28
|
+
sorter,
|
|
29
|
+
key
|
|
30
|
+
}) => {
|
|
31
|
+
const sortOrder = sortStateApi.getColumnSortOrder(String(key));
|
|
32
|
+
if (!sortOrder || typeof sorter !== "function") {
|
|
34
33
|
return currRows;
|
|
35
34
|
}
|
|
36
35
|
return sortRows(sortOrder, sorter, currRows);
|
|
37
|
-
}, [
|
|
38
|
-
return
|
|
36
|
+
}, [...dataItem.rows]);
|
|
37
|
+
return {
|
|
38
|
+
...dataItem,
|
|
39
39
|
rows: sortedRows
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
});
|
|
42
|
-
};
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
getColumnsWithActiveSorting,
|
|
45
|
+
sortDataSourceRows,
|
|
46
|
+
sortRows
|
|
47
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode, ReactPortal } from 'react';
|
|
2
2
|
declare const createReplaceButtonsPortal: <T extends Element>(columnTitleElement: T | null, newButtonsNode: ReactNode) => () => ReactPortal | null;
|
|
3
3
|
export default createReplaceButtonsPortal;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { createPortal } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { createPortal } from "react-dom";
|
|
2
|
+
const createReplaceButtonsPortal = (columnTitleElement, newButtonsNode) => () => {
|
|
3
|
+
const sortContainerElem = columnTitleElement?.parentElement?.nextSibling;
|
|
4
|
+
if (!sortContainerElem) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const sortInnerElem = sortContainerElem.querySelector(".ant-table-column-sorter-inner");
|
|
8
|
+
if (sortInnerElem) {
|
|
9
|
+
sortContainerElem.removeChild(sortInnerElem);
|
|
10
|
+
}
|
|
11
|
+
return createPortal(newButtonsNode, sortContainerElem);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
createReplaceButtonsPortal as default
|
|
15
15
|
};
|
|
16
|
-
export default createReplaceButtonsPortal;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColumnSortOrder, ColumnsSortState, DSColumnType, OnSortFn, SortStateAPI } from '../Table.types';
|
|
2
2
|
export declare const toSortOrder: (value: string | null | undefined) => ColumnSortOrder;
|
|
3
3
|
export declare const columnsToSortState: <T>(columns?: DSColumnType<T>[]) => ColumnsSortState;
|
|
4
4
|
export declare const useSortState: (initialState: ColumnsSortState | undefined, onSort: OnSortFn | undefined) => SortStateAPI;
|
|
@@ -1,148 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (value === 'descend' || value === 'ascend') {
|
|
1
|
+
import "lodash.groupby";
|
|
2
|
+
import merge from "lodash.merge";
|
|
3
|
+
import React from "react";
|
|
4
|
+
const toSortOrder = (value) => {
|
|
5
|
+
if (value === "descend" || value === "ascend") {
|
|
7
6
|
return value;
|
|
8
7
|
}
|
|
9
8
|
return null;
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (process.env.NODE_ENV === 'development') {
|
|
16
|
-
var columnsKeys = columns.map(function (c, i) {
|
|
17
|
-
if (c.sorter && !c.key) {
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.warn("DefaultTable: column " + (typeof c.title === 'string' ? c.title : i + 1) + " has no \"key\" prop set which is required to use sorter");
|
|
20
|
-
}
|
|
21
|
-
return c.key;
|
|
22
|
-
});
|
|
23
|
-
var uniqueColumnKeys = Array.from(new Set(columnsKeys));
|
|
24
|
-
if (columnsKeys.length !== uniqueColumnKeys.length) {
|
|
25
|
-
// eslint-disable-next-line no-console
|
|
26
|
-
console.warn('DefaultTable: column keys are not unique what may affect sorting. Columns grouped by key:', groupBy(columns, 'key'));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return columns.reduce(function (state, column) {
|
|
30
|
-
var _extends2, _extends3;
|
|
31
|
-
return typeof column.sorter === 'object' ? _extends({}, state, (_extends2 = {}, _extends2[String(column.key)] = {
|
|
10
|
+
const columnsToSortState = (columns = []) => {
|
|
11
|
+
return columns.reduce((state, column) => typeof column.sorter === "object" ? {
|
|
12
|
+
...state,
|
|
13
|
+
[String(column.key)]: {
|
|
32
14
|
sortOrder: toSortOrder(column.sortOrder) || toSortOrder(column.defaultSortOrder),
|
|
33
15
|
multiple: column.sorter.multiple || false
|
|
34
|
-
}
|
|
16
|
+
}
|
|
17
|
+
} : {
|
|
18
|
+
...state,
|
|
19
|
+
[String(column.key)]: {
|
|
35
20
|
sortOrder: toSortOrder(column.sortOrder) || toSortOrder(column.defaultSortOrder),
|
|
36
21
|
multiple: false
|
|
37
|
-
}
|
|
22
|
+
}
|
|
38
23
|
}, {});
|
|
39
24
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
const setSingleOrder = (state, action) => {
|
|
26
|
+
const {
|
|
27
|
+
payload
|
|
28
|
+
} = action;
|
|
29
|
+
const {
|
|
30
|
+
onSort
|
|
31
|
+
} = payload;
|
|
32
|
+
const clearedSortState = Object.entries(state).reduce((newState2, [currKey, currValue]) => ({
|
|
33
|
+
...newState2,
|
|
34
|
+
[currKey]: {
|
|
35
|
+
...currValue,
|
|
49
36
|
sortOrder: null
|
|
50
|
-
}
|
|
51
|
-
}, {});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
}
|
|
38
|
+
}), {});
|
|
39
|
+
const newState = {
|
|
40
|
+
...clearedSortState,
|
|
41
|
+
[payload.key]: {
|
|
42
|
+
...state[payload.key],
|
|
43
|
+
sortOrder: payload.sortOrder
|
|
44
|
+
}
|
|
45
|
+
};
|
|
55
46
|
onSort && onSort({
|
|
56
47
|
columnKey: payload.key,
|
|
57
48
|
order: payload.sortOrder
|
|
58
49
|
}, newState);
|
|
59
50
|
return newState;
|
|
60
51
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
const setMultipleOrder = (state, action) => {
|
|
53
|
+
const {
|
|
54
|
+
payload
|
|
55
|
+
} = action;
|
|
56
|
+
const {
|
|
57
|
+
onSort
|
|
58
|
+
} = payload;
|
|
59
|
+
const clearedSortState = Object.entries(state).reduce((newState2, [currKey, currValue]) => currValue.multiple === false ? {
|
|
60
|
+
...newState2,
|
|
61
|
+
[currKey]: {
|
|
62
|
+
...currValue,
|
|
70
63
|
sortOrder: null
|
|
71
|
-
}
|
|
64
|
+
}
|
|
65
|
+
} : {
|
|
66
|
+
...newState2,
|
|
67
|
+
[currKey]: state[currKey]
|
|
72
68
|
}, {});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const newState = {
|
|
70
|
+
...clearedSortState,
|
|
71
|
+
[payload.key]: {
|
|
72
|
+
...state[payload.key],
|
|
73
|
+
sortOrder: payload.sortOrder
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
76
|
onSort && onSort({
|
|
77
77
|
columnKey: payload.key,
|
|
78
78
|
order: payload.sortOrder
|
|
79
79
|
}, newState);
|
|
80
80
|
return newState;
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const updateColumns = (state, action) => {
|
|
83
|
+
const {
|
|
84
|
+
payload
|
|
85
|
+
} = action;
|
|
84
86
|
return merge(payload.columns, state);
|
|
85
87
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const sortReducer = (state, action) => {
|
|
89
|
+
const {
|
|
90
|
+
type
|
|
91
|
+
} = action;
|
|
88
92
|
switch (type) {
|
|
89
|
-
case
|
|
93
|
+
case "setSingleOrder":
|
|
90
94
|
return setSingleOrder(state, action);
|
|
91
|
-
case
|
|
95
|
+
case "setMultipleOrder":
|
|
92
96
|
return setMultipleOrder(state, action);
|
|
93
|
-
case
|
|
97
|
+
case "updateColumns":
|
|
94
98
|
return updateColumns(state, action);
|
|
95
99
|
default:
|
|
96
100
|
return state;
|
|
97
101
|
}
|
|
98
102
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var _React$useReducer = React.useReducer(sortReducer, initialState),
|
|
104
|
-
columnsSortState = _React$useReducer[0],
|
|
105
|
-
dispatch = _React$useReducer[1];
|
|
106
|
-
var getColumnSortOrder = function getColumnSortOrder(key) {
|
|
107
|
-
var _columnsSortState$key;
|
|
108
|
-
return (_columnsSortState$key = columnsSortState[key]) == null ? void 0 : _columnsSortState$key.sortOrder;
|
|
103
|
+
const useSortState = (initialState = {}, onSort) => {
|
|
104
|
+
const [columnsSortState, dispatch] = React.useReducer(sortReducer, initialState);
|
|
105
|
+
const getColumnSortOrder = (key) => {
|
|
106
|
+
return columnsSortState[key]?.sortOrder;
|
|
109
107
|
};
|
|
110
|
-
|
|
108
|
+
const updateColumnsData = (columns) => {
|
|
111
109
|
dispatch({
|
|
112
|
-
type:
|
|
110
|
+
type: "updateColumns",
|
|
113
111
|
payload: {
|
|
114
|
-
columns
|
|
112
|
+
columns
|
|
115
113
|
}
|
|
116
114
|
});
|
|
117
115
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (((_columnsSortState$key2 = columnsSortState[key]) == null ? void 0 : _columnsSortState$key2.sortOrder) !== sortOrder && ((_columnsSortState$key3 = columnsSortState[key]) == null ? void 0 : _columnsSortState$key3.multiple) === false) {
|
|
116
|
+
const setColumnSortOrder = (key, sortOrder) => {
|
|
117
|
+
if (columnsSortState[key]?.sortOrder !== sortOrder && columnsSortState[key]?.multiple === false) {
|
|
121
118
|
dispatch({
|
|
122
|
-
type:
|
|
119
|
+
type: "setSingleOrder",
|
|
123
120
|
payload: {
|
|
124
|
-
key
|
|
125
|
-
sortOrder
|
|
126
|
-
onSort
|
|
121
|
+
key,
|
|
122
|
+
sortOrder,
|
|
123
|
+
onSort
|
|
127
124
|
}
|
|
128
125
|
});
|
|
129
126
|
}
|
|
130
|
-
if (
|
|
127
|
+
if (columnsSortState[key]?.sortOrder !== sortOrder && columnsSortState[key]?.multiple) {
|
|
131
128
|
dispatch({
|
|
132
|
-
type:
|
|
129
|
+
type: "setMultipleOrder",
|
|
133
130
|
payload: {
|
|
134
|
-
key
|
|
135
|
-
sortOrder
|
|
136
|
-
onSort
|
|
131
|
+
key,
|
|
132
|
+
sortOrder,
|
|
133
|
+
onSort
|
|
137
134
|
}
|
|
138
135
|
});
|
|
139
136
|
}
|
|
140
137
|
};
|
|
141
138
|
return {
|
|
142
|
-
columnsSortState
|
|
143
|
-
updateColumnsData
|
|
144
|
-
getColumnSortOrder
|
|
145
|
-
setColumnSortOrder
|
|
139
|
+
columnsSortState,
|
|
140
|
+
updateColumnsData,
|
|
141
|
+
getColumnSortOrder,
|
|
142
|
+
setColumnSortOrder
|
|
146
143
|
};
|
|
147
144
|
};
|
|
148
|
-
export
|
|
145
|
+
export {
|
|
146
|
+
columnsToSortState,
|
|
147
|
+
useSortState as default,
|
|
148
|
+
toSortOrder,
|
|
149
|
+
useSortState
|
|
150
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DSTableProps, RowType } from '../Table.types';
|
|
3
3
|
declare function DefaultTable<T extends object & RowType<T>>(props: DSTableProps<T>): React.JSX.Element;
|
|
4
4
|
export default DefaultTable;
|