@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,3 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TableBodyProps } from '../../Table.types';
|
|
3
|
+
export declare const TableBody: <TData extends object, TValue>({ cellHeight, infiniteScroll, onRowClick, getRowTooltipProps, emptyDataComponent, texts, }: TableBodyProps<TData, TValue>) => React.JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { DEFAULT_CELL_HEIGHT } from "../../Table.const.js";
|
|
4
|
+
import { useTableContext } from "../../contexts/TableContext.js";
|
|
5
|
+
import { TBody } from "./TableBody.styles.js";
|
|
6
|
+
import { TableEmptyBody } from "./TableEmptyBody/TableEmptyBody.js";
|
|
7
|
+
import { TableRow } from "./TableRow/TableRow.js";
|
|
8
|
+
import { TableRowVirtual } from "./TableRow/TableRowVirtual.js";
|
|
9
|
+
const TableBody = ({
|
|
10
|
+
cellHeight = DEFAULT_CELL_HEIGHT,
|
|
11
|
+
infiniteScroll,
|
|
12
|
+
onRowClick,
|
|
13
|
+
getRowTooltipProps,
|
|
14
|
+
emptyDataComponent,
|
|
15
|
+
texts
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
table,
|
|
19
|
+
rowVirtualizer
|
|
20
|
+
} = useTableContext();
|
|
21
|
+
const tbodyRef = useRef(null);
|
|
22
|
+
const virtualItems = rowVirtualizer ? rowVirtualizer.getVirtualItems() : [];
|
|
23
|
+
const allRows = table.getRowModel().flatRows;
|
|
24
|
+
return allRows.length ? /* @__PURE__ */ jsx(TBody, { "data-testid": "ds-table-body", ref: tbodyRef, role: "rowgroup", "data-popup-container": true, style: rowVirtualizer && virtualItems.length ? {
|
|
25
|
+
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
26
|
+
position: "relative"
|
|
27
|
+
} : void 0, children: rowVirtualizer && virtualItems.length ? (
|
|
28
|
+
// Virtualized: place spacer and absolutely-positioned rows
|
|
29
|
+
virtualItems.map((virtual) => {
|
|
30
|
+
const row = allRows[virtual.index];
|
|
31
|
+
return /* @__PURE__ */ jsx(TableRowVirtual, { virtual, cellHeight, row, texts, onRowClick, getRowTooltipProps, rowIndex: virtual.index, infiniteScroll, isLast: virtual.index === allRows.length - 1, isExpanded: row.getIsExpanded(), isParentExpanded: row.getIsAllParentsExpanded() }, row.id);
|
|
32
|
+
})
|
|
33
|
+
) : (
|
|
34
|
+
// Non-virtualized: render all rows in the normal flow
|
|
35
|
+
allRows.map((row) => /* @__PURE__ */ jsx(TableRow, { onRowClick, getRowTooltipProps, row, isSelected: row.getIsSelected(), isExpanded: row.getIsExpanded(), isParentExpanded: row.getIsAllParentsExpanded() }, row.id))
|
|
36
|
+
) }, "virtual-table-body") : /* @__PURE__ */ jsx(TableEmptyBody, { emptyDataComponent, texts });
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
TableBody
|
|
40
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { commonRowStyles } from "../../Table.styles.js";
|
|
3
|
+
import { Td } from "./TableCell/TableCell.styles.js";
|
|
4
|
+
const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
5
|
+
displayName: "TableBodystyles__Tr",
|
|
6
|
+
componentId: "sc-1dty8xx-0"
|
|
7
|
+
})(["", " &:hover{", "{background:", ";}}"], commonRowStyles, Td, (props) => props.theme.palette["grey-050"]);
|
|
8
|
+
const TBody = /* @__PURE__ */ styled.tbody.withConfig({
|
|
9
|
+
displayName: "TableBodystyles__TBody",
|
|
10
|
+
componentId: "sc-1dty8xx-1"
|
|
11
|
+
})(["position:relative;"]);
|
|
12
|
+
export {
|
|
13
|
+
TBody,
|
|
14
|
+
Tr
|
|
15
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useMemo } from "react";
|
|
3
|
+
import { useTableContext } from "../../../contexts/TableContext.js";
|
|
4
|
+
import { TableCell } from "../TableCell/TableCell.js";
|
|
5
|
+
import { Tr, TableSkeletonCell, Skeleton, TBody } from "./TableBodySkeleton.styles.js";
|
|
6
|
+
const TableBodySkeleton = ({
|
|
7
|
+
cellHeight,
|
|
8
|
+
wrapperRef
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
table,
|
|
12
|
+
getScrollContainer
|
|
13
|
+
} = useTableContext();
|
|
14
|
+
const headerGroups = table.getHeaderGroups();
|
|
15
|
+
const [availableSpace, setAvailableSpace] = useState();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const container = getScrollContainer();
|
|
18
|
+
if (container && wrapperRef.current) {
|
|
19
|
+
const y1 = container.getBoundingClientRect().top;
|
|
20
|
+
const y2 = wrapperRef.current.getBoundingClientRect().top;
|
|
21
|
+
setAvailableSpace(container.offsetHeight - (y2 - y1));
|
|
22
|
+
}
|
|
23
|
+
}, [getScrollContainer, wrapperRef]);
|
|
24
|
+
const rowCount = useMemo(() => {
|
|
25
|
+
const container = getScrollContainer();
|
|
26
|
+
if (!container) {
|
|
27
|
+
return 5;
|
|
28
|
+
}
|
|
29
|
+
return availableSpace ? Math.floor(availableSpace / cellHeight) : 0;
|
|
30
|
+
}, [availableSpace, cellHeight, getScrollContainer]);
|
|
31
|
+
const skeletonRows = useMemo(() => {
|
|
32
|
+
return Array.from({
|
|
33
|
+
length: rowCount
|
|
34
|
+
}, (_, rowIndex) => headerGroups.map((headerGroup) => /* @__PURE__ */ jsx(Tr, { role: "row", children: headerGroup.headers.map((header, columnIndex) => {
|
|
35
|
+
return /* @__PURE__ */ jsx(TableCell, { isSorted: !!header.column.getIsSorted(), headerIndex: columnIndex, width: header.column.getSize(), height: cellHeight, isPinned: header.column.getIsPinned(), rightOffset: header.column.getAfter("right"), leftOffset: header.column.getStart("left"), children: header.column.columnDef.meta?.skeletonCell ? header.column.columnDef.meta?.skeletonCell() : /* @__PURE__ */ jsx(TableSkeletonCell, { children: /* @__PURE__ */ jsx(Skeleton, { numberOfSkeletons: 1, size: "M" }) }) }, header.id);
|
|
36
|
+
}) }, `${headerGroup.id}-${rowIndex}`)));
|
|
37
|
+
}, [cellHeight, headerGroups, rowCount]);
|
|
38
|
+
return /* @__PURE__ */ jsx(TBody, { role: "rowgroup", children: skeletonRows });
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
TableBodySkeleton
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const Tr: import('styled-components').StyledComponent<"tr", any, {}, never>;
|
|
2
|
+
export declare const TBody: import('styled-components').StyledComponent<"tbody", any, {}, never>;
|
|
3
|
+
export declare const Td: import('styled-components').StyledComponent<"td", any, {
|
|
4
|
+
$width?: number;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const TableSkeletonCell: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const Skeleton: import('styled-components').StyledComponent<({ size, numberOfSkeletons, width, height, className, }: import('@synerise/ds-skeleton').SkeletonProps) => React.JSX.Element, any, {
|
|
8
|
+
skeletonWidth?: string;
|
|
9
|
+
}, never>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import DSSkeleton from "@synerise/ds-skeleton";
|
|
3
|
+
import { commonCellStyles, commonRowStyles } from "../../../Table.styles.js";
|
|
4
|
+
const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
5
|
+
displayName: "TableBodySkeletonstyles__Tr",
|
|
6
|
+
componentId: "sc-1fl88wn-0"
|
|
7
|
+
})(["", ""], commonRowStyles);
|
|
8
|
+
const TBody = /* @__PURE__ */ styled.tbody.withConfig({
|
|
9
|
+
displayName: "TableBodySkeletonstyles__TBody",
|
|
10
|
+
componentId: "sc-1fl88wn-1"
|
|
11
|
+
})(["position:relative;"]);
|
|
12
|
+
const Td = /* @__PURE__ */ styled.td.withConfig({
|
|
13
|
+
displayName: "TableBodySkeletonstyles__Td",
|
|
14
|
+
componentId: "sc-1fl88wn-2"
|
|
15
|
+
})(["", " padding:16px 24px;", ";"], commonCellStyles, (props) => props.$width ? `width: ${props.$width}px` : "");
|
|
16
|
+
const TableSkeletonCell = /* @__PURE__ */ styled.div.withConfig({
|
|
17
|
+
displayName: "TableBodySkeletonstyles__TableSkeletonCell",
|
|
18
|
+
componentId: "sc-1fl88wn-3"
|
|
19
|
+
})(["align-items:center;justify-content:flex-start;width:100%;"]);
|
|
20
|
+
const Skeleton = /* @__PURE__ */ styled(DSSkeleton).withConfig({
|
|
21
|
+
displayName: "TableBodySkeletonstyles__Skeleton",
|
|
22
|
+
componentId: "sc-1fl88wn-4"
|
|
23
|
+
})(["padding:0;", ""], (props) => props.skeletonWidth && `width: ${props.skeletonWidth};`);
|
|
24
|
+
export {
|
|
25
|
+
Skeleton,
|
|
26
|
+
TBody,
|
|
27
|
+
TableSkeletonCell,
|
|
28
|
+
Td,
|
|
29
|
+
Tr
|
|
30
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
3
|
+
type TableCellProps = WithHTMLAttributes<HTMLTableCellElement, {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
colSpan?: number;
|
|
8
|
+
isSorted?: boolean;
|
|
9
|
+
isPinned?: 'right' | 'left' | false;
|
|
10
|
+
rightOffset?: number;
|
|
11
|
+
leftOffset?: number;
|
|
12
|
+
cellKey?: string;
|
|
13
|
+
headerIndex?: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const TableCell: React.MemoExoticComponent<({ children, width, height, isSorted, colSpan, isPinned, headerIndex, rightOffset, leftOffset, cellKey, ...rest }: TableCellProps) => React.JSX.Element>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Td, CellWrapper } from "./TableCell.styles.js";
|
|
4
|
+
const TableCell = memo(({
|
|
5
|
+
children,
|
|
6
|
+
width,
|
|
7
|
+
height,
|
|
8
|
+
isSorted,
|
|
9
|
+
colSpan,
|
|
10
|
+
isPinned,
|
|
11
|
+
headerIndex,
|
|
12
|
+
rightOffset,
|
|
13
|
+
leftOffset,
|
|
14
|
+
cellKey,
|
|
15
|
+
...rest
|
|
16
|
+
}) => /* @__PURE__ */ jsx(Td, { $height: height, $width: width, isSorted, role: "cell", colSpan, isPinned, rightOffset, leftOffset, headerIndex, ...rest, children: /* @__PURE__ */ jsx(CellWrapper, { children }) }, cellKey));
|
|
17
|
+
export {
|
|
18
|
+
TableCell
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CellWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const Td: import('styled-components').StyledComponent<"td", any, {
|
|
3
|
+
$height?: number;
|
|
4
|
+
$width?: number;
|
|
5
|
+
isSorted?: boolean;
|
|
6
|
+
headerIndex?: number;
|
|
7
|
+
isPinned?: "left" | "right" | false;
|
|
8
|
+
rightOffset?: number;
|
|
9
|
+
leftOffset?: number;
|
|
10
|
+
}, never>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { commonCellStyles, commonPinnedStyles } from "../../../Table.styles.js";
|
|
3
|
+
const CellWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
4
|
+
displayName: "TableCellstyles__CellWrapper",
|
|
5
|
+
componentId: "sc-1sq3dd7-0"
|
|
6
|
+
})(["overflow:hidden;"]);
|
|
7
|
+
const Td = /* @__PURE__ */ styled.td.withConfig({
|
|
8
|
+
displayName: "TableCellstyles__Td",
|
|
9
|
+
componentId: "sc-1sq3dd7-1"
|
|
10
|
+
})(["", " ", " &&&&{", ";}", ";", ";", "{display:flex;align-items:center;width:100%;}"], commonCellStyles, commonPinnedStyles, (props) => props.isSorted && `background-color: ${props.theme.palette["blue-050"]}`, (props) => props.headerIndex !== void 0 ? `width: var(--col-${props.headerIndex}-width)` : props.$width && `width: ${props.$width}px`, (props) => props.$height ? `
|
|
11
|
+
padding: 0 24px;
|
|
12
|
+
height: ${props.$height}px` : `
|
|
13
|
+
padding: 16px 24px;
|
|
14
|
+
`, CellWrapper);
|
|
15
|
+
export {
|
|
16
|
+
CellWrapper,
|
|
17
|
+
Td
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
3
|
+
import Result from "@synerise/ds-result";
|
|
4
|
+
import { useTableContext } from "../../../contexts/TableContext.js";
|
|
5
|
+
import { TBody, Tr, Td, TableEmptyBodyWrapper } from "./TableEmptyBody.styles.js";
|
|
6
|
+
const TableEmptyBody = ({
|
|
7
|
+
emptyDataComponent,
|
|
8
|
+
texts
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
table
|
|
12
|
+
} = useTableContext();
|
|
13
|
+
const colSpan = table.getAllLeafColumns().length;
|
|
14
|
+
return /* @__PURE__ */ jsx(TBody, { children: /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan, children: /* @__PURE__ */ jsx(TableEmptyBodyWrapper, { children: emptyDataComponent !== void 0 ? emptyDataComponent : /* @__PURE__ */ jsx(Result, { description: texts.emptyText || /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TABLE.EMPTY_TEXT" }), type: "no-results", noSearchResults: true }) }) }) }) });
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
TableEmptyBody
|
|
18
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Tr: import('styled-components').StyledComponent<"tr", any, {}, never>;
|
|
2
|
+
export declare const Td: import('styled-components').StyledComponent<"td", any, {}, never>;
|
|
3
|
+
export declare const TBody: import('styled-components').StyledComponent<"tbody", any, {}, never>;
|
|
4
|
+
export declare const TableEmptyBodyWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
3
|
+
displayName: "TableEmptyBodystyles__Tr",
|
|
4
|
+
componentId: "sc-14kyiyc-0"
|
|
5
|
+
})([""]);
|
|
6
|
+
const Td = /* @__PURE__ */ styled.td.withConfig({
|
|
7
|
+
displayName: "TableEmptyBodystyles__Td",
|
|
8
|
+
componentId: "sc-14kyiyc-1"
|
|
9
|
+
})([""]);
|
|
10
|
+
const TBody = /* @__PURE__ */ styled.tbody.withConfig({
|
|
11
|
+
displayName: "TableEmptyBodystyles__TBody",
|
|
12
|
+
componentId: "sc-14kyiyc-2"
|
|
13
|
+
})(["position:relative;"]);
|
|
14
|
+
const TableEmptyBodyWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
15
|
+
displayName: "TableEmptyBodystyles__TableEmptyBodyWrapper",
|
|
16
|
+
componentId: "sc-14kyiyc-3"
|
|
17
|
+
})(["min-height:160px;display:flex;align-items:center;"]);
|
|
18
|
+
export {
|
|
19
|
+
TBody,
|
|
20
|
+
TableEmptyBodyWrapper,
|
|
21
|
+
Td,
|
|
22
|
+
Tr
|
|
23
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { InfiniteLoaderRowTexts } from '../../../../Table.types';
|
|
3
|
+
type ErrorItemProps = {
|
|
4
|
+
onRetryClick?: () => void;
|
|
5
|
+
texts: InfiniteLoaderRowTexts;
|
|
6
|
+
};
|
|
7
|
+
export declare const ErrorItem: ({ onRetryClick, texts }: ErrorItemProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import Icon, { RefreshM } from "@synerise/ds-icon";
|
|
4
|
+
import InlineAlert from "@synerise/ds-inline-alert";
|
|
5
|
+
import { ErrorItemWrapper } from "./ErrorItem.styles.js";
|
|
6
|
+
const ErrorItem = ({
|
|
7
|
+
onRetryClick,
|
|
8
|
+
texts
|
|
9
|
+
}) => {
|
|
10
|
+
return /* @__PURE__ */ jsxs(ErrorItemWrapper, { children: [
|
|
11
|
+
/* @__PURE__ */ jsx(InlineAlert, { type: "alert", message: texts.infiniteScrollError }),
|
|
12
|
+
onRetryClick && /* @__PURE__ */ jsx(Button, { onClick: onRetryClick, type: "ghost", mode: "icon-label", icon: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(RefreshM, {}) }), style: {
|
|
13
|
+
marginLeft: 8
|
|
14
|
+
}, children: texts.infiniteScrollRetry })
|
|
15
|
+
] });
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
ErrorItem
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ErrorItemWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React, CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { InfiniteLoaderRowTexts, InfiniteScrollState } from '../../../../Table.types';
|
|
3
|
+
type InfiniteLoaderRowProps = {
|
|
4
|
+
position: 'TOP' | 'BOTTOM';
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
infiniteLoaderItemProps: InfiniteScrollState & {
|
|
8
|
+
handleRetryClick?: () => void;
|
|
9
|
+
};
|
|
10
|
+
loadMore?: () => void;
|
|
11
|
+
texts: InfiniteLoaderRowTexts;
|
|
12
|
+
};
|
|
13
|
+
export declare const InfiniteLoaderRow: ({ texts, style, loadMore, infiniteLoaderItemProps, }: InfiniteLoaderRowProps) => React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useTableContext } from "../../../../contexts/TableContext.js";
|
|
4
|
+
import { TableCell } from "../../TableCell/TableCell.js";
|
|
5
|
+
import { Tr } from "../TableRow.styles.js";
|
|
6
|
+
import { ErrorItem } from "./ErrorItem.js";
|
|
7
|
+
import { LoadingItem } from "./LoadingItem.js";
|
|
8
|
+
import { NoMoreItem } from "./NoMoreItem.js";
|
|
9
|
+
const InfiniteLoaderRow = ({
|
|
10
|
+
texts,
|
|
11
|
+
style,
|
|
12
|
+
loadMore,
|
|
13
|
+
infiniteLoaderItemProps
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
table,
|
|
17
|
+
rowVirtualizer
|
|
18
|
+
} = useTableContext();
|
|
19
|
+
const size = table.getTotalSize();
|
|
20
|
+
const {
|
|
21
|
+
hasError,
|
|
22
|
+
hasMore,
|
|
23
|
+
isLoading,
|
|
24
|
+
handleRetryClick
|
|
25
|
+
} = infiniteLoaderItemProps;
|
|
26
|
+
const autoLoadMore = !isLoading && hasMore && !hasError;
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (autoLoadMore && loadMore && !rowVirtualizer?.isScrolling) {
|
|
29
|
+
const timeout = setTimeout(loadMore, 0);
|
|
30
|
+
return () => {
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}, [loadMore, autoLoadMore, hasError, hasMore, rowVirtualizer, isLoading]);
|
|
35
|
+
return /* @__PURE__ */ jsxs(Tr, { style, role: "row", children: [
|
|
36
|
+
/* @__PURE__ */ jsxs(TableCell, { style: {
|
|
37
|
+
zIndex: 11
|
|
38
|
+
}, isPinned: "left", leftOffset: 0, width: 400, children: [
|
|
39
|
+
isLoading && /* @__PURE__ */ jsx(LoadingItem, { texts }),
|
|
40
|
+
!isLoading && !hasMore && /* @__PURE__ */ jsx(NoMoreItem, { texts }),
|
|
41
|
+
!isLoading && hasError && /* @__PURE__ */ jsx(ErrorItem, { texts, onRetryClick: handleRetryClick })
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ jsx(TableCell, { style: {
|
|
44
|
+
zIndex: 11
|
|
45
|
+
}, width: size - 400 })
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
InfiniteLoaderRow
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Loader: import('styled-components').StyledComponent<({ size, label, labelPosition, color, percent, percentFormatter, text, fontSize, mode, className, }: import('@synerise/ds-loader/dist/Loader.types').LoaderProps) => React.JSX.Element, any, {}, never>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import DSLoader from "@synerise/ds-loader";
|
|
3
|
+
const Loader = /* @__PURE__ */ styled(DSLoader).withConfig({
|
|
4
|
+
displayName: "LoadingItemstyles__Loader",
|
|
5
|
+
componentId: "sc-i54qqh-0"
|
|
6
|
+
})(["justify-content:flex-start;"]);
|
|
7
|
+
export {
|
|
8
|
+
Loader
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import InlineAlert from "@synerise/ds-inline-alert";
|
|
3
|
+
const NoMoreItem = ({
|
|
4
|
+
texts
|
|
5
|
+
}) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(InlineAlert, { type: "info", message: texts.infiniteScrollNoMoreData });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
NoMoreItem
|
|
10
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TableRowProps } from '../../../Table.types';
|
|
3
|
+
declare const TableRowInner: <TData extends object>({ row, onRowClick, getRowTooltipProps, }: TableRowProps<TData>) => React.JSX.Element;
|
|
4
|
+
export declare const TableRow: typeof TableRowInner;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
4
|
+
import { flexRender } from "@tanstack/react-table";
|
|
5
|
+
import { isSorted } from "../../../utils/sort.js";
|
|
6
|
+
import { TableCell } from "../TableCell/TableCell.js";
|
|
7
|
+
import { Tr } from "./TableRow.styles.js";
|
|
8
|
+
const TableRowInner = ({
|
|
9
|
+
row,
|
|
10
|
+
onRowClick,
|
|
11
|
+
getRowTooltipProps
|
|
12
|
+
}) => {
|
|
13
|
+
const rowContent = /* @__PURE__ */ jsx(Tr, { "data-row-depth": row.depth, "data-row-index": row.index, "data-index": row.index, role: "row", onClick: onRowClick ? (event) => {
|
|
14
|
+
event.stopPropagation();
|
|
15
|
+
onRowClick && onRowClick(row.original, event);
|
|
16
|
+
} : void 0, children: row.getVisibleCells().map((cell, columnIndex) => {
|
|
17
|
+
const cellId = `cell-${cell.column.id}-${cell.row.id}`;
|
|
18
|
+
const isColumnSorted = isSorted(cell.column);
|
|
19
|
+
const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
20
|
+
const cellTooltipProps = cell.column.columnDef.meta?.getCellTooltipProps?.(row.original);
|
|
21
|
+
return /* @__PURE__ */ jsx(TableCell, { isSorted: isColumnSorted, headerIndex: columnIndex, cellKey: cellId, width: cell.column.getSize(), isPinned: cell.column.getIsPinned(), rightOffset: cell.column.getAfter("right"), leftOffset: cell.column.getStart("left"), style: cell.column.columnDef.meta?.style, "data-cell-id": cellId, "data-column-dataindex": cell.column.columnDef.meta?.dataIndex, "data-column-title": cell.column.columnDef.meta?.title, children: cellTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...cellTooltipProps, children: /* @__PURE__ */ jsx("span", { children: cellContent }) }) : cellContent }, cellId);
|
|
22
|
+
}) }, row.id);
|
|
23
|
+
const rowTooltipProps = getRowTooltipProps?.(row.original);
|
|
24
|
+
return rowTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...rowTooltipProps, children: rowContent }) : rowContent;
|
|
25
|
+
};
|
|
26
|
+
const TableRow = memo(TableRowInner);
|
|
27
|
+
export {
|
|
28
|
+
TableRow
|
|
29
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { commonRowStyles } from "../../../Table.styles.js";
|
|
3
|
+
import { Td } from "../TableCell/TableCell.styles.js";
|
|
4
|
+
const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
5
|
+
displayName: "TableRowstyles__Tr",
|
|
6
|
+
componentId: "sc-h0tq5q-0"
|
|
7
|
+
})(["", " & ", "{background:", ";}&:hover{", "{background:", ";}}"], commonRowStyles, Td, (props) => props.theme.palette[props.isChild ? "grey-050" : "white"], Td, (props) => props.theme.palette[props.isChild ? "grey-100" : "grey-050"]);
|
|
8
|
+
const VirtualRow = /* @__PURE__ */ styled.tr.withConfig({
|
|
9
|
+
displayName: "TableRowstyles__VirtualRow",
|
|
10
|
+
componentId: "sc-h0tq5q-1"
|
|
11
|
+
})(["", " ", " & ", "{background:", ";", "}&:hover{", "{background:", ";}}"], (props) => !props.isVisible && css(["&&&{height:0 !important;overflow:hidden;display:block;}"]), commonRowStyles, Td, (props) => props.theme.palette[props.isChild ? "grey-050" : "white"], (props) => props.isChild && css(["&:first-child:before{content:'';display:block;position:absolute;top:0;left:0;width:2px;height:100%;background-color:", ";};}"], props.theme.palette["grey-500"]), Td, (props) => props.theme.palette[props.isChild ? "grey-100" : "grey-050"]);
|
|
12
|
+
export {
|
|
13
|
+
Tr,
|
|
14
|
+
VirtualRow
|
|
15
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TableRowVirtualProps } from '../../../Table.types';
|
|
3
|
+
declare const TableRowVirtualInner: <TData extends object>({ cellHeight, rowIndex, virtual, infiniteScroll, texts, row, isLast, onRowClick, getRowTooltipProps, isExpanded: _isExpanded, isParentExpanded, }: TableRowVirtualProps<TData>) => React.JSX.Element;
|
|
4
|
+
export declare const TableRowVirtual: typeof TableRowVirtualInner;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback } from "react";
|
|
3
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
4
|
+
import { flexRender } from "@tanstack/react-table";
|
|
5
|
+
import { INFINITE_LOADER_ITEM_HEIGHT } from "../../../Table.const.js";
|
|
6
|
+
import { useTableContext } from "../../../contexts/TableContext.js";
|
|
7
|
+
import { isSorted } from "../../../utils/sort.js";
|
|
8
|
+
import { TableCell } from "../TableCell/TableCell.js";
|
|
9
|
+
import { InfiniteLoaderRow } from "./InfiniteLoaderRow/InfiniteLoaderRow.js";
|
|
10
|
+
import { VirtualRow } from "./TableRow.styles.js";
|
|
11
|
+
const TableRowVirtualInner = ({
|
|
12
|
+
cellHeight,
|
|
13
|
+
rowIndex,
|
|
14
|
+
virtual,
|
|
15
|
+
infiniteScroll,
|
|
16
|
+
texts,
|
|
17
|
+
row,
|
|
18
|
+
isLast,
|
|
19
|
+
onRowClick,
|
|
20
|
+
getRowTooltipProps,
|
|
21
|
+
isExpanded: _isExpanded,
|
|
22
|
+
isParentExpanded
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
rowVirtualizer
|
|
26
|
+
} = useTableContext();
|
|
27
|
+
const isFirst = rowIndex === 0;
|
|
28
|
+
const renderLoaderRow = useCallback((position) => {
|
|
29
|
+
let isVisible2 = false;
|
|
30
|
+
let infiniteLoaderItemProps;
|
|
31
|
+
let top2 = virtual.start;
|
|
32
|
+
let loadMore = infiniteScroll?.onScrollEndReach;
|
|
33
|
+
if (position === "TOP") {
|
|
34
|
+
isVisible2 = Boolean(infiniteScroll?.prevPage?.hasMore && rowIndex === 0);
|
|
35
|
+
infiniteLoaderItemProps = infiniteScroll?.prevPage;
|
|
36
|
+
top2 = 0;
|
|
37
|
+
loadMore = infiniteScroll?.onScrollTopReach;
|
|
38
|
+
}
|
|
39
|
+
if (position === "BOTTOM") {
|
|
40
|
+
isVisible2 = Boolean(isLast && infiniteScroll?.nextPage);
|
|
41
|
+
infiniteLoaderItemProps = infiniteScroll?.nextPage;
|
|
42
|
+
const prevDataInfiniteLoaderHeight = infiniteScroll?.prevPage?.hasMore ? INFINITE_LOADER_ITEM_HEIGHT : 0;
|
|
43
|
+
top2 = virtual.start + virtual.size + prevDataInfiniteLoaderHeight + 1;
|
|
44
|
+
}
|
|
45
|
+
return infiniteLoaderItemProps && isVisible2 && /* @__PURE__ */ jsx(InfiniteLoaderRow, { position, texts, infiniteLoaderItemProps, loadMore, style: {
|
|
46
|
+
position: "absolute",
|
|
47
|
+
top: `${top2}px`,
|
|
48
|
+
height: `${INFINITE_LOADER_ITEM_HEIGHT}px`,
|
|
49
|
+
left: 0,
|
|
50
|
+
right: 0
|
|
51
|
+
} });
|
|
52
|
+
}, [virtual.size, infiniteScroll, isLast, rowIndex, texts, virtual.start]);
|
|
53
|
+
const top = infiniteScroll?.prevPage?.hasMore ? virtual.start + INFINITE_LOADER_ITEM_HEIGHT : virtual.start;
|
|
54
|
+
const isChild = !!row.parentId;
|
|
55
|
+
const isChildExpanded = isChild && !!isParentExpanded;
|
|
56
|
+
const isVisible = !isChild || !!isParentExpanded;
|
|
57
|
+
const renderRow = useCallback((tableRow) => {
|
|
58
|
+
return tableRow.getVisibleCells().map((cell, columnIndex) => {
|
|
59
|
+
const colId = cell.column.id;
|
|
60
|
+
const isColumnSorted = isSorted(cell.column);
|
|
61
|
+
const cellContent = flexRender(isChild ? cell.column.columnDef.meta?.childCell : cell.column.columnDef.cell, cell.getContext());
|
|
62
|
+
const cellTooltipProps = cell.column.columnDef.meta?.getCellTooltipProps?.(tableRow.original);
|
|
63
|
+
return /* @__PURE__ */ jsx(TableCell, { isSorted: isColumnSorted, headerIndex: columnIndex, "data-column-key": colId, width: cell.column.getSize(), height: cellHeight, isPinned: cell.column.getIsPinned(), rightOffset: cell.column.getAfter("right"), leftOffset: cell.column.getStart("left"), style: cell.column.columnDef.meta?.style, "data-column-dataindex": cell.column.columnDef.meta?.dataIndex, "data-column-title": cell.column.columnDef.meta?.title, children: cellTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...cellTooltipProps, children: /* @__PURE__ */ jsx("span", { children: cellContent }) }) : cellContent }, colId);
|
|
64
|
+
});
|
|
65
|
+
}, [cellHeight, isChild]);
|
|
66
|
+
const rowTooltipProps = getRowTooltipProps?.(row.original);
|
|
67
|
+
const virtualRowContent = /* @__PURE__ */ jsx(VirtualRow, { "data-key": row.id, "data-row-depth": row.depth, "data-row-ischild": isChild, "data-row-index": virtual.index, "data-index": virtual.index, ...isChild ? {
|
|
68
|
+
"data-row-expanded": isChildExpanded
|
|
69
|
+
} : {}, ref: rowVirtualizer?.measureElement, style: {
|
|
70
|
+
position: "absolute",
|
|
71
|
+
top: `${top}px`,
|
|
72
|
+
height: `${isVisible ? virtual.size : 0}px`,
|
|
73
|
+
left: 0,
|
|
74
|
+
right: 0
|
|
75
|
+
}, isVisible, isChild, onClick: onRowClick ? (event) => {
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
onRowClick && onRowClick(row.original, event);
|
|
78
|
+
} : void 0, children: renderRow(row) }, row.id);
|
|
79
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
isFirst && renderLoaderRow("TOP"),
|
|
81
|
+
rowTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...rowTooltipProps, children: virtualRowContent }) : virtualRowContent,
|
|
82
|
+
isLast && renderLoaderRow("BOTTOM")
|
|
83
|
+
] });
|
|
84
|
+
};
|
|
85
|
+
const TableRowVirtual = memo(TableRowVirtualInner);
|
|
86
|
+
export {
|
|
87
|
+
TableRowVirtual
|
|
88
|
+
};
|