'use strict';

var React = require('react');
var Typography = require('./Typography-cjs.js');
var ComboboxProvider = require('./ComboboxProvider-cjs.js');

var styles = {"actionContainer":"NWf8JR3TBoo-","actionButton":"PoMXFVYVY5A-","spinning":"lP2oDQm9j88-"};

function ComboboxAction(props) {
    const { searchValue, handleClose } = React.useContext(ComboboxProvider.ComboboxContext);
    if (props.visible !== undefined) {
        const isVisible = typeof props.visible === "function"
            ? props.visible({ searchValue })
            : props.visible;
        if (!isVisible) {
            return null;
        }
    }
    const options = { searchValue };
    const computedLabel = typeof props.label === "string" ? props.label : props.label(options);
    const handleClick = (e) => {
        if (!props.keepOpenOnClick) {
            handleClose();
        }
        props.onClick(e, options);
    };
    return (React.createElement("div", { className: styles.actionContainer },
        React.createElement("button", { className: styles.actionButton, onClick: handleClick, type: "button" },
            React.createElement(Typography.Typography, { element: "span", size: "base", textColor: "interactive", fontWeight: "semiBold" }, computedLabel))));
}

exports.ComboboxAction = ComboboxAction;
