UNPKG

@momentum-ui/react-collaboration

Version:

Cisco Momentum UI Framework for React Collaboration Applications

46 lines 2.13 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import React, { useContext } from 'react'; import { ListBoxContext } from '../ListBoxBase/ListBoxBase'; import { useOption } from '@react-aria/listbox'; import Icon from '../Icon'; import ListItemBaseSection from '../ListItemBaseSection'; import ListItemBase from '../ListItemBase'; /** * @deprecated Use the equivalent from momentum.design (NPM: `@momentum-design/components/dist/react`) */ function ListBoxItem(props) { var _a, _b; var item = props.item; var ref = React.useRef(null); var state = useContext(ListBoxContext); var isDisabled = state.disabledKeys.has(item.key); var isSelected = state.selectionManager.isSelected(item.key); var optionProps = useOption({ key: item.key, isDisabled: isDisabled, 'aria-label': item['aria-label'], isSelected: isSelected, shouldFocusOnHover: false, }, state, ref).optionProps; return (React.createElement(ListItemBase, __assign({ isPadded: true, key: item.key, ref: ref }, optionProps, { isDisabled: isDisabled, lang: (_a = item.props) === null || _a === void 0 ? void 0 : _a.lang, size: (_b = item.props) === null || _b === void 0 ? void 0 : _b.size }), React.createElement(ListItemBaseSection, { position: "fill", title: item.textValue }, item.rendered), isSelected && (React.createElement(ListItemBaseSection, { position: "end" }, React.createElement(Icon, { fillColor: "var(--mds-color-theme-control-active-normal)", name: "check", weight: "bold", scale: 16 }))))); } /** * ListBoxItem component used internally as a wrapper for items inside a listbox. * It's using the ListItem component internally. * @internal */ export default ListBoxItem; //# sourceMappingURL=ListBoxItem.js.map