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 InitializerDemo = observer((props: any) => { return ( schema} insertPosition={'beforeBegin'} items={[ { title: 'Data blocks', children: [ { title: 'Table', component: 'TableBlockInitializer', }, { title: 'Form', component: 'FormBlockInitializer', }, ], }, ]} > Configure actions ); }); const TableBlockInitializer = (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 FormBlockInitializer = (props) => { const { insert } = props; return ( } onClick={(info) => { insert({ type: 'void', title: 'form', 'x-component': 'Hello', }); }} > Form ); }; export default function App() { return ( ); }