import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { SegmentedRadioGroup, Select } from '@gravity-ui/uikit';
import { formGeneratorCn } from "../../../utils/cn.js";
import FieldBase from "../../FieldBase/FieldBase.js";
import './Select.css';
const b = formGeneratorCn('editor-select-field');
const SelectDynamicField = ({ input, value, onUpdate, className }) => {
    const inputView = input.view || 'radiobutton';
    const isMultiple = input.mode === 'multiple';
    const currentValue = Array.isArray(value) ? value : [value];
    return (_jsxs(FieldBase, { title: input.title, className: b(null, className), onRefresh: onUpdate, children: [(inputView === 'select' || isMultiple) && (_jsx(Select, { placeholder: 'Value', value: value ? currentValue : [], onUpdate: (selectValues) => isMultiple ? onUpdate(selectValues) : onUpdate(selectValues[0]), options: input.enum, className: b('select'), multiple: isMultiple })), inputView === 'radiobutton' && !isMultiple && (_jsx(SegmentedRadioGroup, { options: input.enum, value: Array.isArray(value) ? value[0] : value, onUpdate: onUpdate }))] }));
};
export default SelectDynamicField;
//# sourceMappingURL=Select.js.map
