mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
* refactor: filter schema component * feat: improve filter schema component * fix: cannot find module
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { FormItem, Input } from '@formily/antd';
|
|
import { ISchema, observer, useForm } from '@formily/react';
|
|
import { Action, Form, SchemaComponent, SchemaComponentProvider, useActionContext } from '@nocobase/client';
|
|
import React from 'react';
|
|
|
|
const useCloseAction = () => {
|
|
const { setVisible } = useActionContext();
|
|
const form = useForm();
|
|
return {
|
|
async run() {
|
|
setVisible(false);
|
|
form.submit((values) => {
|
|
console.log(values);
|
|
});
|
|
},
|
|
};
|
|
};
|
|
|
|
const schema: ISchema = {
|
|
type: 'object',
|
|
properties: {
|
|
action1: {
|
|
'x-component': 'Action',
|
|
'x-component-props': {
|
|
type: 'primary',
|
|
popover: true,
|
|
openMode: 'popover',
|
|
},
|
|
type: 'void',
|
|
title: 'Open',
|
|
properties: {
|
|
popover: {
|
|
type: 'void',
|
|
'x-component': 'Action.Popover',
|
|
properties: {
|
|
hello: {
|
|
type: 'void',
|
|
'x-content': 'Hello',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export default observer(() => {
|
|
return (
|
|
<SchemaComponentProvider scope={{ useCloseAction }} components={{ Form, Action, Input, FormItem }}>
|
|
<SchemaComponent schema={schema} />
|
|
</SchemaComponentProvider>
|
|
);
|
|
});
|