• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / ui5-webcomponents-react / 15071406116

16 May 2025 02:59PM CUT coverage: 88.263%. Remained the same
15071406116

Pull #7355

github

web-flow
Merge c066bd4d1 into 741ff5cbc
Pull Request #7355: docs(useSyncRef): add jsdoc

3029 of 3983 branches covered (76.05%)

5309 of 6015 relevant lines covered (88.26%)

95803.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts
1
import { actions } from 'react-table';
2
import type { TableInstance } from '../types/index.js';
3

4
export const stateReducer = (state, action, _prevState, instance: TableInstance) => {
444✔
5
  const { payload } = action;
252,209✔
6
  if (state.isRtl && action.type === actions.columnResizing) {
252,209!
7
    const { clientX } = action;
×
8
    const { startX, columnWidth, headerIdWidths } = state.columnResizing;
×
9

10
    const deltaX = startX - clientX;
×
11
    const percentageDeltaX = deltaX / columnWidth;
×
12

13
    const newColumnWidths = {};
×
14

15
    headerIdWidths.forEach(([headerId, headerWidth]) => {
×
16
      newColumnWidths[headerId] = Math.max(headerWidth + headerWidth * percentageDeltaX, 0);
×
17
    });
18

19
    return {
×
20
      ...state,
21
      columnResizing: {
22
        ...state.columnResizing,
23
        columnWidths: {
24
          ...state.columnResizing.columnWidths,
25
          ...newColumnWidths,
26
        },
27
      },
28
    };
29
  }
30
  switch (action.type) {
252,209!
31
    case 'setFilter':
32
      instance.webComponentsReactProperties.onFilter({
2,528✔
33
        filters: state.filters,
34
        value: action.filterValue,
35
        columnId: action.columnId,
36
      });
37
      return state;
2,528✔
38
    case 'toggleRowExpanded':
39
      // this flag disables scrolling to the top of the table if a table is collapsed
40
      if (!state.expanded[action.id]) {
1,672✔
41
        instance.dispatch({
102✔
42
          type: 'ROW_COLLAPSED_FLAG',
43
          payload: true,
44
        });
45
      }
46
      return state;
1,672✔
47
    case 'TABLE_RESIZE':
48
      // tableClientWidth is misleading, as only when scaled the `clientWidth` is used. In all other cases `getBoundingClientRect` is measuring the width.
49
      return { ...state, tableClientWidth: payload.tableClientWidth };
29,266✔
50
    case 'VISIBLE_ROWS':
51
      return { ...state, visibleRows: payload.visibleRows };
3,536✔
52
    case 'TABLE_SCROLLING_ENABLED':
53
      return { ...state, isScrollable: payload.isScrollable };
21,068✔
54
    case 'SET_SELECTED_ROW_IDS':
55
      return { ...state, selectedRowIds: payload.selectedRowIds };
392✔
56
    case 'SET_POPIN_COLUMNS':
57
      return { ...state, popInColumns: payload };
28,689✔
58
    case 'INTERACTIVE_ROWS_HAVE_POPIN':
59
      return { ...state, interactiveRowsHavePopIn: payload };
×
60
    case 'IS_RTL':
61
      return { ...state, isRtl: payload.isRtl };
14,946✔
62
    case 'SUB_COMPONENTS_HEIGHT':
63
      return { ...state, subComponentsHeight: payload };
10,308✔
64
    case 'TABLE_COL_RESIZED':
65
      return { ...state, tableColResized: payload };
×
66
    case 'SELECT_ROW_CB':
67
      return { ...state, selectedRowPayload: payload };
7,088✔
68
    case 'ROW_COLLAPSED_FLAG':
69
      return { ...state, rowCollapsed: payload };
136✔
70
    case 'COLUMN_DND_START':
71
      return { ...state, dndColumn: payload };
×
72
    case 'COLUMN_DND_END':
73
      return { ...state, dndColumn: '' };
128✔
74
    // fallback if the component wasn't ready yet for scrolling (elements are not initialized), e.g. when calling `.scrollToItem` on mount
75
    case 'TRIGGER_PROG_SCROLL':
76
      return { ...state, triggerScroll: payload };
160✔
77
    case 'AUTO_RESIZE':
78
      return {
714✔
79
        ...state,
80
        columnResizing: {
81
          ...state.columnResizing,
82
          columnWidths: {
83
            ...state.columnResizing.columnWidths,
84
            ...payload,
85
          },
86
        },
87
      };
88
    default:
89
      return state;
131,578✔
90
  }
91
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc