/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');
var ReactDOM = require('react-dom');
var amisCore = require('amis-core');
var HeadCellDropDown = require('./HeadCellDropDown.js');
var icons = require('../icons.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
var HeadCellSelect = /** @class */ (function (_super) {
    tslib.__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 (_J$X_(HeadCellDropDown["default"], { className: "".concat(ns, "TableCell-selectionBtn"), layerClassName: "".concat(ns, "TableCell-selectionPopOver"), filterIcon: _J$X_(icons.Icon, { icon: "left-arrow", className: "icon" }), active: false, popOverContainer: popOverContainer
                ? popOverContainer
                : function () { return ReactDOM.findDOMNode(_this); }, filterDropdown: function (_a) {
                var setSelectedKeys = _a.setSelectedKeys; _a.selectedKeys; var confirm = _a.confirm; _a.clearFilters;
                return (_J$X_("ul", { className: cx('DropDown-menu') }, selections.map(function (item, index) { return (_J$X_("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["default"].PureComponent));
var HeadCellSelect$1 = amisCore.themeable(amisCore.localeable(HeadCellSelect));

exports.HeadCellSelect = HeadCellSelect;
exports["default"] = HeadCellSelect$1;
