diff --git a/packages/next/docs/components/FormDialog.md b/packages/next/docs/components/FormDialog.md index 610964bb85e..9510fb9a0f0 100644 --- a/packages/next/docs/components/FormDialog.md +++ b/packages/next/docs/components/FormDialog.md @@ -8,7 +8,7 @@ import React from 'react' import { FormDialog, FormItem, Input, FormLayout } from '@formily/next' import { createSchemaField } from '@formily/react' -import { Button, ConfigProvider } from '@alifd/next' +import { Button } from '@alifd/next' const SchemaField = createSchemaField({ components: { @@ -19,72 +19,57 @@ const SchemaField = createSchemaField({ export default () => { return ( - { + FormDialog('弹窗表单', () => { + return ( + + + + + + + + + 扩展文案 + + + ) + }) + .open({ + initialValues: { + aaa: '123', + }, + }) + .then(console.log) }} > - - + 点我打开表单 + ) } ``` @@ -229,6 +214,84 @@ export default () => { } ``` +## 使用 Fusion Context + +```tsx +import React from 'react' +import { FormDialog, FormItem, Input, FormLayout } from '@formily/next' +import { Field } from '@formily/react' +import { Button, ConfigProvider } from '@alifd/next' + +export default () => { + return ( + + + + ) +} +``` + ## API ### FormDialog diff --git a/packages/next/docs/components/FormDrawer.md b/packages/next/docs/components/FormDrawer.md index de885e66b99..223cf9905eb 100644 --- a/packages/next/docs/components/FormDrawer.md +++ b/packages/next/docs/components/FormDrawer.md @@ -247,6 +247,86 @@ export default () => { } ``` +## 使用 Fusion Context + +```tsx +import React from 'react' +import { + FormDrawer, + FormItem, + Input, + Submit, + Reset, + FormButtonGroup, + FormLayout, +} from '@formily/next' +import { Field } from '@formily/react' +import { Button, ConfigProvider } from '@alifd/next' + +export default () => { + return ( + + + + ) +} +``` + ## API ### FormDrawer diff --git a/packages/next/src/form-drawer/index.tsx b/packages/next/src/form-drawer/index.tsx index b8807f4a2ea..1d69171e9af 100644 --- a/packages/next/src/form-drawer/index.tsx +++ b/packages/next/src/form-drawer/index.tsx @@ -3,7 +3,7 @@ import ReactDOM, { createPortal } from 'react-dom' import { createForm } from '@formily/core' import { FormProvider } from '@formily/react' import { isNum, isStr, isBool, isFn } from '@formily/shared' -import { Drawer } from '@alifd/next' +import { ConfigProvider, Drawer } from '@alifd/next' import { DrawerProps } from '@alifd/next/lib/drawer' import { usePrefixCls } from '../__builtins__' @@ -54,6 +54,13 @@ export function FormDrawer(title: any, content: any): IFormDrawer { form: null, promise: null, } + + let contextProps = {} + try { + // @ts-ignore + contextProps = ConfigProvider.getContext() + } catch (e) {} + const props = getDrawerProps(title) const drawer: DrawerProps = { width: '40%', @@ -79,15 +86,17 @@ export function FormDrawer(title: any, content: any): IFormDrawer { } const render = (visible = true, resolve?: () => any, reject?: () => any) => { ReactDOM.render( - - - {React.createElement(component, { - content, - resolve, - reject, - })} - - , + + + + {React.createElement(component, { + content, + resolve, + reject, + })} + + + , env.root ) }