/**
 * amis-ui v6.12.0-beta.0
 * Copyright 2018-2025 fex
 */

import { __extends } from 'tslib';
import React__default from 'react';
import { findDOMNode } from 'react-dom';
import { themeable, localeable } from 'amis-core';
import HeadCellDropDown from './HeadCellDropDown.js';
import { Icon } from '../icons.js';

/**
 * @file table/HeadCellSelect
 * @author fex
 */
var HeadCellSelect = /** @class */ (function (_super) {
    __extends(HeadCellSelect, _super);
    function HeadCellSelect(props) {
        var _this = _super.call(this, props) || this;
        _this.state = {
            key: ''
        };
        return _this;
    }
    HeadCellSelect.prototype.render = function () {
        var _this = this;
        var _a = this.props, selections = _a.selections, allKeys = _a.keys, popOverContainer = _a.popOverContainer, cx = _a.classnames, ns = _a.classPrefix;
        return (React__default.createElement(HeadCellDropDown, { className: "".concat(ns, "TableCell-selectionBtn"), layerClassName: "".concat(ns, "TableCell-selectionPopOver"), filterIcon: React__default.createElement(Icon, { icon: "left-arrow", className: "icon" }), active: false, popOverContainer: popOverContainer
                ? popOverContainer
                : function () { return findDOMNode(_this); }, filterDropdown: function (_a) {
                var setSelectedKeys = _a.setSelectedKeys; _a.selectedKeys; var confirm = _a.confirm; _a.clearFilters;
                return (React__default.createElement("ul", { className: cx('DropDown-menu') }, selections.map(function (item, index) { return (React__default.createElement("li", { key: index, onClick: function () {
                        item.onSelect && item.onSelect(allKeys);
                        _this.handleClick(confirm, setSelectedKeys, item.key);
                    } }, item.text)); })));
            }, setSelectedKeys: function (keys) {
                return _this.setState({ key: keys });
            }, selectedKeys: this.state.key }));
    };
    HeadCellSelect.prototype.handleClick = function (confirm, setSelectedKeys, selectedKeys) {
        setSelectedKeys && setSelectedKeys(selectedKeys);
        confirm();
    };
    HeadCellSelect.defaultProps = {
        selections: []
    };
    return HeadCellSelect;
}(React__default.PureComponent));
var HeadCellSelect$1 = themeable(localeable(HeadCellSelect));

export { HeadCellSelect, HeadCellSelect$1 as default };
