import { jsx as _jsx } from "react/jsx-runtime";
import { Select as SelectUIKIT } from '@gravity-ui/uikit';
import { getValueByPath } from "../../utils/fields.js";
import Base from "../Base/Base.js";
import BaseInput from "../BaseInput/BaseInput.js";
const Select = ({ title, name, options, when, content, onUpdate, hasClear, defaultValue, }) => {
    const selected = getValueByPath(content, name) ?? defaultValue;
    const value = selected ? [selected] : [];
    return (_jsx(Base, { when: when, content: content, name: name, onUpdate: onUpdate, defaultValue: defaultValue, children: _jsx(BaseInput, { title: title, children: _jsx(SelectUIKIT, { name: name, options: options.map((option) => ({
                    value: option.value,
                    content: option.content || option.value,
                })), placeholder: "Not selected", onUpdate: (v) => onUpdate(name, v[0]), value: value, hasClear: hasClear }) }) }));
};
export default Select;
//# sourceMappingURL=Select.js.map
