UNPKG

1.69 kBJavaScriptView Raw
1import { __rest } from "tslib";
2import { css } from '@patternfly/react-styles';
3import styles from '@patternfly/react-styles/css/components/DualListSelector/dual-list-selector';
4import { DualListSelectorListItem } from './DualListSelectorListItem';
5import * as React from 'react';
6import { DualListSelectorListContext } from './DualListSelectorContext';
7export 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 // only called when options are passed via options prop
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};
24DualListSelectorList.displayName = 'DualListSelectorList';
25//# sourceMappingURL=DualListSelectorList.js.map
\No newline at end of file