import { useForm } from '@formily/react'; import React from 'react'; import { SchemaComponent, useActionContext, useDesignable } from '../..'; export const TabPaneInitializers = () => { const { designable, insertBeforeEnd } = useDesignable(); if (!designable) { return null; } const useSubmitAction = () => { const form = useForm(); const ctx = useActionContext(); return { async run() { await form.submit(); const { title } = form.values; insertBeforeEnd({ type: 'void', title, 'x-component': 'Tabs.TabPane', 'x-designer': 'Tabs.Designer', 'x-component-props': {}, properties: { grid: { type: 'void', 'x-component': 'Grid', 'x-initializer': 'RecordBlockInitializers', properties: {}, }, }, }); await form.reset(); ctx.setVisible(false); }, }; }; return ( { const ctx = useActionContext(); return { async run() { ctx.setVisible(false); }, }; }, }, }, submit: { title: '{{t("Submit")}}', 'x-component': 'Action', 'x-component-props': { type: 'primary', useAction: useSubmitAction, }, }, }, }, }, }, }, }, }, }} /> ); };