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

SAP / ui5-webcomponents-react / 9599924297

20 Jun 2024 03:08PM CUT coverage: 81.351% (-6.4%) from 87.716%
9599924297

Pull #5940

github

web-flow
Merge 999dd9bef into cb684cdfb
Pull Request #5940: feat: update to @ui5/webcomonents 2.0.0-rc.6

2634 of 3832 branches covered (68.74%)

10 of 11 new or added lines in 6 files covered. (90.91%)

374 existing lines in 5 files now uncovered.

4794 of 5893 relevant lines covered (81.35%)

69791.28 hits per line

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

12.12
/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([
403✔
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) => {
403✔
19
  const tagName = ref.tagName;
×
20
  const tagNameWithoutSuffix = getTagNameWithoutScopingSuffix(tagName);
×
21

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

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

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

60
export const syncRef = (ref: Ref<unknown>, node: unknown): void => {
403✔
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