import { useField, useFieldSchema } from "@tachybase/schema";
import { useTranslation } from "react-i18next";
import { SchemaSettings } from "../../../../application/schema-settings/SchemaSettings.mjs";
import { useDesignable } from "../../../../schema-component/index.mjs";
import { useColumnSchema } from "../../../../schema-component/antd/table-v2/Table.Column.Decorator.mjs";
const radioComponentFieldSettings = new SchemaSettings({
    name: 'fieldSettings:component:Radio group',
    items: [
        {
            name: 'fieldComponent',
            type: 'select',
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { t } = useTranslation();
                const field = useField();
                const { fieldSchema: tableColumnSchema } = useColumnSchema();
                const schema = useFieldSchema();
                const fieldSchema = tableColumnSchema || schema;
                const fieldModeOptions = [
                    {
                        label: t('Checkbox'),
                        value: 'Checkbox'
                    },
                    {
                        label: t('Radio group'),
                        value: 'Radio group'
                    }
                ];
                const { dn } = useDesignable();
                return {
                    title: t('Field component'),
                    options: fieldModeOptions,
                    value: (null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops.mode) || 'Radio group',
                    onChange (mode) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['mode'] = mode;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps = field.componentProps || {};
                        field.componentProps.mode = mode;
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        }
    ]
});
export { radioComponentFieldSettings };
