import React from 'react';
import classNames from 'classnames';
import { SoftListGroup } from '../ListGroup';
import { toInitials } from '../../services';
export const SoftNavDrawerGroup = ({ className, listItems, flyoutMenuButtonClick, ...rest }) => {
    const classes = classNames('softNavDrawerGroup', className);
    const listItemsExists = listItems && !!listItems.length;
    // Alter listItems object with prop flyoutMenu and extra props
    const newListItems = !listItemsExists ? undefined : listItems.map((item) => {
        // If the flyout menu exists, pass back the list of times and the title with the onClick handler of the item
        const { flyoutMenu, ...itemProps } = item;
        if (flyoutMenu && flyoutMenuButtonClick) {
            const items = [...flyoutMenu.listItems];
            const title = `${flyoutMenu.title}`;
            itemProps.onClick = () => flyoutMenuButtonClick(items, title);
        }
        // Make some declarations of props for the side nav implementation
        itemProps.className = classNames('softNavDrawerGroup__item', item.className);
        itemProps.size = item.size || 's';
        itemProps['aria-label'] = item['aria-label'] || item.label;
        // Add an avatar in place of non-existent icons
        const itemProvidesIcon = !!item.iconType || !!item.icon;
        if (!itemProvidesIcon) {
            itemProps.icon = (React.createElement("span", { className: "softNavDrawerGroup__itemDefaultIcon" }, toInitials(item.label)));
        }
        // And return the item with conditional `onClick` and without `flyoutMenu`
        return { ...itemProps };
    });
    return (React.createElement(SoftListGroup, Object.assign({ className: classes, listItems: newListItems }, rest)));
};
//# sourceMappingURL=SoftNavDrawerGroup.js.map