"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldSelector = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Select_1 = require("../../../components/Select");
const AdaptableContext_1 = require("../../AdaptableContext");
const FieldSelector = (props) => {
    const { api } = (0, AdaptableContext_1.useAdaptable)();
    const fields = React.useMemo(() => {
        return api.expressionApi.internalApi.getFieldsOfType(props.type);
    }, []);
    const options = fields.map((field) => ({
        label: field.label ?? field.name,
        value: field.name,
    }));
    return (React.createElement(React.Fragment, null,
        React.createElement(Select_1.Select, { "data-name": "column-selector", disabled: props.disabled, isMulti: false, menuPosition: props.menuPosition, value: props.value || undefined, placeholder: props.placeholder ?? 'Select Field', onChange: (fieldValue) => {
                props.onChange(fieldValue);
            }, options: options })));
};
exports.FieldSelector = FieldSelector;
