@synerise/ds-table-new 1.0.5 → 1.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 +14 -0
- package/dist/Table.js +4 -2
- package/dist/Table.types.d.ts +6 -4
- package/dist/VirtualTable.js +4 -2
- package/dist/components/BaseTable/BaseTable.d.ts +1 -1
- package/dist/components/BaseTable/BaseTable.js +10 -5
- package/dist/components/BaseTable/BaseTable.styles.d.ts +1 -0
- package/dist/components/BaseTable/BaseTable.styles.js +9 -4
- package/dist/components/TableBody/TableBody.d.ts +1 -1
- package/dist/components/TableBody/TableBody.js +2 -9
- package/dist/components/TableBody/TableBody.styles.d.ts +1 -4
- package/dist/components/TableBody/TableBody.styles.js +2 -2
- package/dist/components/TableBody/TableCell/TableCell.styles.js +1 -1
- package/dist/components/TableBody/TableEmptyBody/TableEmptyBody.d.ts +1 -1
- package/dist/components/TableBody/TableEmptyBody/TableEmptyBody.js +2 -7
- package/dist/components/TableColumns/TableColumns.js +1 -1
- package/dist/hooks/useTable.js +13 -3
- package/dist/types/table.d.ts +6 -0
- package/dist/utils/legacyColumnConfigAdapter.js +2 -1
- package/package.json +21 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.1.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.0.6...@synerise/ds-table-new@1.1.0) (2026-04-28)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **table-new:** summary and id generation ([8564b73](https://github.com/Synerise/synerise-design/commit/8564b73e532b190c9c62674b6ce2725418a2c619))
|
|
11
|
+
|
|
12
|
+
## [1.0.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.0.5...@synerise/ds-table-new@1.0.6) (2026-04-24)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **table-new:** fixes lack of text overflow on cell wrapper child dom node ([81abddf](https://github.com/Synerise/synerise-design/commit/81abddfdc4355b588e9f5345e66cf663102460f3))
|
|
17
|
+
- **table-new:** render skeleton when columns race behind data ([6fbde3c](https://github.com/Synerise/synerise-design/commit/6fbde3c4450aa79e1249c25b5f1de00648304edc))
|
|
18
|
+
- **table-new:** support pinned columns when stickyHeader is off ([1d027dd](https://github.com/Synerise/synerise-design/commit/1d027dd6c2177b75ce5739bf9df04bf25583e82c))
|
|
19
|
+
|
|
6
20
|
## [1.0.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.0.4...@synerise/ds-table-new@1.0.5) (2026-04-22)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @synerise/ds-table-new
|
package/dist/Table.js
CHANGED
|
@@ -33,7 +33,9 @@ const Table = ({
|
|
|
33
33
|
return columns.length ? processColumns(columns, hasSelection, texts) : columns;
|
|
34
34
|
}, [columns, hasSelection, texts]);
|
|
35
35
|
const skeletonColumns = useMemo(() => getDefaultSkeletonColumns(), []);
|
|
36
|
-
const
|
|
36
|
+
const useSkeletonColumns = !processedColumns.length && (isLoading || data.length > 0);
|
|
37
|
+
const finalColumns = useSkeletonColumns ? skeletonColumns : processedColumns;
|
|
38
|
+
const effectiveIsLoading = isLoading || useSkeletonColumns;
|
|
37
39
|
const {
|
|
38
40
|
table,
|
|
39
41
|
paginationProps,
|
|
@@ -70,7 +72,7 @@ const Table = ({
|
|
|
70
72
|
table,
|
|
71
73
|
getScrollContainer: () => null
|
|
72
74
|
}), [table]);
|
|
73
|
-
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selectionConfig, children: /* @__PURE__ */ jsx(BaseTable, { texts, isLoading, hasPagination, paginationProps, tableOuterRef: wrapperRef, selectedRowKeys, columnSizing, isColumnSizingReady, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, dataSourceTotalCount: totalDataCount, ...props }) }) });
|
|
75
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selectionConfig, children: /* @__PURE__ */ jsx(BaseTable, { texts, isLoading: effectiveIsLoading, hasPagination, paginationProps, tableOuterRef: wrapperRef, selectedRowKeys, columnSizing, isColumnSizingReady, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, dataSourceTotalCount: totalDataCount, ...props }) }) });
|
|
74
76
|
};
|
|
75
77
|
export {
|
|
76
78
|
Table
|
package/dist/Table.types.d.ts
CHANGED
|
@@ -246,6 +246,11 @@ export type SharedTableProps<TData, TValue> = {
|
|
|
246
246
|
* custom "Empty data" component
|
|
247
247
|
*/
|
|
248
248
|
emptyDataComponent?: ReactNode;
|
|
249
|
+
/**
|
|
250
|
+
* Optional summary content rendered inside a <tfoot> at the bottom of the table.
|
|
251
|
+
* Should be a <tr> (or fragment of <tr>s) with <td>/<th> cells matching the column layout.
|
|
252
|
+
*/
|
|
253
|
+
summary?: ReactNode;
|
|
249
254
|
};
|
|
250
255
|
export type GlobalSelectionProps = {
|
|
251
256
|
/**
|
|
@@ -444,11 +449,8 @@ export type CustomCounterArgs = {
|
|
|
444
449
|
export type CustomCounterFn = (props: CustomCounterArgs) => ReactNode;
|
|
445
450
|
export type TableBodyProps<TData, TValue> = Pick<BaseTableProps<TData, TValue>, 'infiniteScroll' | 'cellHeight' | 'emptyDataComponent' | 'onRowClick' | 'getRowProps' | 'getRowTooltipProps'> & {
|
|
446
451
|
texts: TableBodyTexts;
|
|
447
|
-
withBodyScroll?: boolean;
|
|
448
|
-
tableBodyScrollRef?: React.MutableRefObject<HTMLElement | null>;
|
|
449
|
-
maxHeight?: number;
|
|
450
452
|
};
|
|
451
|
-
export type TableEmptyBodyProps<TData, TValue> = Pick<TableBodyProps<TData, TValue>, 'emptyDataComponent'
|
|
453
|
+
export type TableEmptyBodyProps<TData, TValue> = Pick<TableBodyProps<TData, TValue>, 'emptyDataComponent'> & {
|
|
452
454
|
texts: TableEmptyBodyTexts;
|
|
453
455
|
};
|
|
454
456
|
export type TableCounterProps<TData, TValue> = Pick<BaseTableProps<TData, TValue>, 'renderCustomCounter' | 'isCounterLoading'> & {
|
package/dist/VirtualTable.js
CHANGED
|
@@ -54,7 +54,9 @@ const VirtualTable = ({
|
|
|
54
54
|
return columns.length ? processColumns(columns, hasSelection, texts) : columns;
|
|
55
55
|
}, [columns, hasSelection, texts]);
|
|
56
56
|
const skeletonColumns = useMemo(() => getDefaultSkeletonColumns(), []);
|
|
57
|
-
const
|
|
57
|
+
const useSkeletonColumns = !processedColumns.length && (isLoading || data.length > 0);
|
|
58
|
+
const finalColumns = useSkeletonColumns ? skeletonColumns : processedColumns;
|
|
59
|
+
const effectiveIsLoading = isLoading || useSkeletonColumns;
|
|
58
60
|
const {
|
|
59
61
|
table,
|
|
60
62
|
columnSizing,
|
|
@@ -243,7 +245,7 @@ const VirtualTable = ({
|
|
|
243
245
|
rowVirtualizer.scrollToOffset(0);
|
|
244
246
|
}, [onBackToTop, rowVirtualizer]);
|
|
245
247
|
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(StickyContext.Provider, { value: stickyValue, children: /* @__PURE__ */ jsxs(SelectionContext.Provider, { value: selectionConfig, children: [
|
|
246
|
-
/* @__PURE__ */ jsx(BaseTable, { columnSizing, isColumnSizingReady, texts, tableOuterRef, tableBodyScrollRef, withScroll: withContainerScroll, withBodyScroll, maxHeight, hasPagination: false, infiniteScroll, isLoading, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, dataSourceTotalCount: totalDataCount, cellHeight, ...props }),
|
|
248
|
+
/* @__PURE__ */ jsx(BaseTable, { columnSizing, isColumnSizingReady, texts, tableOuterRef, tableBodyScrollRef, withScroll: withContainerScroll, withBodyScroll, maxHeight, hasPagination: false, infiniteScroll, isLoading: effectiveIsLoading, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, dataSourceTotalCount: totalDataCount, cellHeight, ...props }),
|
|
247
249
|
showBackToTopButton && /* @__PURE__ */ jsx(BackToTopButton, { label: texts.infiniteScrollBackToTop, onClick: handleBackToTop, scrollContainerRef: scrollableContainerRef, hasData: !tableIsEmpty && columns.length > 0, threshold: (stickyData.titleBarHeight || 0) + (Number.isFinite(stickyData.containerPaddingTop) ? stickyData.containerPaddingTop : 0) })
|
|
248
250
|
] }) }) });
|
|
249
251
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { BaseTableProps, TableInternalProps } from '../../Table.types';
|
|
3
|
-
export declare const BaseTable: <TData extends object, TValue>({ infiniteScroll, cellHeight, className, itemsMenu, texts, isCounterLoading, isLoading, rowKey, title, hideTitleBar, hideTitlePart, renderCustomCounter, renderSelectionTitle, searchComponent, filterComponent, headerWithBorderTop, emptyDataComponent, headerButton, hideColumnNames, expandable, columnSizing, isColumnSizingReady, paginationProps, hasPagination, disableColumnNamesLineBreak, dataSourceTotalCount, cardStyles, tableOuterRef, withScroll, withBodyScroll, maxHeight, tableBodyScrollRef, onRowClick, getRowProps, getRowTooltipProps, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, }: BaseTableProps<TData, TValue> & TableInternalProps) => React.JSX.Element;
|
|
3
|
+
export declare const BaseTable: <TData extends object, TValue>({ infiniteScroll, cellHeight, className, itemsMenu, texts, isCounterLoading, isLoading, rowKey, title, hideTitleBar, hideTitlePart, renderCustomCounter, renderSelectionTitle, searchComponent, filterComponent, headerWithBorderTop, emptyDataComponent, headerButton, hideColumnNames, expandable, columnSizing, isColumnSizingReady, paginationProps, hasPagination, disableColumnNamesLineBreak, dataSourceTotalCount, cardStyles, tableOuterRef, withScroll, withBodyScroll, maxHeight, tableBodyScrollRef, onRowClick, getRowProps, getRowTooltipProps, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, summary, }: BaseTableProps<TData, TValue> & TableInternalProps) => React.JSX.Element;
|
|
@@ -11,7 +11,7 @@ import { TableHeader } from "../TableHeader/TableHeader.js";
|
|
|
11
11
|
import { TableHorizontalScroll } from "../TableHorizontalScroll/TableHorizontalScroll.js";
|
|
12
12
|
import { TableHorizontalScrollBar } from "../TableHorizontalScrollBar/TableHorizontalScrollBar.js";
|
|
13
13
|
import { TablePagination } from "../TablePagination/TablePagination.js";
|
|
14
|
-
import { StyledTable, BaseTableWrapper, TableContainer,
|
|
14
|
+
import { StyledTable, Tfoot, BaseTableWrapper, TableContainer, TableBodyScrollWrapper, TableColumnsHorizontalScroll } from "./BaseTable.styles.js";
|
|
15
15
|
const BaseTable = ({
|
|
16
16
|
infiniteScroll,
|
|
17
17
|
cellHeight = DEFAULT_CELL_HEIGHT,
|
|
@@ -52,7 +52,8 @@ const BaseTable = ({
|
|
|
52
52
|
setSearchQuery,
|
|
53
53
|
handleSearchClear,
|
|
54
54
|
hasBuiltInSearch,
|
|
55
|
-
searchProps
|
|
55
|
+
searchProps,
|
|
56
|
+
summary
|
|
56
57
|
}) => {
|
|
57
58
|
const horizontalScrollRefs = useRef([]);
|
|
58
59
|
const tableBodyWrapperRef = useRef(null);
|
|
@@ -95,18 +96,22 @@ const BaseTable = ({
|
|
|
95
96
|
const tableBodyContent = /* @__PURE__ */ jsx(TableHorizontalScroll, { stickyRight: table.getRightTotalSize(), stickyLeft: table.getLeftTotalSize(), ref: (element) => {
|
|
96
97
|
tableBodyWrapperRef.current = element;
|
|
97
98
|
addNode(element);
|
|
98
|
-
}, children: /* @__PURE__ */
|
|
99
|
+
}, children: /* @__PURE__ */ jsxs(StyledTable, { role: "table", children: [
|
|
100
|
+
isLoading ? /* @__PURE__ */ jsx(TableBodySkeleton, { wrapperRef: tableBodyWrapperRef, cellHeight }, "table-body-skeleton") : /* @__PURE__ */ jsx(TableBody, { cellHeight, infiniteScroll, emptyDataComponent, texts, onRowClick, getRowProps, getRowTooltipProps }, "table-body"),
|
|
101
|
+
!isLoading && summary && /* @__PURE__ */ jsx(Tfoot, { children: summary })
|
|
102
|
+
] }) });
|
|
99
103
|
const unifiedTableContent = /* @__PURE__ */ jsx(TableHorizontalScroll, { stickyRight: table.getRightTotalSize(), stickyLeft: table.getLeftTotalSize(), ref: (element) => {
|
|
100
104
|
tableBodyWrapperRef.current = element;
|
|
101
105
|
addNode(element);
|
|
102
106
|
}, children: /* @__PURE__ */ jsxs(StyledTable, { role: "table", children: [
|
|
103
107
|
!hideColumnNames && (!isEmpty || isLoading) && /* @__PURE__ */ jsx(TableColumns, { texts, disableColumnNamesLineBreak }),
|
|
104
|
-
isLoading ? /* @__PURE__ */ jsx(TableBodySkeleton, { wrapperRef: tableBodyWrapperRef, cellHeight }, "table-body-skeleton") : /* @__PURE__ */ jsx(TableBody, {
|
|
108
|
+
isLoading ? /* @__PURE__ */ jsx(TableBodySkeleton, { wrapperRef: tableBodyWrapperRef, cellHeight }, "table-body-skeleton") : /* @__PURE__ */ jsx(TableBody, { cellHeight, infiniteScroll, emptyDataComponent, texts, onRowClick, getRowProps, getRowTooltipProps }, "table-body"),
|
|
109
|
+
!isLoading && summary && /* @__PURE__ */ jsx(Tfoot, { children: summary })
|
|
105
110
|
] }) });
|
|
106
111
|
return /* @__PURE__ */ jsxs(BaseTableWrapper, { isEmpty, columnSizing, $isColumnSizingReady: isColumnSizingReady, $size: size, children: [
|
|
107
112
|
/* @__PURE__ */ jsxs(TableContainer, { ref: tableOuterRef, className, withBorderTop: headerWithBorderTop, cardStyles, withScroll, $maxHeight: maxHeight, "data-testid": "ds-table-container", children: [
|
|
108
113
|
!hideTitleBar && /* @__PURE__ */ jsx(TableHeader, { itemsMenu, texts, childrenColumnName: expandable?.childrenColumnName, isCounterLoading, isLoading, rowKey, title, hideTitlePart, renderCustomCounter, renderSelectionTitle, searchComponent, filterComponent, headerButton, dataSourceTotalCount, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps }),
|
|
109
|
-
useUnifiedScroll ? unifiedTableContent : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
+
useUnifiedScroll ? withBodyScroll ? /* @__PURE__ */ jsx(TableBodyScrollWrapper, { ref: tableBodyScrollRef, $maxHeight: maxHeight, children: unifiedTableContent }) : unifiedTableContent : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
115
|
!hideColumnNames && (!isEmpty || isLoading) && /* @__PURE__ */ jsx(TableColumnsHorizontalScroll, { stickyRight: table.getRightTotalSize(), stickyLeft: table.getLeftTotalSize(), stickyData: stickyContext?.stickyData, isScrolled: rowVirtualizer?.scrollOffset, ref: handleRef, children: /* @__PURE__ */ jsx(StyledTable, { role: "table", children: /* @__PURE__ */ jsx(TableColumns, { texts, disableColumnNamesLineBreak }) }) }),
|
|
111
116
|
withBodyScroll ? /* @__PURE__ */ jsx(TableBodyScrollWrapper, { ref: tableBodyScrollRef, $maxHeight: maxHeight, children: tableBodyContent }) : tableBodyContent
|
|
112
117
|
] }),
|
|
@@ -17,6 +17,7 @@ export declare const TableBodyScrollWrapper: import('styled-components').StyledC
|
|
|
17
17
|
export declare const TableSkeleton: import('styled-components').StyledComponent<({ size, numberOfSkeletons, width, height, className, }: import('@synerise/ds-skeleton').SkeletonProps) => React.JSX.Element, any, {
|
|
18
18
|
skeletonWidth?: string;
|
|
19
19
|
}, never>;
|
|
20
|
+
export declare const Tfoot: import('styled-components').StyledComponent<"tfoot", any, {}, never>;
|
|
20
21
|
export declare const StyledTable: import('styled-components').StyledComponent<"table", any, {}, never>;
|
|
21
22
|
export declare const TableColumnsHorizontalScroll: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<{
|
|
22
23
|
children?: import('react').ReactNode;
|
|
@@ -17,13 +17,17 @@ const TableSkeleton = /* @__PURE__ */ styled(DSSkeleton).withConfig({
|
|
|
17
17
|
displayName: "BaseTablestyles__TableSkeleton",
|
|
18
18
|
componentId: "sc-1oa5lc2-3"
|
|
19
19
|
})(["padding:0;", ""], (props) => props.skeletonWidth && `width: ${props.skeletonWidth};`);
|
|
20
|
+
const Tfoot = /* @__PURE__ */ styled.tfoot.withConfig({
|
|
21
|
+
displayName: "BaseTablestyles__Tfoot",
|
|
22
|
+
componentId: "sc-1oa5lc2-4"
|
|
23
|
+
})([""]);
|
|
20
24
|
const StyledTable = /* @__PURE__ */ styled.table.withConfig({
|
|
21
25
|
displayName: "BaseTablestyles__StyledTable",
|
|
22
|
-
componentId: "sc-1oa5lc2-
|
|
23
|
-
})(["width:var(--table-size);min-width:100%;border-spacing:0;border-collapse:separate;@keyframes ds-table-row-highlight{0%{background-color:transparent;}5%{background-color:var( --ds-highlight-color,", " );}30%{background-color:var( --ds-highlight-color,", " );}100%{background-color:transparent;}}tr.ds-table-row-highlight td{transition:background 0.3s ease-in-out;animation:ds-table-row-highlight var(--ds-highlight-duration,600ms) ease-in-out forwards;}"], (props) => props.theme.palette["blue-050"], (props) => props.theme.palette["blue-050"]);
|
|
26
|
+
componentId: "sc-1oa5lc2-5"
|
|
27
|
+
})(["width:var(--table-size);min-width:100%;border-spacing:0;table-layout:fixed;border-collapse:separate;@keyframes ds-table-row-highlight{0%{background-color:transparent;}5%{background-color:var( --ds-highlight-color,", " );}30%{background-color:var( --ds-highlight-color,", " );}100%{background-color:transparent;}}tr.ds-table-row-highlight td{transition:background 0.3s ease-in-out;animation:ds-table-row-highlight var(--ds-highlight-duration,600ms) ease-in-out forwards;}"], (props) => props.theme.palette["blue-050"], (props) => props.theme.palette["blue-050"]);
|
|
24
28
|
const TableColumnsHorizontalScroll = /* @__PURE__ */ styled(TableHorizontalScroll).withConfig({
|
|
25
29
|
displayName: "BaseTablestyles__TableColumnsHorizontalScroll",
|
|
26
|
-
componentId: "sc-1oa5lc2-
|
|
30
|
+
componentId: "sc-1oa5lc2-6"
|
|
27
31
|
})(["", ""], ({
|
|
28
32
|
stickyData,
|
|
29
33
|
isScrolled,
|
|
@@ -37,5 +41,6 @@ export {
|
|
|
37
41
|
TableBodyScrollWrapper,
|
|
38
42
|
TableColumnsHorizontalScroll,
|
|
39
43
|
TableContainer,
|
|
40
|
-
TableSkeleton
|
|
44
|
+
TableSkeleton,
|
|
45
|
+
Tfoot
|
|
41
46
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableBodyProps } from '../../Table.types';
|
|
3
|
-
export declare const TableBody: <TData extends object, TValue>({ cellHeight, infiniteScroll, onRowClick, getRowProps, getRowTooltipProps,
|
|
3
|
+
export declare const TableBody: <TData extends object, TValue>({ cellHeight, infiniteScroll, onRowClick, getRowProps, getRowTooltipProps, emptyDataComponent, texts, }: TableBodyProps<TData, TValue>) => React.JSX.Element;
|
|
@@ -11,9 +11,6 @@ const TableBody = ({
|
|
|
11
11
|
onRowClick,
|
|
12
12
|
getRowProps,
|
|
13
13
|
getRowTooltipProps,
|
|
14
|
-
withBodyScroll,
|
|
15
|
-
tableBodyScrollRef,
|
|
16
|
-
maxHeight,
|
|
17
14
|
emptyDataComponent,
|
|
18
15
|
texts
|
|
19
16
|
}) => {
|
|
@@ -39,11 +36,7 @@ const TableBody = ({
|
|
|
39
36
|
return true;
|
|
40
37
|
}) : flatRows;
|
|
41
38
|
const allRows = rowVirtualizer ? flatRows : nonVirtualRows;
|
|
42
|
-
return allRows.length ? /* @__PURE__ */ jsx(TBody, { "data-testid": "ds-table-body",
|
|
43
|
-
if (tableBodyScrollRef) {
|
|
44
|
-
tableBodyScrollRef.current = node;
|
|
45
|
-
}
|
|
46
|
-
}, $maxHeight: maxHeight, withBodyScroll, role: "rowgroup", "data-popup-container": true, style: rowVirtualizer && virtualItems.length ? {
|
|
39
|
+
return allRows.length ? /* @__PURE__ */ jsx(TBody, { "data-testid": "ds-table-body", role: "rowgroup", "data-popup-container": true, style: rowVirtualizer && virtualItems.length ? {
|
|
47
40
|
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
48
41
|
position: "relative"
|
|
49
42
|
} : void 0, children: rowVirtualizer && virtualItems.length ? (
|
|
@@ -55,7 +48,7 @@ const TableBody = ({
|
|
|
55
48
|
) : (
|
|
56
49
|
// Non-virtualized: render all rows in the normal flow
|
|
57
50
|
allRows.map((row) => /* @__PURE__ */ jsx(TableRow, { onRowClick, getRowProps, getRowTooltipProps, row, isSelected: row.getIsSelected(), isExpanded: row.getIsExpanded(), isParentExpanded: row.getIsAllParentsExpanded() }, row.id))
|
|
58
|
-
) }, "virtual-table-body") : /* @__PURE__ */ jsx(TableEmptyBody, { emptyDataComponent, texts
|
|
51
|
+
) }, "virtual-table-body") : /* @__PURE__ */ jsx(TableEmptyBody, { emptyDataComponent, texts });
|
|
59
52
|
};
|
|
60
53
|
export {
|
|
61
54
|
TableBody
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
export declare const Tr: import('styled-components').StyledComponent<"tr", any, {}, never>;
|
|
2
|
-
export declare const TBody: import('styled-components').StyledComponent<"tbody", any, {
|
|
3
|
-
$maxHeight?: number;
|
|
4
|
-
withBodyScroll?: boolean;
|
|
5
|
-
}, never>;
|
|
2
|
+
export declare const TBody: import('styled-components').StyledComponent<"tbody", any, {}, never>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled
|
|
1
|
+
import styled from "styled-components";
|
|
2
2
|
import { commonRowStyles } from "../../Table.styles.js";
|
|
3
3
|
import { Td } from "./TableCell/TableCell.styles.js";
|
|
4
4
|
const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
@@ -8,7 +8,7 @@ const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
|
8
8
|
const TBody = /* @__PURE__ */ styled.tbody.withConfig({
|
|
9
9
|
displayName: "TableBodystyles__TBody",
|
|
10
10
|
componentId: "sc-1dty8xx-1"
|
|
11
|
-
})(["position:relative;"
|
|
11
|
+
})(["position:relative;"]);
|
|
12
12
|
export {
|
|
13
13
|
TBody,
|
|
14
14
|
Tr
|
|
@@ -12,7 +12,7 @@ const CellWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
12
12
|
const Td = /* @__PURE__ */ styled.td.withConfig({
|
|
13
13
|
displayName: "TableCellstyles__Td",
|
|
14
14
|
componentId: "sc-1sq3dd7-1"
|
|
15
|
-
})(["", " ", " text-align:", ";&&&&{", ";}", ";", ";", "{display:flex;align-items:center;justify-content:", ";width:100
|
|
15
|
+
})(["", " ", " text-align:", ";&&&&{", ";}", ";", ";", "{display:flex;align-items:center;justify-content:", ";width:100%;& > *{min-width:0;}}"], commonCellStyles, commonPinnedStyles, (props) => props.$align ?? "left", (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 ? `
|
|
16
16
|
padding: 0 24px;
|
|
17
17
|
height: ${props.$height}px` : `
|
|
18
18
|
padding: 16px 24px;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableEmptyBodyProps } from '../../../Table.types';
|
|
3
|
-
export declare const TableEmptyBody: <TData, TValue>({ emptyDataComponent, texts,
|
|
3
|
+
export declare const TableEmptyBody: <TData, TValue>({ emptyDataComponent, texts, }: TableEmptyBodyProps<TData, TValue>) => React.JSX.Element;
|
|
@@ -5,18 +5,13 @@ import { useTableContext } from "../../../contexts/TableContext.js";
|
|
|
5
5
|
import { TBody, Tr, Td, TableEmptyBodyWrapper } from "./TableEmptyBody.styles.js";
|
|
6
6
|
const TableEmptyBody = ({
|
|
7
7
|
emptyDataComponent,
|
|
8
|
-
texts
|
|
9
|
-
tableBodyScrollRef
|
|
8
|
+
texts
|
|
10
9
|
}) => {
|
|
11
10
|
const {
|
|
12
11
|
table
|
|
13
12
|
} = useTableContext();
|
|
14
13
|
const colSpan = table.getAllLeafColumns().length;
|
|
15
|
-
return /* @__PURE__ */ jsx(TBody, {
|
|
16
|
-
if (tableBodyScrollRef) {
|
|
17
|
-
tableBodyScrollRef.current = node;
|
|
18
|
-
}
|
|
19
|
-
}, 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 }) }) }) }) });
|
|
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 }) }) }) }) });
|
|
20
15
|
};
|
|
21
16
|
export {
|
|
22
17
|
TableEmptyBody
|
|
@@ -18,7 +18,7 @@ const TableColumns = ({
|
|
|
18
18
|
const hasSorter = header.column.getCanSort();
|
|
19
19
|
const isColumnSorted = isSorted(header.column);
|
|
20
20
|
const align = header.column.columnDef.meta?.align;
|
|
21
|
-
return /* @__PURE__ */ jsx(Th, { headerIndex: columnIndex, colSpan: header.colSpan, style: header.column.columnDef.meta?.style, isPinned: header.column.getIsPinned(),
|
|
21
|
+
return /* @__PURE__ */ jsx(Th, { headerIndex: columnIndex, colSpan: header.colSpan, style: header.column.columnDef.meta?.style, isPinned: header.column.getIsPinned(), leftOffset: header.column.getStart("left"), rightOffset: header.column.getAfter("right"), isSorted: isColumnSorted, hasSorter, $align: align, "data-sticky": isSticky ? "true" : void 0, role: "columnheader", children: /* @__PURE__ */ jsxs(HeaderWrapper, { $align: align, children: [
|
|
22
22
|
/* @__PURE__ */ jsx(Label, { disableColumnNamesLineBreak, children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }),
|
|
23
23
|
hasSorter && (header.column.columnDef.meta?.renderCustomSortButton?.(header.getContext()) || /* @__PURE__ */ jsx(TableColumnSorter, { texts, column: header.column }))
|
|
24
24
|
] }) }, id);
|
package/dist/hooks/useTable.js
CHANGED
|
@@ -53,6 +53,15 @@ const useTable = ({
|
|
|
53
53
|
getRowKey
|
|
54
54
|
} = useRowKey(rowKey);
|
|
55
55
|
const memoizedGetRowKey = useCallback((row, index) => getRowKey(row, index), [getRowKey]);
|
|
56
|
+
const columnKeyById = useMemo(() => {
|
|
57
|
+
const map = /* @__PURE__ */ new Map();
|
|
58
|
+
columns.forEach((column) => {
|
|
59
|
+
if (column.id) {
|
|
60
|
+
map.set(column.id, column.meta?.columnKey ?? column.id);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return map;
|
|
64
|
+
}, [columns]);
|
|
56
65
|
const handleSortingChange = useCallback((updaterOrValue) => {
|
|
57
66
|
setSorting((oldSorting) => {
|
|
58
67
|
const newSorting = typeof updaterOrValue === "function" ? updaterOrValue(oldSorting) : updaterOrValue;
|
|
@@ -61,13 +70,14 @@ const useTable = ({
|
|
|
61
70
|
const singleColumnSort = newSorting[0];
|
|
62
71
|
const sortState = {};
|
|
63
72
|
newSorting.forEach((column, index) => {
|
|
64
|
-
|
|
73
|
+
const key = columnKeyById.get(column.id) ?? column.id;
|
|
74
|
+
sortState[key] = {
|
|
65
75
|
sortOrder: column.desc ? "descend" : "ascend",
|
|
66
76
|
multiple: index
|
|
67
77
|
};
|
|
68
78
|
});
|
|
69
79
|
onSort({
|
|
70
|
-
columnKey: singleColumnSort.id,
|
|
80
|
+
columnKey: columnKeyById.get(singleColumnSort.id) ?? singleColumnSort.id,
|
|
71
81
|
order: singleColumnSort.desc ? "descend" : "ascend"
|
|
72
82
|
}, sortState);
|
|
73
83
|
} else {
|
|
@@ -76,7 +86,7 @@ const useTable = ({
|
|
|
76
86
|
}
|
|
77
87
|
return newSorting;
|
|
78
88
|
});
|
|
79
|
-
}, [onSort]);
|
|
89
|
+
}, [onSort, columnKeyById]);
|
|
80
90
|
const handleSelectionChange = useCallback((updaterOrValue) => {
|
|
81
91
|
setRowSelection((oldSelection) => {
|
|
82
92
|
const newSelection = typeof updaterOrValue === "function" ? updaterOrValue(oldSelection) : updaterOrValue;
|
package/dist/types/table.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ declare module '@tanstack/react-table' {
|
|
|
18
18
|
skeletonCell?: () => ReactNode;
|
|
19
19
|
dataIndex?: string;
|
|
20
20
|
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* External-facing column key reported back to consumers (e.g. via onSort).
|
|
23
|
+
* Set by `legacyColumnConfigAdapter` so that internally-disambiguated column
|
|
24
|
+
* ids (e.g. `${key}-${index}` for duplicate-key columns) don't leak out.
|
|
25
|
+
*/
|
|
26
|
+
columnKey?: string;
|
|
21
27
|
enableMultiSort?: boolean;
|
|
22
28
|
/**
|
|
23
29
|
* Returns tooltip props for cells in this column, or false to disable tooltip.
|
|
@@ -91,6 +91,7 @@ const legacyColumnConfigAdapter = (columns) => {
|
|
|
91
91
|
getCellTooltipProps: column.getCellTooltipProps,
|
|
92
92
|
dataIndex: column.dataIndex,
|
|
93
93
|
title: typeof column.title === "string" ? column.title : void 0,
|
|
94
|
+
columnKey: `${column.id ?? column.key ?? (Array.isArray(column.dataIndex) ? column.dataIndex.join(".") : column.dataIndex)}`,
|
|
94
95
|
childCell: (info) => {
|
|
95
96
|
if (column.childRender) {
|
|
96
97
|
const rowData = {
|
|
@@ -107,7 +108,7 @@ const legacyColumnConfigAdapter = (columns) => {
|
|
|
107
108
|
...sortingConfig,
|
|
108
109
|
size: calculatePixels(column.width),
|
|
109
110
|
...column,
|
|
110
|
-
id: `${column.id || column.key
|
|
111
|
+
id: `${column.id || `${column.key ?? column.dataIndex}-${index}`}`
|
|
111
112
|
};
|
|
112
113
|
});
|
|
113
114
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-table-new",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "TableNew UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@floating-ui/react": "^0.27.16",
|
|
37
|
-
"@synerise/ds-badge": "^1.0.
|
|
38
|
-
"@synerise/ds-button": "^1.5.
|
|
39
|
-
"@synerise/ds-checkbox": "^1.2.
|
|
40
|
-
"@synerise/ds-copy-icon": "^1.2.
|
|
41
|
-
"@synerise/ds-dropdown": "^1.3.
|
|
37
|
+
"@synerise/ds-badge": "^1.0.50",
|
|
38
|
+
"@synerise/ds-button": "^1.5.24",
|
|
39
|
+
"@synerise/ds-checkbox": "^1.2.27",
|
|
40
|
+
"@synerise/ds-copy-icon": "^1.2.8",
|
|
41
|
+
"@synerise/ds-dropdown": "^1.3.9",
|
|
42
42
|
"@synerise/ds-flag": "^1.0.10",
|
|
43
|
-
"@synerise/ds-icon": "^1.
|
|
44
|
-
"@synerise/ds-inline-alert": "^1.1.
|
|
45
|
-
"@synerise/ds-input": "^1.7.
|
|
46
|
-
"@synerise/ds-input-number": "^1.2.
|
|
43
|
+
"@synerise/ds-icon": "^1.17.1",
|
|
44
|
+
"@synerise/ds-inline-alert": "^1.1.20",
|
|
45
|
+
"@synerise/ds-input": "^1.7.4",
|
|
46
|
+
"@synerise/ds-input-number": "^1.2.41",
|
|
47
47
|
"@synerise/ds-loader": "^1.0.15",
|
|
48
|
-
"@synerise/ds-modal": "^1.4.
|
|
49
|
-
"@synerise/ds-pagination": "^1.0.
|
|
50
|
-
"@synerise/ds-result": "^1.0.
|
|
51
|
-
"@synerise/ds-scrollbar": "^1.3.
|
|
52
|
-
"@synerise/ds-search": "^1.5.
|
|
53
|
-
"@synerise/ds-skeleton": "^1.0.
|
|
54
|
-
"@synerise/ds-tag": "^1.4.
|
|
55
|
-
"@synerise/ds-tags": "^1.5.
|
|
56
|
-
"@synerise/ds-tooltip": "^1.4.
|
|
57
|
-
"@synerise/ds-typography": "^1.1.
|
|
48
|
+
"@synerise/ds-modal": "^1.4.8",
|
|
49
|
+
"@synerise/ds-pagination": "^1.0.59",
|
|
50
|
+
"@synerise/ds-result": "^1.0.55",
|
|
51
|
+
"@synerise/ds-scrollbar": "^1.3.2",
|
|
52
|
+
"@synerise/ds-search": "^1.5.18",
|
|
53
|
+
"@synerise/ds-skeleton": "^1.0.51",
|
|
54
|
+
"@synerise/ds-tag": "^1.4.24",
|
|
55
|
+
"@synerise/ds-tags": "^1.5.35",
|
|
56
|
+
"@synerise/ds-tooltip": "^1.4.16",
|
|
57
|
+
"@synerise/ds-typography": "^1.1.19",
|
|
58
58
|
"@synerise/ds-utils": "^1.8.0",
|
|
59
59
|
"@tanstack/react-table": "^8.21.3",
|
|
60
60
|
"@tanstack/react-virtual": "^3.13.12",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react-intl": ">= 3.12.0 <= 6.8",
|
|
72
72
|
"styled-components": "^5.3.3"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "25cf79a6df348141419f397813e4f6a5533deb5f"
|
|
75
75
|
}
|