@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
42 lines • 2.03 kB
JavaScript
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);
};
/* eslint-disable @typescript-eslint/ban-types */
import React, { useContext } from 'react';
import './ListBoxSection.style.scss';
import { STYLE } from './ListBoxSection.constants';
import { useListBoxSection } from '@react-aria/listbox';
import { ListBoxContext } from '../ListBoxBase/ListBoxBase';
import ListBoxItem from '../ListBoxItem';
import ContentSeparator from '../ContentSeparator';
/**
* @deprecated Use the equivalent from momentum.design (NPM: `@momentum-design/components/dist/react`)
*/
var ListBoxSection = function (props) {
var section = props.section;
var _a = useListBoxSection({
heading: section.rendered,
'aria-label': section['aria-label'],
}), itemProps = _a.itemProps, headingProps = _a.headingProps, groupProps = _a.groupProps;
var state = useContext(ListBoxContext);
return (React.createElement(React.Fragment, null,
section.key !== state.collection.getFirstKey() && React.createElement(ContentSeparator, null),
React.createElement("li", __assign({}, itemProps),
section.rendered && (React.createElement("div", __assign({}, headingProps, { className: STYLE.wrapper }), section.rendered)),
React.createElement("ul", __assign({}, groupProps, { className: STYLE.subItemsWrapper }), Array.from(section.childNodes).map(function (node) { return (React.createElement(ListBoxItem, { key: node.key, item: node })); })))));
};
/**
* ListBoxSection is used internally to display sectioned items.
* This component should not be exported as part of the library.
* @internal
*/
export default ListBoxSection;
//# sourceMappingURL=ListBoxSection.js.map