UNPKG

@shopify/polaris

Version:

Shopify’s admin product component library

41 lines (36 loc) 1.09 kB
import React from 'react'; import { classNames } from '../../utilities/css.js'; import styles from './ActionList.scss.js'; import { Section } from './components/Section/Section.js'; function ActionList({ items, sections = [], actionRole, onActionAnyItem }) { let finalSections = []; if (items) { finalSections = [{ items }, ...sections]; } else if (sections) { finalSections = sections; } const className = classNames(styles.ActionList); const hasMultipleSections = finalSections.length > 1; const Element = hasMultipleSections ? 'ul' : 'div'; const sectionMarkup = finalSections.map((section, index) => { return section.items.length > 0 ? /*#__PURE__*/React.createElement(Section, { key: section.title || index, firstSection: index === 0, section: section, hasMultipleSections: hasMultipleSections, actionRole: actionRole, onActionAnyItem: onActionAnyItem }) : null; }); return /*#__PURE__*/React.createElement(Element, { className: className }, sectionMarkup); } export { ActionList };