import { FormOutlined, TableOutlined } from '@ant-design/icons'; import { Field } from '@formily/core'; import { observer, useField } from '@formily/react'; import { SchemaComponent, SchemaComponentProvider, SchemaInitializer } from '@nocobase/client'; import React from 'react'; const Hello = observer((props) => { const field = useField(); return (
{field.title}
); }); const InitializerButton = observer((props: any) => { return ( schema} insertPosition={'beforeBegin'} items={[ { title: 'Data blocks', children: [ { title: 'Table', component: TableBlockInitializerItem, }, { title: 'Form', component: FormBlockInitializerItem, }, ], }, ]} > Create block ); }); const TableBlockInitializerItem = (props) => { const { insert } = props; return ( } onClick={(info) => { console.log({ info }); insert({ type: 'void', title: info.key, 'x-component': 'Hello', }); }} items={[ { type: 'itemGroup', title: 'select a data source', children: [ { key: 'users', title: 'Users', }, { key: 'posts', title: 'Posts', }, ], }, ]} > Table ); }; const FormBlockInitializerItem = (props) => { const { insert } = props; return ( } onClick={(info) => { insert({ type: 'void', title: 'form', 'x-component': 'Hello', }); }} > Form ); }; export default function App() { return ( ); }