"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormBuilderBody = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const FormContext_1 = require("../../hooks/FormContext.js");
const cn_1 = require("../../utils/cn.js");
const FieldCard_1 = require("../FieldCard/FieldCard.js");
const b = (0, cn_1.formBuilderCn)('form-builder-body');
const FormBuilderBody = ({ className }) => {
    const { formFields, addField } = (0, FormContext_1.useFormContext)();
    const inputTypeMenuItems = [
        {
            type: 'text',
            action: () => addField('text'),
            text: 'Text Input',
        },
        {
            type: 'number',
            action: () => addField('number'),
            text: 'Number Input',
        },
        {
            type: 'boolean',
            action: () => addField('boolean'),
            text: 'Boolean Input',
        },
        {
            type: 'textarea',
            action: () => addField('textarea'),
            text: 'Textarea Input',
        },
        {
            type: 'select',
            action: () => addField('select'),
            text: 'Select Input',
        },
        {
            type: 'object',
            action: () => addField('object'),
            text: 'Object Input',
        },
        {
            type: 'array',
            action: () => addField('array'),
            text: 'Array Input',
        },
        {
            type: 'oneOf',
            action: () => addField('oneOf'),
            text: 'OneOf Input',
        },
        {
            type: 'anyOf',
            action: () => addField('anyOf'),
            text: 'AnyOf Input',
        },
    ];
    return ((0, jsx_runtime_1.jsxs)("div", { className: b(null, className), children: [(0, jsx_runtime_1.jsx)("div", { className: b('fields-list'), children: formFields.map((field) => ((0, jsx_runtime_1.jsx)(FieldCard_1.FieldCard, { field: field, inputTypeMenuItems: inputTypeMenuItems }, field.id))) }), (0, jsx_runtime_1.jsx)("div", { className: b('field'), children: (0, jsx_runtime_1.jsx)(uikit_1.DropdownMenu, { items: inputTypeMenuItems, renderSwitcher: (props) => ((0, jsx_runtime_1.jsx)(uikit_1.Button, { ...props, view: "action", size: "l", children: "+ Add Field" })) }) })] }));
};
exports.FormBuilderBody = FormBuilderBody;
//# sourceMappingURL=FormBuilderBody.js.map
