diff --git a/packages/main/src/components/AnalyticalTable/AnayticalTable.jss.ts b/packages/main/src/components/AnalyticalTable/AnayticalTable.jss.ts index 26ddad277a9..40f58eaa659 100644 --- a/packages/main/src/components/AnalyticalTable/AnayticalTable.jss.ts +++ b/packages/main/src/components/AnalyticalTable/AnayticalTable.jss.ts @@ -45,6 +45,7 @@ const styles = ({ parameters }: JSSTheme) => ({ backgroundColor: parameters.sapUiListHeaderBackground } }, + emptyRow: {}, tr: { zIndex: 0, backgroundColor: parameters.sapUiListBackground, @@ -67,11 +68,11 @@ const styles = ({ parameters }: JSSTheme) => ({ } }, selectable: { - '& $tr:hover': { + '& $tr:hover:not($emptyRow)': { backgroundColor: parameters.sapUiListHoverBackground, cursor: 'pointer' }, - '& $tr:active:not([data-is-selected]):not($tableGroupHeader)': { + '& $tr:active:not([data-is-selected]):not($tableGroupHeader):not($emptyRow)': { backgroundColor: parameters.sapUiListActiveBackground, '& $tableCell': { borderRight: `1px solid ${parameters.sapUiListActiveBackground}`, diff --git a/packages/main/src/components/AnalyticalTable/__snapshots__/AnalyticalTable.test.tsx.snap b/packages/main/src/components/AnalyticalTable/__snapshots__/AnalyticalTable.test.tsx.snap index 8865aa79ae0..c76bd8514d3 100644 --- a/packages/main/src/components/AnalyticalTable/__snapshots__/AnalyticalTable.test.tsx.snap +++ b/packages/main/src/components/AnalyticalTable/__snapshots__/AnalyticalTable.test.tsx.snap @@ -16,7 +16,7 @@ exports[`AnalyticalTable Alternate Row Color 1`] = ` class="AnalyticalTable--tableContainer-" >
@@ -414,58 +414,145 @@ exports[`AnalyticalTable Alternate Row Color 1`] = `
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
@@ -490,7 +577,7 @@ exports[`AnalyticalTable Loading - Loader 1`] = ` class="AnalyticalTable--tableContainer-" >
@@ -888,58 +975,145 @@ exports[`AnalyticalTable Loading - Loader 1`] = `
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
@@ -964,7 +1138,7 @@ exports[`AnalyticalTable Loading - Placeholder 1`] = ` class="AnalyticalTable--tableContainer-" >
@@ -1243,312 +1417,329 @@ exports[`AnalyticalTable Loading - Placeholder 1`] = ` />
- - - Loading interface... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; - -exports[`AnalyticalTable Tree Table 1`] = ` -
-
- - Table Title - -
-
-
-
- Name - -
-
- - - + +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + +`; + +exports[`AnalyticalTable Tree Table 1`] = ` +
+
+ + Table Title + +
+
+
+
+
+
+
+ + Name + +
+
+
+ + + Sort Ascending
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
@@ -2079,7 +2327,7 @@ exports[`AnalyticalTable custom row height 1`] = ` class="AnalyticalTable--tableContainer- AnalyticalTable--modifiedRowHeight- AnalyticalTable--modifiedRowHeight-d0-" >
@@ -2477,58 +2725,145 @@ exports[`AnalyticalTable custom row height 1`] = `
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
@@ -2553,7 +2888,7 @@ exports[`AnalyticalTable render without data 1`] = ` class="AnalyticalTable--tableContainer-" >
@@ -2773,70 +3108,309 @@ exports[`AnalyticalTable render without data 1`] = ` style="display: inline-block; width: 100%; font-weight: normal; cursor: pointer; height: 100%; overflow-x: hidden;" >
+ + + Friend Age + + +
+
+
+ + + + Sort Ascending + + + Sort Descending + + + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
- - Friend Age - - -
-
- - - - Sort Ascending - - - Sort Descending - - - -
+ +
+
+ +
+
- -
- No Data
@@ -2859,7 +3433,7 @@ exports[`AnalyticalTable test Asc desc 1`] = ` class="AnalyticalTable--tableContainer-" >
@@ -3257,58 +3831,145 @@ exports[`AnalyticalTable test Asc desc 1`] = `
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
@@ -3333,7 +3994,7 @@ exports[`AnalyticalTable test drag and drop of a draggable column 1`] = ` class="AnalyticalTable--tableContainer-" >
@@ -3731,58 +4392,145 @@ exports[`AnalyticalTable test drag and drop of a draggable column 1`] = `
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 0px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 60px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 120px; width: 60px; align-items: center;" + > + +
+ style="position: absolute; top: 0px; left: 180px; width: 60px; align-items: center;" + > + +
diff --git a/packages/main/src/components/AnalyticalTable/hooks/useTableRowStyling.ts b/packages/main/src/components/AnalyticalTable/hooks/useTableRowStyling.ts index 850cf90c6db..2eedf58a363 100644 --- a/packages/main/src/components/AnalyticalTable/hooks/useTableRowStyling.ts +++ b/packages/main/src/components/AnalyticalTable/hooks/useTableRowStyling.ts @@ -6,17 +6,22 @@ const ROW_SELECTION_ATTRIBUTE = 'data-is-selected'; export const useTableRowStyling = (hooks) => { hooks.getRowProps.push((passedRowProps, { instance, row }) => { const { classes, selectionMode, onRowSelected } = instance.webComponentsReactProperties; + const isEmptyRow = row.original?.emptyRow; let className = classes.tr; if (row.isGrouped) { className += ` ${classes.tableGroupHeader}`; } + if(isEmptyRow) { + className += ` ${classes.emptyRow}`; + } + const rowProps: any = { ...passedRowProps, className, role: 'row' }; - if ([TableSelectionMode.SINGLE_SELECT, TableSelectionMode.MULTI_SELECT].includes(selectionMode)) { + if ([TableSelectionMode.SINGLE_SELECT, TableSelectionMode.MULTI_SELECT].includes(selectionMode) && !isEmptyRow) { rowProps.onClick = (e) => { if (row.isGrouped) { return; diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index e87c536a938..b2a806851f2 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -133,7 +133,6 @@ const useStyles = createUseStyles>(sty const AnalyticalTable: FC = forwardRef((props: TableProps, ref: Ref) => { const { columns, - data, className, style, tooltip, @@ -180,6 +179,17 @@ const AnalyticalTable: FC = forwardRef((props: TableProps, ref: Ref< return DefaultColumn; }, [columnWidth]); + const data = useMemo(() => { + if (minRows > props.data.length) { + const missingRows = minRows - props.data.length; + // @ts-ignore + const emptyRows = [...Array(missingRows).keys()].map(() => ({ emptyRow: true })); + + return [...props.data, ...emptyRows]; + } + return props.data; + }, [props.data, minRows]); + const { getTableProps, headerGroups, @@ -293,8 +303,9 @@ const AnalyticalTable: FC = forwardRef((props: TableProps, ref: Ref< const internalRowHeight = rowHeight ?? calcRowHeight; const tableBodyHeight = useMemo(() => { - return internalRowHeight * Math.max(rows.length < visibleRows ? rows.length : visibleRows, minRows); - }, [internalRowHeight, rows.length, minRows, visibleRows]); + const rowNum = rows.length < visibleRows ? Math.max(rows.length, minRows) : visibleRows; + return internalRowHeight * rowNum; + }, [internalRowHeight, rows.length, visibleRows, minRows]); const noDataStyles = useMemo(() => { return { diff --git a/packages/main/src/components/AnalyticalTable/virtualization/VirtualTableRow.tsx b/packages/main/src/components/AnalyticalTable/virtualization/VirtualTableRow.tsx index 5f7e42a6d7f..7c194e673d5 100644 --- a/packages/main/src/components/AnalyticalTable/virtualization/VirtualTableRow.tsx +++ b/packages/main/src/components/AnalyticalTable/virtualization/VirtualTableRow.tsx @@ -3,21 +3,11 @@ import React from 'react'; export const VirtualTableRow = (props) => { const { style, index, data } = props; const { additionalProps, rows } = data; - const { isTreeTable, classes, columns } = additionalProps; + const { isTreeTable } = additionalProps; const row = rows[index]; if (!row) { - return ( -
- {columns.map((col, colIndex) => { - let classNames = classes.tableCell; - if (col.className) { - classNames += ` ${col.className}`; - } - return
; - })} -
- ); + return null; } return (