import React from 'react';
import classNames from 'classnames';
import { SoftListGroupItem, } from './SoftListGroupItem';
export const SoftListGroup = ({ children, className, flush, bordered, wrapText, listItems, maxWidth, style, showToolTips, ...rest }) => {
    let newStyle;
    let widthClassName;
    if (maxWidth !== true) {
        const value = typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth;
        newStyle = { ...style, maxWidth: value };
    }
    else if (maxWidth === true) {
        widthClassName = 'softListGroup-maxWidthDefault';
    }
    const classes = classNames('softListGroup', {
        'softListGroup-flush': flush,
        'softListGroup-bordered': bordered,
    }, widthClassName, className);
    let childrenOrListItems = null;
    if (listItems) {
        childrenOrListItems = (listItems.map((item, index) => {
            return [
                React.createElement(SoftListGroupItem, Object.assign({ key: `title-${index}`, showToolTip: showToolTips, wrapText: wrapText }, item))
            ];
        }));
    }
    else {
        if (showToolTips) {
            childrenOrListItems = React.Children.map(children, child => {
                // @ts-ignore
                return React.cloneElement(child, {
                    showToolTip: true
                });
            });
        }
        else {
            childrenOrListItems = children;
        }
    }
    return (React.createElement("ul", Object.assign({ className: classes, style: newStyle || style }, rest), childrenOrListItems));
};
// @ts-ignore
SoftListGroup.defaultProps = {
    flush: false,
    bordered: false,
    wrapText: false,
    maxWidth: true,
    showToolTips: false,
};
//# sourceMappingURL=SoftListGroup.js.map