'use strict';

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

var styles = {"actionContainer":"wnyB0d1ZE70-","actionButton":"mljM3ouZmbM-","spinning":"uMfMpnitRs0-"};

function FilterPickerAction(props) {
    const { searchValue, handleClose } = React.useContext(FilterPickerProvider.FilterPickerContext);
    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.FilterPickerAction = FilterPickerAction;
