Skip to content

Commit 8e13ec6

Browse files
committed
AT: fix lint errors
1 parent 2934283 commit 8e13ec6

File tree

15 files changed

+63
-72
lines changed

15 files changed

+63
-72
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js';
22
import paperPlaneIcon from '@ui5/webcomponents-icons/paper-plane.js';
3+
import { isIOS, isMac } from '@ui5/webcomponents-react-base/Device';
34
import { ThemingParameters } from '@ui5/webcomponents-react-base/ThemingParameters';
45
import { useCallback, useEffect, useMemo, useRef, useState, version as reactVersion } from 'react';
56
import type {
@@ -80,7 +81,6 @@ import { useRowDisableSelection } from './pluginHooks/useRowDisableSelection';
8081
import { cssVarToRgb, cypressPassThroughTestsFactory } from '@/cypress/support/utils';
8182
import type { RowType } from '@/packages/main/src/components/AnalyticalTable/types/index.js';
8283
import { getUi5TagWithSuffix } from '@/packages/main/src/internal/utils.js';
83-
import { isIOS, isMac } from '@ui5/webcomponents-react-base/Device';
8484

8585
const canUseVoiceOver = isIOS() || isMac();
8686

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ interface VerticalResizerProps {
1717
classNames: ClassNames;
1818
}
1919

20+
interface VerticalResizerPosition {
21+
left: number;
22+
top: number;
23+
width: number;
24+
}
25+
2026
const isTouchEvent = (e, touchEvent) => {
2127
if (e.type === touchEvent) {
2228
return !(e.touches && e.touches.length > 1);
@@ -39,7 +45,7 @@ export const VerticalResizer = (props: VerticalResizerProps) => {
3945

4046
const startY = useRef(null);
4147
const verticalResizerRef = useRef(null);
42-
const [resizerPosition, setResizerPosition] = useState(undefined);
48+
const [resizerPosition, setResizerPosition] = useState<undefined | VerticalResizerPosition>(undefined);
4349
const [isDragging, setIsDragging] = useState(false);
4450
const [mountTouchEvents, setMountTouchEvents] = useState(false);
4551

@@ -54,34 +60,37 @@ export const VerticalResizer = (props: VerticalResizerProps) => {
5460
}, []);
5561

5662
const handleMove = useCallback(
57-
(e) => {
63+
(e: TouchEvent | MouseEvent) => {
5864
setResizerPosition((prev) => ({
5965
...prev,
60-
top: isTouchEvent(e, 'touchmove') ? Math.round(e.touches[0].pageY) : e.pageY,
66+
top: isTouchEvent(e, 'touchmove') ? Math.round((e as TouchEvent).touches[0].pageY) : (e as MouseEvent).pageY,
6167
}));
6268
},
6369
[setResizerPosition],
6470
);
65-
const handleResizeEnd = (e: TouchEvent | MouseEvent) => {
66-
setIsDragging(false);
67-
const rowCount = Math.floor(
68-
(analyticalTableRef.current.clientHeight +
69-
(isTouchEvent(e, 'touchend')
70-
? Math.round((e as TouchEvent).changedTouches[0].pageY)
71-
: (e as MouseEvent).pageY) -
72-
startY.current -
73-
extensionsHeight -
74-
5) /*resizer height*/ /
75-
popInRowHeight,
76-
);
77-
if (hasPopInColumns) {
78-
dispatch({ type: 'INTERACTIVE_ROWS_HAVE_POPIN', payload: true });
79-
}
80-
dispatch({
81-
type: 'VISIBLE_ROWS',
82-
payload: { visibleRows: rowCount },
83-
});
84-
};
71+
const handleResizeEnd = useCallback(
72+
(e: TouchEvent | MouseEvent) => {
73+
setIsDragging(false);
74+
const rowCount = Math.floor(
75+
(analyticalTableRef.current.clientHeight +
76+
(isTouchEvent(e, 'touchend')
77+
? Math.round((e as TouchEvent).changedTouches[0].pageY)
78+
: (e as MouseEvent).pageY) -
79+
startY.current -
80+
extensionsHeight -
81+
5) /*resizer height*/ /
82+
popInRowHeight,
83+
);
84+
if (hasPopInColumns) {
85+
dispatch({ type: 'INTERACTIVE_ROWS_HAVE_POPIN', payload: true });
86+
}
87+
dispatch({
88+
type: 'VISIBLE_ROWS',
89+
payload: { visibleRows: rowCount },
90+
});
91+
},
92+
[analyticalTableRef, dispatch, extensionsHeight, hasPopInColumns, popInRowHeight],
93+
);
8594

8695
useEffect(() => {
8796
const removeEventListeners = () => {
@@ -107,7 +116,7 @@ export const VerticalResizer = (props: VerticalResizerProps) => {
107116
return () => {
108117
removeEventListeners();
109118
};
110-
}, [isDragging]);
119+
}, [handleMove, handleResizeEnd, isDragging, mountTouchEvents]);
111120

112121
useEffect(() => {
113122
const resizerPosTop = verticalResizerRef.current?.getBoundingClientRect()?.top + window.scrollY;
@@ -126,15 +135,7 @@ export const VerticalResizer = (props: VerticalResizerProps) => {
126135
handleOnLoadMore({ type: 'tableGrow' } as Event);
127136
}
128137
isInitial.current = false;
129-
}, [rowsLength, visibleRows]);
130-
131-
const [allowed, setAllowed] = useState(false);
132-
useEffect(() => {
133-
setAllowed(true);
134-
}, []);
135-
if (!allowed) {
136-
return null;
137-
}
138+
}, [handleOnLoadMore, rowsLength, visibleRows]);
138139

139140
return (
140141
<div

packages/main/src/components/AnalyticalTable/defaults/Column/Expandable.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { FocusEvent } from 'react';
88
import type { ButtonDomRef } from '../../../../webComponents/Button/index.js';
99
import { Button } from '../../../../webComponents/Button/index.js';
1010
import { Icon } from '../../../../webComponents/Icon/index.js';
11-
import type { ColumnType, RowType, WCRPropertiesType } from '../../types/index.js';
11+
import type { CellInstance } from '../../types/index.js';
1212
import { RenderColumnTypes } from '../../types/index.js';
1313

1414
const getPadding = (level) => {
@@ -26,15 +26,7 @@ const getPadding = (level) => {
2626
}
2727
};
2828

29-
interface ExpandableProps {
30-
cell: Record<string, any>;
31-
row: RowType;
32-
column: ColumnType;
33-
visibleColumns: ColumnType[];
34-
webComponentsReactProperties: WCRPropertiesType;
35-
}
36-
37-
export const Expandable = (props: ExpandableProps) => {
29+
export const Expandable = (props: CellInstance) => {
3830
const { cell, row, column, visibleColumns: columns, webComponentsReactProperties } = props;
3931
const {
4032
renderRowSubComponent,
@@ -92,7 +84,7 @@ export const Expandable = (props: ExpandableProps) => {
9284
onClick={rowProps.onClick}
9385
mode={IconMode.Interactive}
9486
name={row.isExpanded ? iconNavDownArrow : iconNavRightArrow}
95-
aria-expanded={`${row.isExpanded}`}
87+
aria-expanded={`${row.isExpanded}` as 'true' | 'false'}
9688
data-component-name="AnalyticalTableExpandIcon"
9789
className={classNames.expandableIcon}
9890
accessibleName={

packages/main/src/components/AnalyticalTable/defaults/Column/Grouped.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { clsx } from 'clsx';
44
import type { CSSProperties } from 'react';
55
import { TextAlign } from '../../../../enums/TextAlign.js';
66
import { Icon } from '../../../../webComponents/Icon/index.js';
7+
import type { CellInstance } from '../../types/index.js';
78
import { RenderColumnTypes } from '../../types/index.js';
89

9-
export const Grouped = (props) => {
10+
export const Grouped = (props: CellInstance) => {
1011
const { cell, row, webComponentsReactProperties } = props;
1112
const { translatableTexts, classes } = webComponentsReactProperties;
1213

packages/main/src/components/AnalyticalTable/defaults/Column/PopIn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { FlexBoxDirection } from '../../../../enums/FlexBoxDirection.js';
55
import { FlexBoxWrap } from '../../../../enums/FlexBoxWrap.js';
66
import { Text } from '../../../../webComponents/Text/index.js';
77
import { FlexBox } from '../../../FlexBox/index.js';
8-
import type { TableInstance } from '../../types/index.js';
8+
import type { CellInstance } from '../../types/index.js';
99
import { RenderColumnTypes } from '../../types/index.js';
1010

11-
export const PopIn = (instance: TableInstance) => {
11+
export const PopIn = (instance: CellInstance) => {
1212
const {
1313
state,
1414
contentToRender,

packages/main/src/components/AnalyticalTable/hooks/useCanUseVoiceOver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export function useCanUseVoiceOver() {
88
const [canUseVoiceOver, setCanUseVoiceOver] = useState(false);
99

1010
useEffect(() => {
11+
// Needs another rendering cycle to prevent hydration errors
12+
// eslint-disable-next-line react-hooks/set-state-in-effect
1113
setCanUseVoiceOver(isIOS() || isMac());
1214
}, []);
1315

packages/main/src/components/AnalyticalTable/hooks/useKeyboardNavigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const useGetTableProps = (
9898
currentlyFocusedCell.current = null;
9999
tableRef.current.tabIndex = 0;
100100
}
101-
}, [data, columns, showOverlay]);
101+
}, [data, columns, showOverlay, tableRef]);
102102

103103
const onTableFocus = useCallback(
104104
(e) => {

packages/main/src/components/AnalyticalTable/hooks/useSyncScroll.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export function useSyncScroll(
2323
return;
2424
}
2525

26+
// Is a React ref
27+
// eslint-disable-next-line react-hooks/immutability
2628
scrollbar.scrollTop = content.scrollTop;
2729

2830
const sync = (source: 'content' | 'scrollbar') => {

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
useSyncRef,
1313
} from '@ui5/webcomponents-react-base';
1414
import { clsx } from 'clsx';
15-
import type { CSSProperties, MutableRefObject } from 'react';
15+
import type { CSSProperties } from 'react';
1616
import { forwardRef, useCallback, useEffect, useId, useMemo, useRef } from 'react';
1717
import {
1818
useColumnOrder,
@@ -406,7 +406,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
406406
!!Object.keys(tableState.subComponentsHeight);
407407

408408
if (tableInstance && {}.hasOwnProperty.call(tableInstance, 'current')) {
409-
(tableInstance as MutableRefObject<Record<string, any>>).current = tableInstanceRef.current;
409+
(tableInstance as { current: TableInstance }).current = tableInstanceRef.current;
410410
}
411411
if (typeof tableInstance === 'function') {
412412
tableInstance(tableInstanceRef.current);
@@ -496,15 +496,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
496496
});
497497
}
498498
}
499-
}, [
500-
analyticalTableRef.current?.parentElement?.getBoundingClientRect().height,
501-
analyticalTableRef.current?.getBoundingClientRect().y,
502-
extensionsHeight,
503-
popInRowHeight,
504-
visibleRowCountMode,
505-
includeSubCompRowHeight,
506-
tableState.subComponentsHeight,
507-
]);
499+
}, [extensionsHeight, popInRowHeight, visibleRowCountMode, includeSubCompRowHeight, tableState.subComponentsHeight]);
508500

509501
useEffect(() => {
510502
setGlobalFilter(globalFilterValue);
@@ -526,7 +518,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
526518
tableWidthObserver.disconnect();
527519
parentHeightObserver.disconnect();
528520
};
529-
}, [updateTableClientWidth, updateRowsCount]);
521+
}, [updateTableClientWidth, updateRowsCount, analyticalTableRef]);
530522

531523
useIsomorphicLayoutEffect(() => {
532524
dispatch({ type: 'IS_RTL', payload: { isRtl } });
@@ -547,7 +539,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
547539
payload: { visibleRows: undefined },
548540
});
549541
}
550-
}, [visibleRowCountMode, tableState.visibleRows]);
542+
}, [visibleRowCountMode, tableState.visibleRows, dispatch]);
551543

