import { __assign, __extends } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { Component } from 'react';
import { BaseTrigger } from './BaseTrigger';
import { getPathLabel } from '../path-fns';
import { SearchInput } from './Search';
var SingleTrigger = (function (_super) {
    __extends(SingleTrigger, _super);
    function SingleTrigger() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.onKeywordChange = function (e) {
            _this.props.onKeywordChange(e.target.value);
        };
        return _this;
    }
    SingleTrigger.prototype.render = function () {
        var _a = this.props, className = _a.className, visible = _a.visible, clearable = _a.clearable, selectedPath = _a.selectedPath, keyword = _a.keyword, disabled = _a.disabled, i18n = _a.i18n, searchable = _a.searchable, placeholder = _a.placeholder, onClick = _a.onClick, onClear = _a.onClear, onKeywordChange = _a.onKeywordChange, renderValue = _a.renderValue;
        var showSearch = visible && searchable;
        var hasValue = selectedPath.length > 0;
        var inputPlaceholder = hasValue
            ? getPathLabel(selectedPath)
            : i18n.searchPlaceholder;
        var selectedPaths = hasValue ? [selectedPath] : [];
        return (_jsx(BaseTrigger, __assign({ disabled: disabled, className: className, clearable: clearable, visible: visible, onClear: onClear, selectedPaths: selectedPaths, keyword: keyword, onKeywordChange: onKeywordChange, onClick: onClick, i18n: i18n, renderValue: renderValue, showLabels: !showSearch, placeholder: placeholder, searchable: searchable }, { children: showSearch && (_jsx(SearchInput, { placeholder: inputPlaceholder, value: keyword, onChange: this.onKeywordChange }, void 0)) }), void 0));
    };
    SingleTrigger.defaultProps = {
        selectedPath: [],
    };
    return SingleTrigger;
}(Component));
export { SingleTrigger };
