@synerise/ds-table-new 0.1.0
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 +10 -0
- package/LICENSE.md +21 -0
- package/README.md +153 -0
- package/dist/Table.const.d.ts +20 -0
- package/dist/Table.const.js +42 -0
- package/dist/Table.d.ts +3 -0
- package/dist/Table.js +51 -0
- package/dist/Table.styles.d.ts +15 -0
- package/dist/Table.styles.js +29 -0
- package/dist/Table.types.d.ts +359 -0
- package/dist/Table.types.js +1 -0
- package/dist/VirtualTable.d.ts +3 -0
- package/dist/VirtualTable.js +222 -0
- package/dist/components/BaseTable/BaseTable.d.ts +3 -0
- package/dist/components/BaseTable/BaseTable.js +114 -0
- package/dist/components/BaseTable/BaseTable.styles.d.ts +28 -0
- package/dist/components/BaseTable/BaseTable.styles.js +41 -0
- package/dist/components/Cell/Action/ActionCell.d.ts +3 -0
- package/dist/components/Cell/Action/ActionCell.js +16 -0
- package/dist/components/Cell/Action/ActionCell.styles.d.ts +5 -0
- package/dist/components/Cell/Action/ActionCell.styles.js +13 -0
- package/dist/components/Cell/Action/ActionCell.types.d.ts +13 -0
- package/dist/components/Cell/Action/ActionCell.types.js +1 -0
- package/dist/components/Cell/AvatarLabel/AvatarLabel.d.ts +4 -0
- package/dist/components/Cell/AvatarLabel/AvatarLabel.js +42 -0
- package/dist/components/Cell/AvatarLabel/AvatarLabel.styles.d.ts +27 -0
- package/dist/components/Cell/AvatarLabel/AvatarLabel.styles.js +49 -0
- package/dist/components/Cell/AvatarLabel/AvatarLabel.types.d.ts +22 -0
- package/dist/components/Cell/AvatarLabel/AvatarLabel.types.js +1 -0
- package/dist/components/Cell/Copyable/Copyable.styles.d.ts +2 -0
- package/dist/components/Cell/Copyable/Copyable.styles.js +14 -0
- package/dist/components/Cell/Copyable/Copyable.types.d.ts +11 -0
- package/dist/components/Cell/Copyable/Copyable.types.js +1 -0
- package/dist/components/Cell/Copyable/CopyableCell.d.ts +4 -0
- package/dist/components/Cell/Copyable/CopyableCell.js +28 -0
- package/dist/components/Cell/Editable/EditableCell.d.ts +4 -0
- package/dist/components/Cell/Editable/EditableCell.js +30 -0
- package/dist/components/Cell/Editable/EditableCell.styles.d.ts +4 -0
- package/dist/components/Cell/Editable/EditableCell.styles.js +14 -0
- package/dist/components/Cell/Editable/EditableCell.types.d.ts +11 -0
- package/dist/components/Cell/Editable/EditableCell.types.js +1 -0
- package/dist/components/Cell/FlagLabel/FlagLabelCell.d.ts +4 -0
- package/dist/components/Cell/FlagLabel/FlagLabelCell.js +16 -0
- package/dist/components/Cell/FlagLabel/FlagLabelCell.styles.d.ts +1 -0
- package/dist/components/Cell/FlagLabel/FlagLabelCell.styles.js +8 -0
- package/dist/components/Cell/FlagLabel/FlagLabelCell.types.d.ts +11 -0
- package/dist/components/Cell/FlagLabel/FlagLabelCell.types.js +1 -0
- package/dist/components/Cell/IconLabel/IconLabel.d.ts +4 -0
- package/dist/components/Cell/IconLabel/IconLabel.js +15 -0
- package/dist/components/Cell/IconLabel/IconLabel.styles.d.ts +3 -0
- package/dist/components/Cell/IconLabel/IconLabel.styles.js +9 -0
- package/dist/components/Cell/IconLabel/IconLabel.types.d.ts +13 -0
- package/dist/components/Cell/IconLabel/IconLabel.types.js +1 -0
- package/dist/components/Cell/IconTooltipCell/IconTooltipCell.d.ts +4 -0
- package/dist/components/Cell/IconTooltipCell/IconTooltipCell.js +19 -0
- package/dist/components/Cell/IconTooltipCell/IconTooltipCell.styles.d.ts +4 -0
- package/dist/components/Cell/IconTooltipCell/IconTooltipCell.styles.js +13 -0
- package/dist/components/Cell/IconTooltipCell/IconTooltipCell.types.d.ts +16 -0
- package/dist/components/Cell/IconTooltipCell/IconTooltipCell.types.js +1 -0
- package/dist/components/Cell/InputNumber/InputNumberCell.d.ts +4 -0
- package/dist/components/Cell/InputNumber/InputNumberCell.js +11 -0
- package/dist/components/Cell/InputNumber/InputNumberCell.styles.d.ts +3 -0
- package/dist/components/Cell/InputNumber/InputNumberCell.styles.js +11 -0
- package/dist/components/Cell/InputNumber/InputNumberCell.types.d.ts +7 -0
- package/dist/components/Cell/InputNumber/InputNumberCell.types.js +1 -0
- package/dist/components/Cell/LabelsWithShowMore/LabelsWithShowMore.d.ts +5 -0
- package/dist/components/Cell/LabelsWithShowMore/LabelsWithShowMore.js +33 -0
- package/dist/components/Cell/LabelsWithShowMore/LabelsWithShowMore.styles.d.ts +3 -0
- package/dist/components/Cell/LabelsWithShowMore/LabelsWithShowMore.styles.js +18 -0
- package/dist/components/Cell/LabelsWithShowMore/LabelsWithShowMore.types.d.ts +22 -0
- package/dist/components/Cell/LabelsWithShowMore/LabelsWithShowMore.types.js +1 -0
- package/dist/components/Cell/LabelsWithShowMore/Modal/Modal.d.ts +4 -0
- package/dist/components/Cell/LabelsWithShowMore/Modal/Modal.js +37 -0
- package/dist/components/Cell/LabelsWithShowMore/Modal/Modal.types.d.ts +15 -0
- package/dist/components/Cell/LabelsWithShowMore/Modal/Modal.types.js +1 -0
- package/dist/components/Cell/Star/StarCell.d.ts +4 -0
- package/dist/components/Cell/Star/StarCell.js +25 -0
- package/dist/components/Cell/Star/StarCell.styles.d.ts +5 -0
- package/dist/components/Cell/Star/StarCell.styles.js +16 -0
- package/dist/components/Cell/Star/StarCell.types.d.ts +17 -0
- package/dist/components/Cell/Star/StarCell.types.js +1 -0
- package/dist/components/Cell/StatusLabel/StatusLabel.d.ts +4 -0
- package/dist/components/Cell/StatusLabel/StatusLabel.js +18 -0
- package/dist/components/Cell/StatusLabel/StatusLabel.styles.d.ts +4 -0
- package/dist/components/Cell/StatusLabel/StatusLabel.styles.js +13 -0
- package/dist/components/Cell/StatusLabel/StatusLabel.types.d.ts +14 -0
- package/dist/components/Cell/StatusLabel/StatusLabel.types.js +1 -0
- package/dist/components/Cell/TagIcon/TagIcon.d.ts +4 -0
- package/dist/components/Cell/TagIcon/TagIcon.js +10 -0
- package/dist/components/Cell/TagIcon/TagIcon.styles.d.ts +3 -0
- package/dist/components/Cell/TagIcon/TagIcon.styles.js +9 -0
- package/dist/components/Cell/TagIcon/TagIcon.types.d.ts +11 -0
- package/dist/components/Cell/TagIcon/TagIcon.types.js +1 -0
- package/dist/components/Cell/TagsGroup/TagsGroup.d.ts +3 -0
- package/dist/components/Cell/TagsGroup/TagsGroup.js +26 -0
- package/dist/components/Cell/TagsGroup/TagsGroup.styles.d.ts +5 -0
- package/dist/components/Cell/TagsGroup/TagsGroup.styles.js +34 -0
- package/dist/components/Cell/TagsGroup/TagsGroup.types.d.ts +9 -0
- package/dist/components/Cell/TagsGroup/TagsGroup.types.js +1 -0
- package/dist/components/Cell/index.d.ts +26 -0
- package/dist/components/Cell/index.js +28 -0
- package/dist/components/TableBody/TableBody.d.ts +3 -0
- package/dist/components/TableBody/TableBody.js +40 -0
- package/dist/components/TableBody/TableBody.styles.d.ts +2 -0
- package/dist/components/TableBody/TableBody.styles.js +15 -0
- package/dist/components/TableBody/TableBodySkeleton/TableBodySkeleton.d.ts +5 -0
- package/dist/components/TableBody/TableBodySkeleton/TableBodySkeleton.js +42 -0
- package/dist/components/TableBody/TableBodySkeleton/TableBodySkeleton.styles.d.ts +9 -0
- package/dist/components/TableBody/TableBodySkeleton/TableBodySkeleton.styles.js +30 -0
- package/dist/components/TableBody/TableCell/TableCell.d.ts +16 -0
- package/dist/components/TableBody/TableCell/TableCell.js +19 -0
- package/dist/components/TableBody/TableCell/TableCell.styles.d.ts +10 -0
- package/dist/components/TableBody/TableCell/TableCell.styles.js +18 -0
- package/dist/components/TableBody/TableEmptyBody/TableEmptyBody.d.ts +3 -0
- package/dist/components/TableBody/TableEmptyBody/TableEmptyBody.js +18 -0
- package/dist/components/TableBody/TableEmptyBody/TableEmptyBody.styles.d.ts +4 -0
- package/dist/components/TableBody/TableEmptyBody/TableEmptyBody.styles.js +23 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/ErrorItem.d.ts +8 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/ErrorItem.js +19 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/ErrorItem.styles.d.ts +1 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/ErrorItem.styles.js +8 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/InfiniteLoaderRow.d.ts +14 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/InfiniteLoaderRow.js +50 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/LoadingItem.d.ts +5 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/LoadingItem.js +10 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/LoadingItem.styles.d.ts +1 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/LoadingItem.styles.js +9 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/NoMoreItem.d.ts +5 -0
- package/dist/components/TableBody/TableRow/InfiniteLoaderRow/NoMoreItem.js +10 -0
- package/dist/components/TableBody/TableRow/TableRow.d.ts +5 -0
- package/dist/components/TableBody/TableRow/TableRow.js +29 -0
- package/dist/components/TableBody/TableRow/TableRow.styles.d.ts +7 -0
- package/dist/components/TableBody/TableRow/TableRow.styles.js +15 -0
- package/dist/components/TableBody/TableRow/TableRowVirtual.d.ts +5 -0
- package/dist/components/TableBody/TableRow/TableRowVirtual.js +88 -0
- package/dist/components/TableBody/TableRowSelection/TableRowSelection.d.ts +3 -0
- package/dist/components/TableBody/TableRowSelection/TableRowSelection.js +39 -0
- package/dist/components/TableColumns/TableColumnSorter/SortIcons/DefaultSortIcon.d.ts +5 -0
- package/dist/components/TableColumns/TableColumnSorter/SortIcons/DefaultSortIcon.js +19 -0
- package/dist/components/TableColumns/TableColumnSorter/SortIcons/StringSortIcon.d.ts +5 -0
- package/dist/components/TableColumns/TableColumnSorter/SortIcons/StringSortIcon.js +19 -0
- package/dist/components/TableColumns/TableColumnSorter/TableColumnSorter.const.d.ts +4 -0
- package/dist/components/TableColumns/TableColumnSorter/TableColumnSorter.const.js +8 -0
- package/dist/components/TableColumns/TableColumnSorter/TableColumnSorter.d.ts +3 -0
- package/dist/components/TableColumns/TableColumnSorter/TableColumnSorter.js +75 -0
- package/dist/components/TableColumns/TableColumnSorter/TableColumnSorter.styles.d.ts +30 -0
- package/dist/components/TableColumns/TableColumnSorter/TableColumnSorter.styles.js +11 -0
- package/dist/components/TableColumns/TableColumns.d.ts +3 -0
- package/dist/components/TableColumns/TableColumns.js +28 -0
- package/dist/components/TableColumns/TableColumns.styles.d.ts +18 -0
- package/dist/components/TableColumns/TableColumns.styles.js +35 -0
- package/dist/components/TableHeader/TableCounter/TableCounter.d.ts +3 -0
- package/dist/components/TableHeader/TableCounter/TableCounter.js +33 -0
- package/dist/components/TableHeader/TableCounter/TableCounter.styles.d.ts +1 -0
- package/dist/components/TableHeader/TableCounter/TableCounter.styles.js +8 -0
- package/dist/components/TableHeader/TableHeader.d.ts +3 -0
- package/dist/components/TableHeader/TableHeader.js +103 -0
- package/dist/components/TableHeader/TableHeader.styles.d.ts +18 -0
- package/dist/components/TableHeader/TableHeader.styles.js +48 -0
- package/dist/components/TableHeader/TableHeaderSelection/TableHeaderSelection.d.ts +3 -0
- package/dist/components/TableHeader/TableHeaderSelection/TableHeaderSelection.js +123 -0
- package/dist/components/TableHeader/TableHeaderSelection/TableHeaderSelection.styles.d.ts +8 -0
- package/dist/components/TableHeader/TableHeaderSelection/TableHeaderSelection.styles.js +21 -0
- package/dist/components/TableHeader/TableLimit/TableLimit.d.ts +3 -0
- package/dist/components/TableHeader/TableLimit/TableLimit.js +50 -0
- package/dist/components/TableHeader/TableLimit/TableLimit.styles.d.ts +4 -0
- package/dist/components/TableHeader/TableLimit/TableLimit.styles.js +24 -0
- package/dist/components/TableHeader/TableLimit/TableLimit.types.d.ts +10 -0
- package/dist/components/TableHeader/TableLimit/TableLimit.types.js +1 -0
- package/dist/components/TableHorizontalScroll/TableHorizontalScroll.d.ts +6 -0
- package/dist/components/TableHorizontalScroll/TableHorizontalScroll.js +41 -0
- package/dist/components/TableHorizontalScroll/TableHorizontalScroll.styles.d.ts +12 -0
- package/dist/components/TableHorizontalScroll/TableHorizontalScroll.styles.js +33 -0
- package/dist/components/TableHorizontalScrollBar/TableHorizontalScrollBar.d.ts +6 -0
- package/dist/components/TableHorizontalScrollBar/TableHorizontalScrollBar.js +11 -0
- package/dist/components/TableHorizontalScrollBar/TableHorizontalScrollBar.styles.d.ts +4 -0
- package/dist/components/TableHorizontalScrollBar/TableHorizontalScrollBar.styles.js +14 -0
- package/dist/components/TablePagination/TablePagination.d.ts +3 -0
- package/dist/components/TablePagination/TablePagination.js +19 -0
- package/dist/components/TablePagination/TablePagination.styles.d.ts +1 -0
- package/dist/components/TablePagination/TablePagination.styles.js +8 -0
- package/dist/contexts/SelectionContext.d.ts +4 -0
- package/dist/contexts/SelectionContext.js +10 -0
- package/dist/contexts/StickyContext.d.ts +8 -0
- package/dist/contexts/StickyContext.js +9 -0
- package/dist/contexts/TableContext.d.ts +11 -0
- package/dist/contexts/TableContext.js +13 -0
- package/dist/hooks/useColumnSizing.d.ts +23 -0
- package/dist/hooks/useColumnSizing.js +95 -0
- package/dist/hooks/useDefaultTexts.d.ts +2 -0
- package/dist/hooks/useDefaultTexts.js +95 -0
- package/dist/hooks/useInfiniteScroll.d.ts +13 -0
- package/dist/hooks/useInfiniteScroll.js +58 -0
- package/dist/hooks/useRowKey.d.ts +4 -0
- package/dist/hooks/useRowKey.js +27 -0
- package/dist/hooks/useScrollSync.d.ts +2 -0
- package/dist/hooks/useScrollSync.js +23 -0
- package/dist/hooks/useTable.d.ts +14 -0
- package/dist/hooks/useTable.js +168 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +50 -0
- package/dist/types/table.d.js +1 -0
- package/dist/types/table.d.ts +28 -0
- package/dist/utils/arrayToTrueMap.d.ts +1 -0
- package/dist/utils/arrayToTrueMap.js +7 -0
- package/dist/utils/calculatePixels.d.ts +1 -0
- package/dist/utils/calculatePixels.js +21 -0
- package/dist/utils/compareKeys.d.ts +1 -0
- package/dist/utils/compareKeys.js +16 -0
- package/dist/utils/getChildrenColumnName.d.ts +1 -0
- package/dist/utils/getChildrenColumnName.js +7 -0
- package/dist/utils/getDefaultSkeletonColumns.d.ts +2 -0
- package/dist/utils/getDefaultSkeletonColumns.js +58 -0
- package/dist/utils/getInfiniteScrollPadding.d.ts +2 -0
- package/dist/utils/getInfiniteScrollPadding.js +13 -0
- package/dist/utils/getIsRevealed.d.ts +5 -0
- package/dist/utils/getIsRevealed.js +9 -0
- package/dist/utils/getPaginationConfig.d.ts +10 -0
- package/dist/utils/getPaginationConfig.js +19 -0
- package/dist/utils/getRecordSelectionStatus.d.ts +5 -0
- package/dist/utils/getRecordSelectionStatus.js +13 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/isRecordSelectable.d.ts +2 -0
- package/dist/utils/isRecordSelectable.js +14 -0
- package/dist/utils/legacyColumnConfigAdapter.d.ts +3 -0
- package/dist/utils/legacyColumnConfigAdapter.js +113 -0
- package/dist/utils/processColumns.d.ts +3 -0
- package/dist/utils/processColumns.js +24 -0
- package/dist/utils/sort.d.ts +3 -0
- package/dist/utils/sort.js +14 -0
- package/package.json +76 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
const useDefaultTexts = (defaultTexts) => {
|
|
4
|
+
const intl = useIntl();
|
|
5
|
+
return useMemo(() => ({
|
|
6
|
+
infiniteScrollLoading: intl.formatMessage({
|
|
7
|
+
id: "DS.TABLE.INFINITE-SCROLL-LOADING",
|
|
8
|
+
defaultMessage: "Loading"
|
|
9
|
+
}),
|
|
10
|
+
infiniteScrollError: intl.formatMessage({
|
|
11
|
+
id: "DS.TABLE.INFINITE-SCROLL-ERROR",
|
|
12
|
+
defaultMessage: "An error occurred"
|
|
13
|
+
}),
|
|
14
|
+
infiniteScrollRetry: intl.formatMessage({
|
|
15
|
+
id: "DS.TABLE.INFINITE-SCROLL-RETRY",
|
|
16
|
+
defaultMessage: "Retry"
|
|
17
|
+
}),
|
|
18
|
+
infiniteScrollNoMoreData: intl.formatMessage({
|
|
19
|
+
id: "DS.TABLE.INFINITE-SCROLL-NO-MORE-DATA",
|
|
20
|
+
defaultMessage: "There are no more items to load"
|
|
21
|
+
}),
|
|
22
|
+
columnSortClear: intl.formatMessage({
|
|
23
|
+
id: "DS.TABLE.COLUMN.SORT_CLEAR",
|
|
24
|
+
defaultMessage: "Clear"
|
|
25
|
+
}),
|
|
26
|
+
columnSortAscend: intl.formatMessage({
|
|
27
|
+
id: "DS.TABLE.COLUMN.SORT_ASCEND",
|
|
28
|
+
defaultMessage: "Sort ascending"
|
|
29
|
+
}),
|
|
30
|
+
columnSortDescend: intl.formatMessage({
|
|
31
|
+
id: "DS.TABLE.COLUMN.SORT_DESCEND",
|
|
32
|
+
defaultMessage: "Sort descending"
|
|
33
|
+
}),
|
|
34
|
+
columnSortZa: intl.formatMessage({
|
|
35
|
+
id: "DS.TABLE.COLUMN.SORT_ZA",
|
|
36
|
+
defaultMessage: "Sort z-a"
|
|
37
|
+
}),
|
|
38
|
+
columnSortAz: intl.formatMessage({
|
|
39
|
+
id: "DS.TABLE.COLUMN.SORT_AZ",
|
|
40
|
+
defaultMessage: "Sort a-z"
|
|
41
|
+
}),
|
|
42
|
+
totalItems: intl.formatMessage({
|
|
43
|
+
id: "DS.TABLE.ITEMS",
|
|
44
|
+
defaultMessage: "Records"
|
|
45
|
+
}),
|
|
46
|
+
selected: intl.formatMessage({
|
|
47
|
+
id: "DS.TABLE.SELECTED",
|
|
48
|
+
defaultMessage: "selected"
|
|
49
|
+
}),
|
|
50
|
+
selectAll: intl.formatMessage({
|
|
51
|
+
id: "DS.TABLE.SELECT-ALL",
|
|
52
|
+
defaultMessage: "Select visible"
|
|
53
|
+
}),
|
|
54
|
+
selectAllTooltip: intl.formatMessage({
|
|
55
|
+
id: "DS.TABLE.SELECT-ALL-TOOLTIP",
|
|
56
|
+
defaultMessage: "Select all"
|
|
57
|
+
}),
|
|
58
|
+
selectGlobalAll: intl.formatMessage({
|
|
59
|
+
id: "DS.TABLE.SELECT-GLOBAL-ALL",
|
|
60
|
+
defaultMessage: "Select all"
|
|
61
|
+
}),
|
|
62
|
+
selectInvert: intl.formatMessage({
|
|
63
|
+
id: "DS.TABLE.SELECT-INVERT",
|
|
64
|
+
defaultMessage: "Inverse selection"
|
|
65
|
+
}),
|
|
66
|
+
selectionLimitWarning: intl.formatMessage({
|
|
67
|
+
id: "DS.TABLE.SELECTION-LIMIT",
|
|
68
|
+
defaultMessage: "You have reached max limit"
|
|
69
|
+
}),
|
|
70
|
+
selectionOptionsTooltip: intl.formatMessage({
|
|
71
|
+
id: "DS.TABLE.SELECTIONS-MENU-TOOLTIP",
|
|
72
|
+
defaultMessage: "Batch selection options"
|
|
73
|
+
}),
|
|
74
|
+
unselectAll: intl.formatMessage({
|
|
75
|
+
id: "DS.TABLE.UNSELECT-ALL",
|
|
76
|
+
defaultMessage: "Unselect visible"
|
|
77
|
+
}),
|
|
78
|
+
unselectGlobalAll: intl.formatMessage({
|
|
79
|
+
id: "DS.TABLE.UNSELECT-GLOBAL-ALL",
|
|
80
|
+
defaultMessage: "Unselect all"
|
|
81
|
+
}),
|
|
82
|
+
emptyText: intl.formatMessage({
|
|
83
|
+
id: "DS.TABLE.NO-DATA",
|
|
84
|
+
defaultMessage: "No data"
|
|
85
|
+
}),
|
|
86
|
+
selectRowTooltip: intl.formatMessage({
|
|
87
|
+
id: "DS.TABLE.SELECT-ROW",
|
|
88
|
+
defaultMessage: "Select"
|
|
89
|
+
}),
|
|
90
|
+
...defaultTexts
|
|
91
|
+
}), [intl, defaultTexts]);
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
useDefaultTexts
|
|
95
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { Virtualizer } from '@tanstack/react-virtual';
|
|
3
|
+
import { InfiniteScrollProps, OnItemsRenderedProps, StickyData } from '../Table.types';
|
|
4
|
+
type UseInfiniteScrollProps = {
|
|
5
|
+
infiniteScroll?: InfiniteScrollProps;
|
|
6
|
+
onItemsRendered?: (props: OnItemsRenderedProps) => void;
|
|
7
|
+
setStickyData?: Dispatch<SetStateAction<StickyData>>;
|
|
8
|
+
};
|
|
9
|
+
export declare const useInfiniteScroll: ({ infiniteScroll, onItemsRendered, setStickyData, }: UseInfiniteScrollProps) => {
|
|
10
|
+
scrollDirection: "forward" | "backward" | null;
|
|
11
|
+
handleScrollDirection: (virtualiser: Virtualizer<HTMLDivElement, Element>, isScrolling: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect } from "react";
|
|
2
|
+
import { INFINITE_SCROLL_TRIGGER_THRESHOLD, INFINITE_SCROLL_PADDING_START } from "../Table.const.js";
|
|
3
|
+
const useInfiniteScroll = ({
|
|
4
|
+
infiniteScroll,
|
|
5
|
+
onItemsRendered,
|
|
6
|
+
setStickyData
|
|
7
|
+
}) => {
|
|
8
|
+
const [scrollDirection, setScrollDirection] = useState(null);
|
|
9
|
+
const [isCurrentlyScrolling, setIsCurrentlyScrolling] = useState(false);
|
|
10
|
+
const handleInfiniteScroll = useCallback((containerRefElement, dir) => {
|
|
11
|
+
if (containerRefElement) {
|
|
12
|
+
const {
|
|
13
|
+
scrollHeight,
|
|
14
|
+
scrollTop,
|
|
15
|
+
clientHeight
|
|
16
|
+
} = containerRefElement;
|
|
17
|
+
if (scrollHeight - scrollTop - clientHeight < INFINITE_SCROLL_TRIGGER_THRESHOLD && infiniteScroll?.nextPage?.hasMore && !infiniteScroll?.nextPage?.isLoading && dir === "forward") {
|
|
18
|
+
infiniteScroll?.onScrollEndReach?.();
|
|
19
|
+
} else if (scrollTop < INFINITE_SCROLL_TRIGGER_THRESHOLD && infiniteScroll?.prevPage?.hasMore && !infiniteScroll?.prevPage?.isLoading && dir === "backward") {
|
|
20
|
+
infiniteScroll?.onScrollTopReach?.();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, [infiniteScroll]);
|
|
24
|
+
const handleScrollDirection = useCallback((virtualiser, isScrolling) => {
|
|
25
|
+
const itemAtOffset = virtualiser.getVirtualItemForOffset((virtualiser.scrollOffset || 0) - INFINITE_SCROLL_PADDING_START);
|
|
26
|
+
const firstVisibleItem = itemAtOffset?.size === 0 ? virtualiser.getVirtualItems().find((v) => v.index > itemAtOffset.index && v.size > 0) : itemAtOffset;
|
|
27
|
+
if (firstVisibleItem !== void 0) {
|
|
28
|
+
onItemsRendered?.({
|
|
29
|
+
visibleStartIndex: firstVisibleItem.index
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
setIsCurrentlyScrolling(isScrolling);
|
|
33
|
+
if (infiniteScroll && isScrolling) {
|
|
34
|
+
handleInfiniteScroll(virtualiser.scrollElement, virtualiser.scrollDirection);
|
|
35
|
+
}
|
|
36
|
+
if (virtualiser.scrollDirection) {
|
|
37
|
+
setScrollDirection(virtualiser.scrollDirection);
|
|
38
|
+
}
|
|
39
|
+
if (!virtualiser.scrollOffset) {
|
|
40
|
+
setScrollDirection(null);
|
|
41
|
+
}
|
|
42
|
+
}, [handleInfiniteScroll, infiniteScroll, onItemsRendered]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (isCurrentlyScrolling && scrollDirection === "forward") {
|
|
45
|
+
setStickyData?.((prev) => ({
|
|
46
|
+
...prev,
|
|
47
|
+
isRevealed: false
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
}, [isCurrentlyScrolling, scrollDirection, setStickyData]);
|
|
51
|
+
return {
|
|
52
|
+
scrollDirection,
|
|
53
|
+
handleScrollDirection
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
useInfiniteScroll
|
|
58
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
const parentIndex = (row) => {
|
|
3
|
+
const parent = row.getParentRow();
|
|
4
|
+
return `.${row.index}${parent ? parentIndex(parent) : ""}`;
|
|
5
|
+
};
|
|
6
|
+
const generateIdFromIndex = (index, parent) => {
|
|
7
|
+
return `${index}${parent ? parentIndex(parent) : ""}`;
|
|
8
|
+
};
|
|
9
|
+
const useRowKey = (rowKey) => {
|
|
10
|
+
const getRowKey = useCallback((row, index, parent) => {
|
|
11
|
+
if (typeof rowKey === "function") {
|
|
12
|
+
return rowKey(row);
|
|
13
|
+
}
|
|
14
|
+
if (typeof rowKey === "string") {
|
|
15
|
+
return String(row[rowKey]);
|
|
16
|
+
}
|
|
17
|
+
const record = row;
|
|
18
|
+
const fallback = record.key || record.id;
|
|
19
|
+
return fallback ? String(fallback) : generateIdFromIndex(index, parent);
|
|
20
|
+
}, [rowKey]);
|
|
21
|
+
return {
|
|
22
|
+
getRowKey
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
useRowKey
|
|
27
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
const useScrollSync = (refs) => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
const nodes = refs.current;
|
|
5
|
+
if (!nodes.length) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const scrollHandler = (event) => {
|
|
9
|
+
nodes.forEach((elem) => {
|
|
10
|
+
if (elem !== event.currentTarget) {
|
|
11
|
+
elem.scrollLeft = event.currentTarget?.scrollLeft;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
nodes.forEach((elem) => elem.addEventListener("scroll", scrollHandler));
|
|
16
|
+
return () => {
|
|
17
|
+
nodes.forEach((elem) => elem.removeEventListener("scroll", scrollHandler));
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useScrollSync
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { SharedTableProps, TableProps, VirtualTableProps } from '../Table.types';
|
|
3
|
+
type UseTableProps<TData, TValue> = Pick<VirtualTableProps<TData, TValue>, 'infiniteScroll'> & Pick<TableProps<TData, TValue>, 'pagination'> & Pick<SharedTableProps<TData, TValue>, 'data' | 'selectionConfig' | 'columns' | 'rowKey' | 'onSort' | 'expandable' | 'selectedRowKeys'> & {
|
|
4
|
+
wrapperRef: MutableRefObject<HTMLDivElement | null>;
|
|
5
|
+
requireColumnSizing?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const useTable: <TData, TValue>({ data, selectionConfig, columns, rowKey, wrapperRef, infiniteScroll, pagination, onSort, expandable, selectedRowKeys, requireColumnSizing, }: UseTableProps<TData, TValue>) => {
|
|
8
|
+
table: import('@tanstack/react-table').Table<TData>;
|
|
9
|
+
paginationProps: {} | {};
|
|
10
|
+
hasPagination: boolean;
|
|
11
|
+
columnSizing: import('@tanstack/react-table').ColumnSizingState;
|
|
12
|
+
isColumnSizingReady: boolean;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { useState, useEffect, useRef, useLayoutEffect, useCallback, useMemo } from "react";
|
|
2
|
+
import { useReactTable, getGroupedRowModel, getExpandedRowModel, getPaginationRowModel, getSortedRowModel, getCoreRowModel } from "@tanstack/react-table";
|
|
3
|
+
import { EMPTY_SORT_STATE } from "../Table.const.js";
|
|
4
|
+
import { arrayToTrueMap } from "../utils/arrayToTrueMap.js";
|
|
5
|
+
import { compareKeys } from "../utils/compareKeys.js";
|
|
6
|
+
import { getChildrenColumnName } from "../utils/getChildrenColumnName.js";
|
|
7
|
+
import { getPaginationConfig } from "../utils/getPaginationConfig.js";
|
|
8
|
+
import { useColumnSizing } from "./useColumnSizing.js";
|
|
9
|
+
import { useRowKey } from "./useRowKey.js";
|
|
10
|
+
const useTable = ({
|
|
11
|
+
data,
|
|
12
|
+
selectionConfig,
|
|
13
|
+
columns,
|
|
14
|
+
rowKey,
|
|
15
|
+
wrapperRef,
|
|
16
|
+
infiniteScroll,
|
|
17
|
+
pagination,
|
|
18
|
+
onSort,
|
|
19
|
+
expandable,
|
|
20
|
+
selectedRowKeys,
|
|
21
|
+
requireColumnSizing = true
|
|
22
|
+
}) => {
|
|
23
|
+
const [rowSelection, setRowSelection] = useState({});
|
|
24
|
+
const [sorting, setSorting] = useState([]);
|
|
25
|
+
const childrenColumnName = getChildrenColumnName(expandable?.childrenColumnName);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const localSelectionKeys = Object.keys(rowSelection);
|
|
28
|
+
if (selectedRowKeys && !compareKeys(selectedRowKeys, localSelectionKeys)) {
|
|
29
|
+
setRowSelection(arrayToTrueMap(selectedRowKeys));
|
|
30
|
+
}
|
|
31
|
+
}, [selectedRowKeys]);
|
|
32
|
+
const dataRef = useRef(data);
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
dataRef.current = data;
|
|
35
|
+
}, [data]);
|
|
36
|
+
const {
|
|
37
|
+
getRowKey
|
|
38
|
+
} = useRowKey(rowKey);
|
|
39
|
+
const memoizedGetRowKey = useCallback((row, index) => getRowKey(row, index), [getRowKey]);
|
|
40
|
+
const handleSortingChange = useCallback((updaterOrValue) => {
|
|
41
|
+
setSorting((oldSorting) => {
|
|
42
|
+
const newSorting = typeof updaterOrValue === "function" ? updaterOrValue(oldSorting) : updaterOrValue;
|
|
43
|
+
if (onSort) {
|
|
44
|
+
if (newSorting.length) {
|
|
45
|
+
const singleColumnSort = newSorting[0];
|
|
46
|
+
const sortState = {};
|
|
47
|
+
newSorting.forEach((column, index) => {
|
|
48
|
+
sortState[column.id] = {
|
|
49
|
+
sortOrder: column.desc ? "descend" : "ascend",
|
|
50
|
+
multiple: index
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
onSort({
|
|
54
|
+
columnKey: singleColumnSort.id,
|
|
55
|
+
order: singleColumnSort.desc ? "descend" : "ascend"
|
|
56
|
+
}, sortState);
|
|
57
|
+
} else {
|
|
58
|
+
onSort(...EMPTY_SORT_STATE);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return newSorting;
|
|
62
|
+
});
|
|
63
|
+
}, [onSort]);
|
|
64
|
+
const handleSelectionChange = useCallback((updaterOrValue) => {
|
|
65
|
+
setRowSelection((oldSelection) => {
|
|
66
|
+
const newSelection = typeof updaterOrValue === "function" ? updaterOrValue(oldSelection) : updaterOrValue;
|
|
67
|
+
if (selectionConfig?.onChange) {
|
|
68
|
+
const ids = Object.keys(newSelection);
|
|
69
|
+
const items = dataRef.current.filter((item, index) => ids.includes(memoizedGetRowKey(item, index)));
|
|
70
|
+
selectionConfig?.onChange(ids, items);
|
|
71
|
+
}
|
|
72
|
+
return newSelection;
|
|
73
|
+
});
|
|
74
|
+
}, [selectionConfig, memoizedGetRowKey]);
|
|
75
|
+
const columnWidths = useMemo(() => columns.map((column) => ({
|
|
76
|
+
id: column.id,
|
|
77
|
+
minWidth: column.minSize ?? (column.meta?.minWidth ? parseInt(`${column.meta?.minWidth}`) : void 0),
|
|
78
|
+
width: column.size ?? (column.meta?.width ? parseInt(`${column.meta?.width}`) : void 0),
|
|
79
|
+
maxWidth: column.maxSize ?? (column.meta?.maxWidth ? parseInt(`${column.meta?.maxWidth}`) : void 0)
|
|
80
|
+
})), [columns]);
|
|
81
|
+
const hasAnyColumnWidth = columnWidths.some((col) => col.width !== void 0 || col.minWidth !== void 0 || col.maxWidth !== void 0);
|
|
82
|
+
const {
|
|
83
|
+
columnSizing,
|
|
84
|
+
isColumnSizingReady
|
|
85
|
+
} = useColumnSizing({
|
|
86
|
+
columnWidths,
|
|
87
|
+
wrapperRef,
|
|
88
|
+
enabled: requireColumnSizing || hasAnyColumnWidth
|
|
89
|
+
});
|
|
90
|
+
const {
|
|
91
|
+
rightPinnedColumns,
|
|
92
|
+
leftPinnedColumns
|
|
93
|
+
} = useMemo(() => {
|
|
94
|
+
const right = [];
|
|
95
|
+
const left = [];
|
|
96
|
+
columns.forEach((column) => {
|
|
97
|
+
if (column.meta?.fixed === "right") {
|
|
98
|
+
right.push(column.id);
|
|
99
|
+
}
|
|
100
|
+
if (column.meta?.fixed === "left") {
|
|
101
|
+
left.push(column.id);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
rightPinnedColumns: right,
|
|
106
|
+
leftPinnedColumns: left
|
|
107
|
+
};
|
|
108
|
+
}, [columns]);
|
|
109
|
+
const hasPagination = !infiniteScroll && pagination !== false;
|
|
110
|
+
const {
|
|
111
|
+
initialState: paginationInitialState,
|
|
112
|
+
...paginationProps
|
|
113
|
+
} = getPaginationConfig(!infiniteScroll && pagination);
|
|
114
|
+
const getSubRows = useCallback((row) => {
|
|
115
|
+
return row[childrenColumnName];
|
|
116
|
+
}, [childrenColumnName]);
|
|
117
|
+
const expandedKeys = expandable?.expandedRowKeys ? arrayToTrueMap(expandable?.expandedRowKeys) : void 0;
|
|
118
|
+
const table = useReactTable({
|
|
119
|
+
getRowId: memoizedGetRowKey,
|
|
120
|
+
data,
|
|
121
|
+
columns,
|
|
122
|
+
getSubRows: childrenColumnName ? getSubRows : void 0,
|
|
123
|
+
getCoreRowModel: getCoreRowModel(),
|
|
124
|
+
getSortedRowModel: getSortedRowModel(),
|
|
125
|
+
getPaginationRowModel: hasPagination ? getPaginationRowModel() : void 0,
|
|
126
|
+
getExpandedRowModel: expandable ? getExpandedRowModel() : void 0,
|
|
127
|
+
getGroupedRowModel: getGroupedRowModel(),
|
|
128
|
+
onRowSelectionChange: handleSelectionChange,
|
|
129
|
+
onExpandedChange: () => {
|
|
130
|
+
},
|
|
131
|
+
onSortingChange: handleSortingChange,
|
|
132
|
+
enableRowSelection: (row) => {
|
|
133
|
+
const {
|
|
134
|
+
unavailable,
|
|
135
|
+
disabled
|
|
136
|
+
} = selectionConfig?.checkRowSelectionStatus?.(row.original) || {};
|
|
137
|
+
return !!selectionConfig && !unavailable && !disabled;
|
|
138
|
+
},
|
|
139
|
+
manualExpanding: !!expandable?.expandedRowKeys,
|
|
140
|
+
initialState: {
|
|
141
|
+
columnPinning: {
|
|
142
|
+
right: rightPinnedColumns,
|
|
143
|
+
left: leftPinnedColumns
|
|
144
|
+
},
|
|
145
|
+
...paginationInitialState,
|
|
146
|
+
expanded: expandedKeys
|
|
147
|
+
},
|
|
148
|
+
state: {
|
|
149
|
+
columnPinning: {
|
|
150
|
+
right: rightPinnedColumns,
|
|
151
|
+
left: leftPinnedColumns
|
|
152
|
+
},
|
|
153
|
+
sorting,
|
|
154
|
+
rowSelection,
|
|
155
|
+
expanded: expandedKeys
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
table,
|
|
160
|
+
paginationProps,
|
|
161
|
+
hasPagination,
|
|
162
|
+
columnSizing,
|
|
163
|
+
isColumnSizingReady
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export {
|
|
167
|
+
useTable
|
|
168
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Table } from './Table';
|
|
2
|
+
export { VirtualTable } from './VirtualTable';
|
|
3
|
+
/** @deprecated */
|
|
4
|
+
export * as TableCell from './components/Cell';
|
|
5
|
+
export * from './components/Cell';
|
|
6
|
+
export * from './Table.types';
|
|
7
|
+
export * from './Table.const';
|
|
8
|
+
export { legacyColumnConfigAdapter } from './utils/legacyColumnConfigAdapter';
|
|
9
|
+
export { type ColumnDef, type Row, type CellContext, type HeaderContext, } from '@tanstack/react-table';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Table } from "./Table.js";
|
|
2
|
+
import { VirtualTable } from "./VirtualTable.js";
|
|
3
|
+
import * as components_Cell_index from "./components/Cell/index.js";
|
|
4
|
+
import { ACTION_COLUMN_ID, BOTTOM_BORDER_WIDTH, DEFAULT_CELL_HEIGHT, DEFAULT_PAGINATION_CONFIG, DEFAULT_STICKY_VALUE, EMPTY_SORT_STATE, EXPANDED_ROW_PROPERTY, INFINITE_LOADER_ITEM_HEIGHT, INFINITE_SCROLL_PADDING_START, INFINITE_SCROLL_TRIGGER_THRESHOLD, SELECTION_ALL, SELECTION_COLUMN_ID, SELECTION_INVERT } from "./Table.const.js";
|
|
5
|
+
import { legacyColumnConfigAdapter } from "./utils/legacyColumnConfigAdapter.js";
|
|
6
|
+
import { ActionCell } from "./components/Cell/Action/ActionCell.js";
|
|
7
|
+
import { AvatarLabelCell } from "./components/Cell/AvatarLabel/AvatarLabel.js";
|
|
8
|
+
import { CopyableCell } from "./components/Cell/Copyable/CopyableCell.js";
|
|
9
|
+
import { EditableCell } from "./components/Cell/Editable/EditableCell.js";
|
|
10
|
+
import { FlagLabelCell } from "./components/Cell/FlagLabel/FlagLabelCell.js";
|
|
11
|
+
import { IconLabelCell } from "./components/Cell/IconLabel/IconLabel.js";
|
|
12
|
+
import { IconTooltipCell } from "./components/Cell/IconTooltipCell/IconTooltipCell.js";
|
|
13
|
+
import { InputNumberCell } from "./components/Cell/InputNumber/InputNumberCell.js";
|
|
14
|
+
import { LabelsWithShowMore } from "./components/Cell/LabelsWithShowMore/LabelsWithShowMore.js";
|
|
15
|
+
import { StarCell } from "./components/Cell/Star/StarCell.js";
|
|
16
|
+
import { StatusLabelCell } from "./components/Cell/StatusLabel/StatusLabel.js";
|
|
17
|
+
import { TagIconCell } from "./components/Cell/TagIcon/TagIcon.js";
|
|
18
|
+
import { TagsGroupCell } from "./components/Cell/TagsGroup/TagsGroup.js";
|
|
19
|
+
export {
|
|
20
|
+
ACTION_COLUMN_ID,
|
|
21
|
+
ActionCell,
|
|
22
|
+
AvatarLabelCell,
|
|
23
|
+
BOTTOM_BORDER_WIDTH,
|
|
24
|
+
CopyableCell,
|
|
25
|
+
DEFAULT_CELL_HEIGHT,
|
|
26
|
+
DEFAULT_PAGINATION_CONFIG,
|
|
27
|
+
DEFAULT_STICKY_VALUE,
|
|
28
|
+
EMPTY_SORT_STATE,
|
|
29
|
+
EXPANDED_ROW_PROPERTY,
|
|
30
|
+
EditableCell,
|
|
31
|
+
FlagLabelCell,
|
|
32
|
+
INFINITE_LOADER_ITEM_HEIGHT,
|
|
33
|
+
INFINITE_SCROLL_PADDING_START,
|
|
34
|
+
INFINITE_SCROLL_TRIGGER_THRESHOLD,
|
|
35
|
+
IconLabelCell,
|
|
36
|
+
IconTooltipCell,
|
|
37
|
+
InputNumberCell,
|
|
38
|
+
LabelsWithShowMore,
|
|
39
|
+
SELECTION_ALL,
|
|
40
|
+
SELECTION_COLUMN_ID,
|
|
41
|
+
SELECTION_INVERT,
|
|
42
|
+
StarCell,
|
|
43
|
+
StatusLabelCell,
|
|
44
|
+
Table,
|
|
45
|
+
components_Cell_index as TableCell,
|
|
46
|
+
TagIconCell,
|
|
47
|
+
TagsGroupCell,
|
|
48
|
+
VirtualTable,
|
|
49
|
+
legacyColumnConfigAdapter
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CellContext, HeaderContext, RowData, ColumnDefTemplate } from '@tanstack/react-table';
|
|
2
|
+
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
3
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
4
|
+
declare module '@tanstack/react-table' {
|
|
5
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
6
|
+
minWidth?: number | string;
|
|
7
|
+
maxWidth?: number | string;
|
|
8
|
+
width?: number | string;
|
|
9
|
+
fixed?: 'left' | 'right';
|
|
10
|
+
style?: CSSProperties<HTMLTableHeaderCellElement>;
|
|
11
|
+
sortRender?: 'string' | 'default';
|
|
12
|
+
sortOrder?: 'ascend' | 'descend' | null;
|
|
13
|
+
renderCustomSortButton?: (
|
|
14
|
+
headerContext: HeaderContext<TData, TValue>,
|
|
15
|
+
) => ReactNode;
|
|
16
|
+
childCell?: ColumnDefTemplate<CellContext<TData, TValue>>;
|
|
17
|
+
skeletonCell?: () => ReactNode;
|
|
18
|
+
dataIndex?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
enableMultiSort?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Returns tooltip props for cells in this column, or false to disable tooltip.
|
|
23
|
+
* When provided, the cell content is wrapped in a Tooltip component.
|
|
24
|
+
*/
|
|
25
|
+
getCellTooltipProps?: (row: TData) => TooltipProps | false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const arrayToTrueMap: <T extends string | number | symbol>(items: readonly T[]) => Record<T, true>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calculatePixels: (value: number | string | undefined) => number | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import toPx from "unit-to-px";
|
|
2
|
+
const hasSameLength = (parsedValue, originalValue) => `${parsedValue}`.length === `${originalValue}`.length;
|
|
3
|
+
const calculatePixels = (value) => {
|
|
4
|
+
if (typeof value === "number") {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
const isWhiteSpaceString = typeof value === "string" && !value.trim();
|
|
8
|
+
if (!value || isWhiteSpaceString) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
if (typeof value !== "number" && !Number.isNaN(value) && !Number.isNaN(parseFloat(value))) {
|
|
12
|
+
const parsedNumber = parseFloat(value);
|
|
13
|
+
if (hasSameLength(parsedNumber, value)) {
|
|
14
|
+
return parsedNumber;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return toPx(value);
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
calculatePixels
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const compareKeys: (a: string[], b: string[]) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const compareKeys = (a, b) => {
|
|
2
|
+
const sa = new Set(a);
|
|
3
|
+
const sb = new Set(b);
|
|
4
|
+
if (sa.size !== sb.size) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
for (const v of sa) {
|
|
8
|
+
if (!sb.has(v)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
compareKeys
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getChildrenColumnName: <TData>(childrenColumnName?: keyof TData) => "children" | keyof TData;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SkeletonAvatar } from "@synerise/ds-skeleton";
|
|
3
|
+
import { AvatarLabelCell } from "../components/Cell/AvatarLabel/AvatarLabel.js";
|
|
4
|
+
import { TableSkeletonCell, Skeleton } from "../components/TableBody/TableBodySkeleton/TableBodySkeleton.styles.js";
|
|
5
|
+
const getDefaultSkeletonColumns = () => {
|
|
6
|
+
const renderTitleSkeleton = (skeletonWidth) => /* @__PURE__ */ jsx(TableSkeletonCell, { children: /* @__PURE__ */ jsx(Skeleton, { skeletonWidth, numberOfSkeletons: 1, width: "M" }) });
|
|
7
|
+
const renderCellSkeleton = () => /* @__PURE__ */ jsx(TableSkeletonCell, { children: /* @__PURE__ */ jsx(Skeleton, { numberOfSkeletons: 1, size: "M" }) });
|
|
8
|
+
const renderAvatarCell = () => /* @__PURE__ */ jsx(TableSkeletonCell, { children: /* @__PURE__ */ jsx(AvatarLabelCell, { title: /* @__PURE__ */ jsx(Skeleton, { skeletonWidth: "120px", numberOfSkeletons: 1, width: "M" }), avatar: /* @__PURE__ */ jsx(SkeletonAvatar, { shape: "square", size: "M" }) }) });
|
|
9
|
+
const buildMeta = (skeletonCell, width, minWidth) => ({
|
|
10
|
+
...minWidth !== void 0 ? {
|
|
11
|
+
minWidth
|
|
12
|
+
} : {},
|
|
13
|
+
...width !== void 0 ? {
|
|
14
|
+
width
|
|
15
|
+
} : {},
|
|
16
|
+
childCell: () => null,
|
|
17
|
+
skeletonCell
|
|
18
|
+
});
|
|
19
|
+
const columns = [{
|
|
20
|
+
accessorKey: "undefined",
|
|
21
|
+
header: () => renderTitleSkeleton("140px"),
|
|
22
|
+
meta: buildMeta(renderAvatarCell, 350),
|
|
23
|
+
size: 350,
|
|
24
|
+
enableSorting: false,
|
|
25
|
+
id: "col-0"
|
|
26
|
+
}, {
|
|
27
|
+
accessorKey: "undefined",
|
|
28
|
+
header: () => "",
|
|
29
|
+
meta: buildMeta(() => /* @__PURE__ */ jsx(Fragment, {}), void 0, 100),
|
|
30
|
+
enableSorting: false,
|
|
31
|
+
id: "col-1"
|
|
32
|
+
}, {
|
|
33
|
+
accessorKey: "undefined",
|
|
34
|
+
header: () => renderTitleSkeleton(),
|
|
35
|
+
meta: buildMeta(renderCellSkeleton, 120),
|
|
36
|
+
size: 120,
|
|
37
|
+
enableSorting: false,
|
|
38
|
+
id: "col-2"
|
|
39
|
+
}, {
|
|
40
|
+
accessorKey: "undefined",
|
|
41
|
+
header: () => renderTitleSkeleton(),
|
|
42
|
+
meta: buildMeta(renderCellSkeleton, 212),
|
|
43
|
+
size: 212,
|
|
44
|
+
enableSorting: false,
|
|
45
|
+
id: "col-3"
|
|
46
|
+
}, {
|
|
47
|
+
accessorKey: "undefined",
|
|
48
|
+
header: () => renderTitleSkeleton(),
|
|
49
|
+
meta: buildMeta(renderCellSkeleton, 120),
|
|
50
|
+
size: 120,
|
|
51
|
+
enableSorting: false,
|
|
52
|
+
id: "col-4"
|
|
53
|
+
}];
|
|
54
|
+
return columns;
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
getDefaultSkeletonColumns
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { INFINITE_LOADER_ITEM_HEIGHT } from "../Table.const.js";
|
|
2
|
+
const getInfiniteScrollPadding = (infiniteScroll) => {
|
|
3
|
+
if (!infiniteScroll) {
|
|
4
|
+
return 0;
|
|
5
|
+
}
|
|
6
|
+
if (infiniteScroll.prevPage?.hasMore) {
|
|
7
|
+
return 2 * INFINITE_LOADER_ITEM_HEIGHT;
|
|
8
|
+
}
|
|
9
|
+
return INFINITE_LOADER_ITEM_HEIGHT;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
getInfiniteScrollPadding
|
|
13
|
+
};
|