Skip to content

Commit ca13875

Browse files
authored
refactor(AnalyticalTable): remove deprecated props & enums (#6021)
BREAKING CHANGE: The `TableScaleWidthMode` enum has been removed, please use `AnalyticalTableScaleWidthMode` instead. BREAKING CHANGE: The `TableSelectionBehavior` enum has been removed, please use `AnalyticalTableSelectionBehavior` instead. BREAKING CHANGE: The `TableSelectionMode ` enum has been removed, please use `AnalyticalTableSelectionMode` instead. BREAKING CHANGE: The `TableVisibleRowCountMode` enum has been removed, please use `AnalyticalTableVisibleRowCountMode ` instead. BREAKING CHANGE: The `alwaysShowSubComponent ` prop has been removed, please use `subComponentsBehavior` instead. BREAKING CHANGE: The default value (`true`) of the `sortable` prop has been removed, it is now required to explicitly set this prop, if the table should be sortable. BREAKING CHANGE: The `canReorder` [column property](https://sap.github.io/ui5-webcomponents-react/?path=/docs/data-display-analyticaltable--docs#column-properties) has been removed, please use `disableDragAndDrop` instead.
1 parent 4c8043a commit ca13875

14 files changed

+109
-134
lines changed

docs/MigrationGuide.mdx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ Please use the following components instead:
403403
- `headerContent` now only accepts the `ObjectPageHeader` component.
404404
- `headerTitle` now only accepts the `ObjectPageTitle` component.
405405

406-
**Renamed props:**
406+
**Renamed Props:**
407407

408408
- `a11yConfig.dynamicPageAnchorBar` has been renamed to `a11yConfig.objectPageAnchorBar`
409409

@@ -470,6 +470,54 @@ function MyComponent() {
470470
}
471471
```
472472

473+
### AnalyticalTable
474+
475+
**Renamed or Changed Props:**
476+
477+
- `alwaysShowSubComponent` has been removed, please use `subComponentsBehavior` with `AnalyticalTableSubComponentsBehavior.Visibe` instead.
478+
- The default value of `sortable` (`true`) has been removed. To allow sorting in your table please set `sorting` to `true` yourself.
479+
480+
**Renamed Enums:**
481+
482+
Only the names of the following enums have changed, so it's sufficient to replace them with the new name.
483+
484+
- `TableScaleWidthMode` is now `AnalyticalTableScaleWidthMode`
485+
- `TableSelectionBehavior` is now `AnalyticalTableSelectionBehavior`
486+
- `TableSelectionMode` is now `AnalyticalTableSelectionMode`
487+
- `TableVisibleRowCountMode` is now `AnalyticalTableVisibleRowCountMode`
488+
489+
**[Column Properties](https://sap.github.io/ui5-webcomponents-react/?path=/docs/data-display-analyticaltable--docs#column-properties) Changes**
490+
491+
- `canReorder` has been removed, please use `disableDragAndDrop` instead.
492+
493+
```jsx
494+
// v1
495+
const columns = [{ ...otherProperties, canReorder: false }];
496+
497+
<AnalyticalTable
498+
{...otherProps}
499+
columns={columns}
500+
alwaysShowSubComponent
501+
scaleWidthMode={TableScaleWidthMode.Grow}
502+
selectionBehavior={TableSelectionBehavior.Row}
503+
selectionMode={TableSelectionMode.MultiSelect}
504+
visibleRowCountMode={TableVisibleRowCountMode.Interactive}
505+
/>;
506+
507+
// v2
508+
const columns = [{ ...otherProps, disableDragAndDrop: true }];
509+
510+
<AnalyticalTable
511+
{...otherProps}
512+
columns={columns}
513+
subComponentsBehavior={AnalyticalTableSubComponentsBehavior.Visible}
514+
scaleWidthMode={AnalyticalTableScaleWidthMode.Grow}
515+
selectionBehavior={AnalyticalTableSelectionBehavior.Row}
516+
selectionMode={AnalyticalTableSelectionMode.MultiSelect}
517+
visibleRowCountMode={AnalyticalTableVisibleRowCountMode.Interactive}
518+
/>;
519+
```
520+
473521
### Expandable Text
474522

475523
The prop `portalContainer` has been removed as it is no longer needed due to the [popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) which is now used in the UI5 Web Components.

packages/cli/src/scripts/codemod/transforms/v2/codemodConfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"removedProps": ["portalContainer"]
1818
},
19+
"AnalyticalTable": {},
1920
"Avatar": {},
2021
"Badge": {
2122
"newComponent": "Tag"
@@ -596,6 +597,9 @@
596597
"renamedEnums": {
597598
"MessageBoxActions": "MessageBoxAction",
598599
"MessageBoxTypes": "MessageBoxType",
600+
"TableScaleWidthMode": "AnalyticalTableScaleWidthMode",
601+
"TableSelectionBehavior": "AnalyticalTableSelectionBehavior",
602+
"TableVisibleRowCountMode": "AnalyticalTableVisibleRowCountMode",
599603
"Themes": "Theme"
600604
},
601605
"enumProperties": {

packages/cli/src/scripts/codemod/transforms/v2/main.cts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function extractValueFromProp(
5454
const prop = j(el).find(j.JSXAttribute, { name: { name: propName } });
5555

5656
if (prop.size()) {
57-
const s = prop.get();
5857
const stringLiteral = prop.find(j.StringLiteral);
5958
const numericLiteral = prop.find(j.NumericLiteral);
6059
prop.remove();
@@ -112,6 +111,39 @@ export default function transform(file: FileInfo, api: API, options?: Options):
112111
});
113112
}
114113

114+
if (componentName === 'AnalyticalTable') {
115+
jsxElements.forEach((el) => {
116+
const alwaysShowSubComponent = j(el).find(j.JSXAttribute, { name: { name: 'alwaysShowSubComponent' } });
117+
if (alwaysShowSubComponent.size() > 0) {
118+
const attr = alwaysShowSubComponent.get();
119+
120+
if (
121+
attr.value.value === null ||
122+
(attr.value.value?.type === 'JSXAttribute' && attr.value.value === true) ||
123+
(attr.value.value?.type === 'JSXExpressionContainer' && attr.value.value.expression.value === true)
124+
) {
125+
j(el)
126+
.find(j.JSXOpeningElement)
127+
.get()
128+
.value.attributes.push(
129+
j.jsxAttribute(j.jsxIdentifier('subComponentsBehavior'), j.stringLiteral('Visible'))
130+
);
131+
}
132+
alwaysShowSubComponent.remove();
133+
isDirty = true;
134+
}
135+
136+
const sortable = j(el).find(j.JSXAttribute, { name: { name: 'sortable' } });
137+
if (sortable.size() === 0) {
138+
j(el)
139+
.find(j.JSXOpeningElement)
140+
.get()
141+
.value.attributes.push(j.jsxAttribute(j.jsxIdentifier('sortable'), null));
142+
isDirty = true;
143+
}
144+
});
145+
}
146+
115147
// Special Handling for logic inversions, etc.
116148
if (componentName === 'Button') {
117149
jsxElements.forEach((el) => {

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ describe('AnalyticalTable', () => {
9292
it('sorting', () => {
9393
const sort = cy.spy().as('onSortSpy');
9494
cy.mount(<AnalyticalTable data={data} columns={columns} onSort={sort} />);
95+
96+
cy.findByText('Name').click();
97+
cy.get('[ui5-popover]').should('not.exist');
98+
99+
cy.mount(<AnalyticalTable data={data} columns={columns} onSort={sort} sortable />);
95100
cy.get('[aria-rowindex="3"] > [aria-colindex="1"]').should('text', 'X');
96101

97102
cy.findByText('Name').click();
103+
cy.get('[ui5-popover]').should('be.visible');
98104
cy.findByText('Sort Ascending').shadow().findByRole('listitem').click({ force: true });
99105
cy.get('@onSortSpy').should('have.been.calledWithMatch', {
100106
detail: { column: { id: 'name' }, sortDirection: 'asc' }
@@ -752,7 +758,7 @@ describe('AnalyticalTable', () => {
752758
const GroupBySelectTable = (props: PropTypes) => {
753759
const { onRowSelect } = props;
754760
const [relevantPayload, setRelevantPayload] = useState<Record<string, any>>({});
755-
const tableInstance = useRef<Record<string, any>>();
761+
const tableInstance = useRef<Record<string, any>>(null);
756762

757763
useEffect(() => {
758764
if (tableInstance.current) {
@@ -804,7 +810,7 @@ describe('AnalyticalTable', () => {
804810
cy.findByTestId('isSelected').should('have.text', 'true');
805811

806812
cy.findByText('Friend Name').click();
807-
cy.findByText('Group').click();
813+
cy.findByText('Group').realClick();
808814
cy.get('[aria-rowindex="7"] > [aria-colindex="3"] > [title="Expand Node"] > [ui5-icon]').click();
809815

810816
cy.findByText('25').click();
@@ -1456,7 +1462,7 @@ describe('AnalyticalTable', () => {
14561462
it('Alternate Row Color', () => {
14571463
const standardRowColor = cssVarToRgb(ThemingParameters.sapList_Background);
14581464
const alternatingRowColor = cssVarToRgb(ThemingParameters.sapList_AlternatingBackground);
1459-
cy.mount(<AnalyticalTable data={data} columns={columns} alternateRowColor minRows={7} />);
1465+
cy.mount(<AnalyticalTable data={data} columns={columns} alternateRowColor minRows={7} sortable />);
14601466
cy.get('[data-component-name="AnalyticalTableContainer"]').should('have.css', 'background-color', standardRowColor);
14611467

14621468
function testAlternateRowColor() {
@@ -1779,6 +1785,8 @@ describe('AnalyticalTable', () => {
17791785
}
17801786
];
17811787
cy.mount(<AnalyticalTable data={data} columns={columns} />);
1788+
cy.get('[data-column-id="name"]').should('not.have.attr', 'aria-haspopup', 'menu').click();
1789+
cy.mount(<AnalyticalTable data={data} columns={columns} sortable />);
17821790
cy.get('[data-column-id="name"]').should('have.attr', 'aria-haspopup', 'menu').click();
17831791
cy.get('[ui5-popover]').should('be.visible');
17841792
cy.get('[data-column-id="age"]').should('not.have.attr', 'aria-haspopup');
@@ -2193,7 +2201,7 @@ describe('AnalyticalTable', () => {
21932201

21942202
it("Expandable: don't scroll when expanded/collapsed", () => {
21952203
const TestComp = () => {
2196-
const tableInstanceRef = useRef();
2204+
const tableInstanceRef = useRef<{ toggleRowExpanded?: (e: string) => void }>({});
21972205
return (
21982206
<>
21992207
<button
@@ -2236,7 +2244,7 @@ describe('AnalyticalTable', () => {
22362244

22372245
cy.mount(<AnalyticalTable data={[...data, ...data]} columns={columns} visibleRows={5} groupable />);
22382246
cy.findByText('Name').click();
2239-
cy.findByText('Group').click();
2247+
cy.findByText('Group').realClick();
22402248
cy.findByText('A (2)').trigger('keydown', {
22412249
key: 'Enter'
22422250
});
@@ -2539,7 +2547,7 @@ describe('AnalyticalTable', () => {
25392547
cy.findByText('Aggregated').should('not.exist');
25402548

25412549
cy.findByText('Name').click();
2542-
cy.findByText('Group').click();
2550+
cy.findByText('Group').realClick();
25432551
cy.findByText('Simon').should('be.visible').should('have.length', 1);
25442552
cy.findAllByText('Aggregated').should('be.visible').should('have.length', 2);
25452553
cy.get('[ui5-icon][name="navigation-right-arrow"]').should('be.visible').should('have.length', 2);

packages/main/src/components/AnalyticalTable/AnalyticalTable.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ const TableWithSubcomponents = (props) => {
356356
data={props.data}
357357
columns={props.columns}
358358
renderRowSubComponent={renderRowSubComponent}
359-
alwaysShowSubComponent={false} //default value
359+
subComponentsBehavior={AnalyticalTableSubComponentsBehavior.Expandable} //default value
360360
/>
361361
);
362362
};

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeader.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333

3434
.text {
35-
cursor: pointer;
35+
cursor: inherit;
3636
color: inherit;
3737
font-family: inherit;
3838
width: 100%;

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const ColumnHeaderContainer = forwardRef<HTMLDivElement, ColumnHeaderCont
8282
onSort={onSort}
8383
onGroupBy={onGroupByChanged}
8484
headerTooltip={column.headerTooltip}
85-
isDraggable={(column.canReorder || !column.disableDragAndDrop) && !resizeInfo.isResizingColumn}
85+
isDraggable={!column.disableDragAndDrop && !resizeInfo.isResizingColumn}
8686
virtualColumn={virtualColumn}
8787
columnVirtualizer={columnVirtualizer}
8888
isRtl={isRtl}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { useVirtualizer } from '@tanstack/react-virtual';
44
import {
55
debounce,
6-
deprecationNotice,
76
enrichEventWithDetails,
87
useI18nBundle,
98
useIsomorphicId,
@@ -151,7 +150,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
151150
selectionBehavior = AnalyticalTableSelectionBehavior.Row,
152151
selectionMode = AnalyticalTableSelectionMode.None,
153152
showOverlay,
154-
sortable = true,
153+
sortable,
155154
style,
156155
subComponentsBehavior = AnalyticalTableSubComponentsBehavior.Expandable,
157156
subRowsKey = 'subRows',
@@ -172,25 +171,14 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
172171
onAutoResize,
173172
NoDataComponent = DefaultNoDataComponent,
174173
additionalEmptyRowsCount = 0,
175-
alwaysShowSubComponent: _omit,
176174
...rest
177175
} = props;
178176

179177
useStylesheet(styleData, AnalyticalTable.displayName);
180178

181-
useEffect(() => {
182-
if (props.alwaysShowSubComponent != undefined) {
183-
deprecationNotice(
184-
'alwaysShowSubComponent',
185-
'`alwaysShowSubComponent` is deprecated. Please use `subComponentsBehavior` instead!'
186-
);
187-
}
188-
}, [props.alwaysShowSubComponent]);
189-
190179
const alwaysShowSubComponent =
191180
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.Visible ||
192-
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.IncludeHeight ||
193-
props.alwaysShowSubComponent;
181+
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.IncludeHeight;
194182

195183
const uniqueId = useIsomorphicId();
196184
const i18nBundle = useI18nBundle('@ui5/webcomponents-react');

packages/main/src/components/AnalyticalTable/types/index.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import type {
99
AnalyticalTableSubComponentsBehavior,
1010
AnalyticalTableVisibleRowCountMode,
1111
IndicationColor,
12-
TableScaleWidthMode,
13-
TableSelectionBehavior,
14-
TableSelectionMode,
15-
TableVisibleRowCountMode,
1612
TextAlign,
1713
VerticalAlign
1814
} from '../../../enums/index.js';
@@ -301,14 +297,6 @@ export interface AnalyticalTableColumnDefinition {
301297
PopInHeader?: string | ComponentType<any> | ((props?: any) => ReactNode);
302298

303299
//use useDragAndDrop
304-
/**
305-
* Defines if the column is reorderable by dragging and dropping columns.
306-
*
307-
* Defaults to: `true`
308-
*
309-
* @deprecated please use `disableDragAndDrop` instead.
310-
*/
311-
canReorder?: boolean;
312300
/**
313301
* Defines if the column is reorderable by dragging and dropping columns.
314302
*/
@@ -392,10 +380,7 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
392380
*
393381
* __Note:__ When `"Auto"` or `"AutoWithEmptyRows"` is enabled, we recommend using a fixed height for the parent container.
394382
*/
395-
visibleRowCountMode?:
396-
| AnalyticalTableVisibleRowCountMode
397-
| keyof typeof AnalyticalTableVisibleRowCountMode
398-
| TableVisibleRowCountMode;
383+
visibleRowCountMode?: AnalyticalTableVisibleRowCountMode | keyof typeof AnalyticalTableVisibleRowCountMode;
399384
/**
400385
* Specifies the number of additional empty rows added to the bottom of a table that is normally __non__ scrollable.
401386
* Use this prop if you want to ensure that the table is scrollable.
@@ -518,10 +503,7 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
518503
*
519504
* __Default:__ `"Row"`
520505
*/
521-
selectionBehavior?:
522-
| AnalyticalTableSelectionBehavior
523-
| keyof typeof AnalyticalTableSelectionBehavior
524-
| TableSelectionBehavior;
506+
selectionBehavior?: AnalyticalTableSelectionBehavior | keyof typeof AnalyticalTableSelectionBehavior;
525507
/**
526508
* Defines the `SelectionMode` of the table.
527509
*
@@ -531,7 +513,7 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
531513
*
532514
* @default `"None"`
533515
*/
534-
selectionMode?: AnalyticalTableSelectionMode | keyof typeof AnalyticalTableSelectionMode | TableSelectionMode;
516+
selectionMode?: AnalyticalTableSelectionMode | keyof typeof AnalyticalTableSelectionMode;
535517

536518
/**
537519
* Defines the column growing behaviour. Possible Values:
@@ -547,7 +529,7 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
547529
* @default `"Default"`
548530
*
549531
*/
550-
scaleWidthMode?: AnalyticalTableScaleWidthMode | keyof typeof AnalyticalTableScaleWidthMode | TableScaleWidthMode;
532+
scaleWidthMode?: AnalyticalTableScaleWidthMode | keyof typeof AnalyticalTableScaleWidthMode;
551533
/**
552534
* Defines the number of the CSS `scaleX(sx: number)` function. `sx` is representing the abscissa of the scaling vector.
553535
*/
@@ -620,12 +602,6 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
620602
* __Note:__ Subcomponents can affect performance, especially when used in a tree table (`isTreeTable={true}`). If you face performance issues, please try memoizing your subcomponent.
621603
*/
622604
renderRowSubComponent?: (row?: any) => ReactNode;
623-
/**
624-
* Defines whether a subcomponent should be rendered as expandable container or directly at the bottom of the row.
625-
*
626-
* @deprecated please use `subComponentsBehavior` instead.
627-
*/
628-
alwaysShowSubComponent?: boolean;
629605
/**
630606
* Defines the rendering and height calculation behavior of subcomponents when `renderRowSubComponent` is used.
631607
*

packages/main/src/enums/TableScaleWidthMode.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/main/src/enums/TableSelectionBehavior.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)