Skip to content

Commit 970119e

Browse files
committed
allow focusing TablePlaceholder
1 parent 7258679 commit 970119e

File tree

3 files changed

+52
-37
lines changed

3 files changed

+52
-37
lines changed

packages/main/src/components/AnalyticalTable/defaults/LoadingComponent/TablePlaceholder.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
}
88
}
99

10+
.container {
11+
background: var(--sapList_Background);
12+
}
13+
1014
.animation {
1115
animation-duration: 2s;
1216
animation-fill-mode: forwards;

packages/main/src/components/AnalyticalTable/defaults/LoadingComponent/TablePlaceholder.tsx

+36-32
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
1-
import { ThemingParameters, useStylesheet } from '@ui5/webcomponents-react-base';
1+
import { useStylesheet } from '@ui5/webcomponents-react-base';
22
import { clsx } from 'clsx';
33
import type { CSSProperties, FC } from 'react';
4+
import type { ColumnType } from '../../types/index.js';
45
import { resolveCellAlignment } from '../../util/index.js';
5-
import { classNames, styleData } from './TablePlaceholder.module.css.js';
6+
import { classNames, content } from './TablePlaceholder.module.css.js';
67

7-
const getArrayOfLength = (len) => Array.from(Array(len).keys());
8+
const getArrayOfLength = (len: number) => Array.from(Array(len).keys());
89

910
interface TablePlaceholderPropTypes {
10-
columns: any[];
11-
rows: number;
1211
style: CSSProperties;
12+
columns: ColumnType[];
13+
rows: number;
14+
pleaseWaitText: string;
1315
}
1416

1517
export const TablePlaceholder: FC<TablePlaceholderPropTypes> = (props) => {
16-
const { columns, rows = 5, style } = props;
18+
const { columns, rows = 5, style, pleaseWaitText } = props;
1719

18-
useStylesheet(styleData, TablePlaceholder.displayName);
20+
useStylesheet(content, TablePlaceholder.displayName);
1921

2022
return (
21-
<div
22-
style={{
23-
backgroundColor: ThemingParameters.sapList_Background,
24-
width: '100%',
25-
...style
26-
}}
27-
data-component-name="AnalyticalTableLoadingPlaceholder"
28-
>
29-
{getArrayOfLength(rows).map((_, index) => {
30-
return (
31-
<div className={classNames.row} key={`row-${index}`}>
32-
{columns.map((col) => {
33-
return (
34-
<div
35-
key={`row${index}-${col.id}`}
36-
className={classNames.cellContainer}
37-
style={{ width: col.totalWidth, ...resolveCellAlignment(col) }}
38-
>
39-
<div className={clsx(classNames.cell, classNames.animation)} />
40-
</div>
41-
);
42-
})}
43-
</div>
44-
);
45-
})}
23+
<div role="gridcell">
24+
<div
25+
style={style}
26+
className={classNames.container}
27+
title={pleaseWaitText}
28+
role="progressbar"
29+
aria-valuetext="Busy"
30+
data-component-name="AnalyticalTableLoadingPlaceholder"
31+
>
32+
{getArrayOfLength(rows).map((_, index) => {
33+
return (
34+
<div className={classNames.row} key={`row-${index}`}>
35+
{columns.map((col) => {
36+
return (
37+
<div
38+
key={`row${index}-${col.id}`}
39+
className={classNames.cellContainer}
40+
style={{ width: col.totalWidth, ...resolveCellAlignment(col) }}
41+
>
42+
<div className={clsx(classNames.cell, classNames.animation)} />
43+
</div>
44+
);
45+
})}
46+
</div>
47+
);
48+
})}
49+
</div>
4650
</div>
4751
);
4852
};

packages/main/src/components/AnalyticalTable/index.tsx

+12-5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
INVALID_TABLE,
4444
LIST_NO_DATA,
4545
NO_DATA_FILTERED,
46+
PLEASE_WAIT,
4647
ROW_COLLAPSED,
4748
ROW_EXPANDED,
4849
SELECT_ALL,
@@ -797,18 +798,24 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
797798
)
798799
);
799800
})}
800-
{loading && rows?.length === 0 && (
801-
<TablePlaceholder columns={visibleColumns} rows={minRows} style={noDataStyles} />
802-
)}
803-
{!loading && rows?.length === 0 && (
801+
{rows?.length === 0 && (
804802
<div
805803
style={noDataStyles}
806804
data-component-name="AnalyticalTableNoDataContainer"
807805
role="row"
808806
tabIndex={0}
809807
className={classNames.noDataContainer}
810808
>
811-
<NoDataComponent noDataText={noDataTextLocal} className={classNames.noData} />
809+
{loading ? (
810+
<TablePlaceholder
811+
columns={visibleColumns}
812+
rows={minRows}
813+
style={noDataStyles}
814+
pleaseWaitText={i18nBundle.getText(PLEASE_WAIT)}
815+
/>
816+
) : (
817+
<NoDataComponent noDataText={noDataTextLocal} className={classNames.noData} />
818+
)}
812819
</div>
813820
)}
814821
{rows?.length > 0 && tableRef.current && (

0 commit comments

Comments
 (0)