1 | import { __rest } from "tslib";
|
2 | import { css } from '@patternfly/react-styles';
|
3 | import styles from '@patternfly/react-styles/css/components/DualListSelector/dual-list-selector';
|
4 | import { DualListSelectorListItem } from './DualListSelectorListItem';
|
5 | import * as React from 'react';
|
6 | import { DualListSelectorListContext } from './DualListSelectorContext';
|
7 | export const DualListSelectorList = (_a) => {
|
8 | var { children } = _a, props = __rest(_a, ["children"]);
|
9 | const { setFocusedOption, isTree, ariaLabelledBy, focusedOption, displayOption, selectedOptions, id, onOptionSelect, options, isDisabled } = React.useContext(DualListSelectorListContext);
|
10 |
|
11 | const onOptionClick = (e, index, id) => {
|
12 | setFocusedOption(id);
|
13 | onOptionSelect(e, index, id);
|
14 | };
|
15 | return (React.createElement("ul", Object.assign({ className: css(styles.dualListSelectorList), role: isTree ? 'tree' : 'listbox', "aria-multiselectable": "true", "aria-labelledby": ariaLabelledBy, "aria-activedescendant": focusedOption, "aria-disabled": isDisabled ? 'true' : undefined }, props), options.length === 0
|
16 | ? children
|
17 | : options.map((option, index) => {
|
18 | if (displayOption(option)) {
|
19 | return (React.createElement(DualListSelectorListItem, { key: index, isSelected: selectedOptions.indexOf(index) !== -1, id: `${id}-option-${index}`, onOptionSelect: (e, id) => onOptionClick(e, index, id), orderIndex: index, isDisabled: isDisabled }, option));
|
20 | }
|
21 | return;
|
22 | })));
|
23 | };
|
24 | DualListSelectorList.displayName = 'DualListSelectorList';
|
25 |
|
\ | No newline at end of file |