552544
useEffect(() => {
553545
if (groupBy) {
@@ -559,13 +551,13 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
559551
if (selectedRowIds) {
560552
dispatch({ type: 'SET_SELECTED_ROW_IDS', payload: { selectedRowIds } });
561553
}
562-
}, [selectedRowIds]);
554+
}, [dispatch, selectedRowIds]);
563555

564556
const tableBodyHeight = useMemo(() => {
565557
if (typeof tableState.bodyHeight === 'number') {
566558
return tableState.bodyHeight;
567559
}
568-
let rowNum;
560+
let rowNum: number;
569561
if (visibleRowCountMode === AnalyticalTableVisibleRowCountMode.AutoWithEmptyRows) {
570562
rowNum = internalVisibleRowCount;
571563
} else {

packages/main/src/components/AnalyticalTable/pluginHooks/useF2CellEdit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ function findFirstFocusableInside(element: HTMLElement) {
213213
* Init `cellContentTabIndex` if the plugin hook is used.
214214
*/
215215
function useInstanceBeforeDimensions(instance: TableInstance) {
216+
const { dispatch } = instance;
216217
useEffect(() => {
217-
instance.dispatch({ type: 'CELL_CONTENT_TAB_INDEX', payload: -1 });
218-
}, [instance.dispatch]);
218+
dispatch({ type: 'CELL_CONTENT_TAB_INDEX', payload: -1 });
219+
}, [dispatch]);
219220
}

0 commit comments

Comments
 (0)