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

SAP / ui5-webcomponents-react / 9418003409

07 Jun 2024 01:40PM CUT coverage: 88.099% (-0.5%) from 88.645%
9418003409

Pull #5860

github

web-flow
Merge 2d8ec93e0 into 2bba948ab
Pull Request #5860: feat: support React 19

3096 of 4079 branches covered (75.9%)

88 of 94 new or added lines in 38 files covered. (93.62%)

31 existing lines in 4 files now uncovered.

5500 of 6243 relevant lines covered (88.1%)

66352.01 hits per line

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

18.18
/packages/main/src/components/FilterBar/utils.tsx
1
import type { Ref } from 'react';
2
import { cloneElement } from 'react';
3
import { getTagNameWithoutScopingSuffix } from '../../internal/utils.js';
4

5
const inputTagNames = new Set([
447✔
6
  'UI5-COMBOBOX',
7
  'UI5-DATE-PICKER',
8
  'UI5-DATERANGE-PICKER',
9
  'UI5-DATETIME-PICKER',
10
  'UI5-DURATION-PICKER',
11
  'UI5-INPUT',
12
  'UI5-MULTI-INPUT',
13
  'UI5-RATING-INDICATOR',
14
  'UI5-STEP-INPUT',
15
  'UI5-TIME-PICKER'
16
]);
17

18
export const filterValue = (ref, child) => {
447✔
UNCOV
19
  const tagName = ref.tagName;
×
UNCOV
20
  const tagNameWithoutSuffix = getTagNameWithoutScopingSuffix(tagName);
×
21

UNCOV
22
  let filterItemProps = {};
×
UNCOV
23
  if (inputTagNames.has(tagNameWithoutSuffix)) {
×
UNCOV
24
    filterItemProps = { value: ref.value ?? '' };
×
25
  }
UNCOV
26
  if (tagNameWithoutSuffix === 'UI5-SELECT' || tagNameWithoutSuffix === 'UI5-MULTI-COMBOBOX') {
×
UNCOV
27
    const filterChildren = child.props.children.props.children;
×
UNCOV
28
    let options = undefined;
×
UNCOV
29
    if (filterChildren) {
×
UNCOV
30
      const selectedIndices = Array.from(ref.children as HTMLCollectionOf<any>)
×
UNCOV
31
        .map((item, index) => (item.selected ? index : false))
×
UNCOV
32
        .filter((el) => el !== false);
×
UNCOV
33
      const selectedIndicesSet = new Set(selectedIndices);
×
34

UNCOV
35
      const filterChildrenArr = Array.isArray(filterChildren) ? filterChildren : [filterChildren];
×
UNCOV
36
      options = filterChildrenArr.map((item, index) => {
×
UNCOV
37
        if (selectedIndicesSet.has(index)) {
×
UNCOV
38
          return cloneElement(item, { selected: true });
×
39
        }
UNCOV
40
        return cloneElement(item, { selected: false });
×
41
      });
42
    }
UNCOV
43
    filterItemProps = { children: options };
×
44
  }
UNCOV
45
  if (tagNameWithoutSuffix === 'UI5-SWITCH' || tagNameWithoutSuffix === 'UI5-CHECKBOX') {
×
UNCOV
46
    filterItemProps = { checked: ref.checked };
×
47
  }
UNCOV
48
  return filterItemProps;
×
49
};
50

51
export const renderSearchWithValue = (renderSearchElement, searchValue, defaultProps = {}) => {
447!
52
  const props = { ...defaultProps, ...renderSearchElement?.props };
28✔
53
  return cloneElement(renderSearchElement, {
28✔
54
    ...props,
55
    'data-component-name': 'FilterBarSearch',
56
    value: searchValue ?? renderSearchElement?.props?.value
56✔
57
  });
58
};
59

60
export const syncRef = (ref: Ref<unknown>, node: unknown): void => {
447✔
UNCOV
61
  if (ref) {
×
62
    if (typeof ref === 'function') {
×
63
      ref(node);
×
64
    } else if (ref.hasOwnProperty('current')) {
×
65
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
      // @ts-ignore
67
      ref.current = node;
×
68
    }
69
  }
70
};
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