a87a089acf
* v0.6 * update... * feat: improve code * improve code * action & form * update... * improve code * improve code * improve code * designable * update * update... * api client * RecordProvider * collection manager * update... * update api client * update use request * update * update doc * test cases for compose * docs: improve documentation
84 lines
1.9 KiB
TypeScript
84 lines
1.9 KiB
TypeScript
/**
|
|
* title: Insert Adjacent
|
|
*/
|
|
import React from 'react';
|
|
import { SchemaComponentProvider, SchemaComponent, useDesignable } from '@nocobase/client';
|
|
import { observer, Schema, useFieldSchema } from '@formily/react';
|
|
import { Button, Space } from 'antd';
|
|
import { uid } from '@formily/shared';
|
|
|
|
const Hello = observer((props) => {
|
|
const { insertAdjacent } = useDesignable();
|
|
const fieldSchema = useFieldSchema();
|
|
return (
|
|
<div>
|
|
<h1>{fieldSchema.name}</h1>
|
|
<Space>
|
|
<Button
|
|
onClick={() => {
|
|
insertAdjacent('beforeBegin', {
|
|
'x-component': 'Hello',
|
|
});
|
|
}}
|
|
>
|
|
before begin
|
|
</Button>
|
|
<Button
|
|
onClick={() => {
|
|
insertAdjacent('afterBegin', {
|
|
'x-component': 'Hello',
|
|
});
|
|
}}
|
|
>
|
|
after begin
|
|
</Button>
|
|
<Button
|
|
onClick={() => {
|
|
insertAdjacent('beforeEnd', {
|
|
'x-component': 'Hello',
|
|
});
|
|
}}
|
|
>
|
|
before end
|
|
</Button>
|
|
<Button
|
|
onClick={() => {
|
|
insertAdjacent('afterEnd', {
|
|
'x-component': 'Hello',
|
|
});
|
|
}}
|
|
>
|
|
after end
|
|
</Button>
|
|
</Space>
|
|
<div style={{ margin: 50 }}>{props.children}</div>
|
|
</div>
|
|
);
|
|
});
|
|
|
|
const Page = observer((props) => {
|
|
return <div>{props.children}</div>;
|
|
});
|
|
|
|
export default function App() {
|
|
return (
|
|
<SchemaComponentProvider components={{ Page, Hello }}>
|
|
<SchemaComponent
|
|
schema={{
|
|
type: 'void',
|
|
name: 'page',
|
|
'x-uid': uid(),
|
|
'x-component': 'Page',
|
|
properties: {
|
|
hello1: {
|
|
type: 'void',
|
|
'x-uid': uid(),
|
|
'x-component': 'Hello',
|
|
},
|
|
},
|
|
}}
|
|
/>
|
|
</SchemaComponentProvider>
|
|
);
|
|
}
|