import React, { Component } from 'react';
import classNames from 'classnames';
import { SoftIcon } from '../../Icon';
function resolveIconAndColor(checked) {
    if (!checked) {
        return { icon: 'empty' };
    }
    return checked === 'on'
        ? { icon: 'check', color: 'text' }
        : { icon: 'cross', color: 'text' };
}
export class SoftSelectableListItem extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        const { children, className, disabled, checked, isFocused, showIcons, prepend, append, ...rest } = this.props;
        const classes = classNames('softSelectableListItem', {
            'softSelectableListItem-isFocused': isFocused,
        }, className);
        let buttonIcon;
        if (showIcons) {
            const { icon, color } = resolveIconAndColor(checked);
            buttonIcon = (React.createElement(SoftIcon, { className: "softSelectableListItem__icon", color: color, type: icon }));
        }
        let prependNode;
        if (prepend) {
            prependNode = (React.createElement("span", { className: "softSelectableListItem__prepend" }, prepend));
        }
        let appendNode;
        if (append) {
            appendNode = (React.createElement("span", { className: "softSelectableListItem__append" }, append));
        }
        return (React.createElement("button", Object.assign({ role: "option", type: "button", "aria-selected": isFocused, className: classes, disabled: disabled, "aria-disabled": disabled }, rest),
            React.createElement("span", { className: "softSelectableListItem__content" },
                buttonIcon,
                prependNode,
                React.createElement("span", { className: "softSelectableListItem__text" }, children),
                appendNode)));
    }
}
SoftSelectableListItem.defaultProps = {
    showIcons: true,
};
//# sourceMappingURL=SoftSelectableListItem.js.map