import { jsx } from "react/jsx-runtime";
import "react";
import { useField, useFieldSchema } from "@tachybase/schema";
import { useTranslation } from "react-i18next";
import { useDesignable } from "../../schema-component/index.mjs";
import { SchemaSettingsModalItem } from "../../schema-settings/index.mjs";
function CustomSchemaSettingsBlockTitleItem() {
    var _fieldSchema_xdecoratorprops;
    const field = useField();
    const fieldSchema = useFieldSchema();
    const { dn } = useDesignable();
    const { t } = useTranslation();
    return /*#__PURE__*/ jsx(SchemaSettingsModalItem, {
        title: t('Edit block title'),
        schema: {
            type: 'object',
            title: t('Edit block title'),
            properties: {
                title: {
                    title: t('Block title'),
                    type: 'string',
                    default: null == fieldSchema ? void 0 : null == (_fieldSchema_xdecoratorprops = fieldSchema['x-decorator-props']) ? void 0 : _fieldSchema_xdecoratorprops['title'],
                    'x-decorator': 'FormItem',
                    'x-component': 'Input'
                }
            }
        },
        onSubmit: (param)=>{
            let { title } = param;
            console.log('titleSchemaTest', fieldSchema, field);
            const componentProps = fieldSchema['x-decorator-props'] || {};
            componentProps.title = title;
            fieldSchema['x-decorator-props'] = componentProps;
            field.decoratorProps.title = title;
            dn.emit('patch', {
                schema: {
                    ['x-uid']: fieldSchema['x-uid'],
                    'x-decorator-props': fieldSchema['x-decorator-props']
                }
            });
            dn.refresh();
        }
    });
}
export { CustomSchemaSettingsBlockTitleItem };
