@shopify/polaris
Version:
Shopify’s admin product component library
49 lines (40 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var css = require('../../utilities/css.js');
var ActionList$1 = require('./ActionList.scss.js');
var Section = require('./components/Section/Section.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
function ActionList({
items,
sections = [],
actionRole,
onActionAnyItem
}) {
let finalSections = [];
if (items) {
finalSections = [{
items
}, ...sections];
} else if (sections) {
finalSections = sections;
}
const className = css.classNames(ActionList$1['default'].ActionList);
const hasMultipleSections = finalSections.length > 1;
const Element = hasMultipleSections ? 'ul' : 'div';
const sectionMarkup = finalSections.map((section, index) => {
return section.items.length > 0 ? /*#__PURE__*/React__default['default'].createElement(Section.Section, {
key: section.title || index,
firstSection: index === 0,
section: section,
hasMultipleSections: hasMultipleSections,
actionRole: actionRole,
onActionAnyItem: onActionAnyItem
}) : null;
});
return /*#__PURE__*/React__default['default'].createElement(Element, {
className: className
}, sectionMarkup);
}
exports.ActionList = ActionList;