"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewColumnSelector = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_1 = require("react");
const ValueSelector_1 = require("../ValueSelector");
const NewColumnSelector = ({ allowReorder = true, ...props }) => {
    const { columnFilterText, availableColumns, selected, onChange, singleSelect } = props;
    const filterFn = (0, react_1.useMemo)(() => {
        return columnFilterText
            ? (c) => c.friendlyName.toLowerCase().indexOf(columnFilterText.toLowerCase()) != -1
            : null;
    }, [columnFilterText]);
    return (React.createElement(ValueSelector_1.ValueSelector, { value: selected, options: availableColumns, filter: filterFn, singleSelect: singleSelect, allowReorder: false, onChange: (colIds) => {
            if (singleSelect) {
                onChange(colIds.length ? [colIds.pop()] : []);
            }
            else {
                onChange(colIds);
            }
        }, toIdentifier: (c) => c.columnId, toLabel: (c) => c.friendlyName }));
};
exports.NewColumnSelector = NewColumnSelector;
