'use strict';

var React = require('react');
var Chip = require('./Chip-cjs.js');
require('./tslib.es6-cjs.js');
var Icon = require('./Icon-cjs.js');
var ComboboxProvider = require('./ComboboxProvider-cjs.js');

function ComboboxTrigger({ label = "Select", selected, activatorRef, }) {
    const { handleOpen } = React.useContext(ComboboxProvider.ComboboxContext);
    const hasSelection = selected.length;
    const selectedLabel = selected.map(option => option.label).join(", ");
    return (React.createElement(Chip.Chip, { variation: hasSelection ? "base" : "subtle", label: hasSelection ? selectedLabel : "", ariaLabel: label, heading: label, onClick: handleOpen, role: "combobox", ref: activatorRef }, !hasSelection && (React.createElement(Chip.Chip.Suffix, null,
        React.createElement(Icon.Icon, { name: "add", size: "small" })))));
}

exports.ComboboxTrigger = ComboboxTrigger;
