Skip to content

Commit

Permalink
feat(layout): add ts type desc of MegaLayout and fix array-inc doc (#905
Browse files Browse the repository at this point in the history
)

* feat: add style entry and docs

* feat: add mega props and docs
  • Loading branch information
JohnIsOnTheRoad committed Jun 19, 2020
1 parent 944891f commit f37a093
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion docs/zh-cn/schema-develop/complext-self-inc-component.md
Expand Up @@ -132,11 +132,16 @@ const App = () => {
renderMoveUp: () => null,
renderAddition: () => '+add',
renderRemove: idx => {
const mutators = actions.createMutators('userList')
return (
<FormSpy
selector={[['onFieldValueChange', `userList.${idx}.username`]]}
>
{({ state }) => (state.value === 'morally' ? null : 'remove')}
{({ state }) => {
return (state.value === 'morally' ? null : <Button onClick={() => {
mutators.remove(idx)
}}>remove</Button> )
}}
</FormSpy>
)
}
Expand Down
Empty file.
8 changes: 4 additions & 4 deletions packages/antd/src/components/FormMegaLayout/index.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import classnames from 'classnames'
import { Form } from 'antd'
import { Layout, LayoutItem } from '@formily/react'
import { Layout, LayoutItem, ILayoutProps } from '@formily/react'
import { createVirtualBox } from '@formily/react-schema-renderer'
import styled from 'styled-components'
import { useDeepFormItem } from '../../context'
Expand Down Expand Up @@ -69,7 +69,7 @@ const StyledLayoutNestWrapper = styled(props => {
return <div style={style} className={classnames('mega-layout-nest-container', className)}>{children}</div>
})`${props => computeStyle(props, true)}`

const MegaLayout = (props => {
const MegaLayout = (props: ILayoutProps) => {
const { children, addonBefore, addonAfter, description, ...others } = props
const layoutProps = props.layoutProps || {}
const { size } = useDeepFormItem()
Expand Down Expand Up @@ -147,7 +147,7 @@ const MegaLayout = (props => {
return ele
}}
/>
});
};

const MegaLayoutItem = (props) => {
const { children, schemaChildren, itemProps, ...others } = props
Expand Down Expand Up @@ -210,7 +210,7 @@ const MegaLayoutItem = (props) => {
})
}

const FormMegaLayout = createVirtualBox('mega-layout', MegaLayout)
const FormMegaLayout = createVirtualBox<ILayoutProps>('mega-layout', MegaLayout)

export {
MegaLayout,
Expand Down
Empty file.
8 changes: 4 additions & 4 deletions packages/next/src/components/FormMegaLayout/index.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import classnames from 'classnames'
import { Form } from '@alifd/next'
import { Layout, LayoutItem } from '@formily/react'
import { Layout, LayoutItem, ILayoutProps } from '@formily/react'
import { createVirtualBox } from '@formily/react-schema-renderer'
import styled from 'styled-components'
import { useDeepFormItem } from '../../context'
Expand Down Expand Up @@ -69,7 +69,7 @@ const StyledLayoutNestWrapper = styled(props => {
return <div style={style} className={classnames('mega-layout-nest-container', className)}>{children}</div>
})`${props => computeStyle(props)}`

const MegaLayout = (props => {
const MegaLayout = (props: ILayoutProps) => {
const { children, addonBefore, addonAfter, description, ...others } = props
const layoutProps = props.layoutProps || {}
const { size } = useDeepFormItem()
Expand Down Expand Up @@ -147,7 +147,7 @@ const MegaLayout = (props => {
return ele
}}
/>
});
};

const MegaLayoutItem = (props) => {
const { children, schemaChildren, itemProps, ...others } = props
Expand Down Expand Up @@ -210,7 +210,7 @@ const MegaLayoutItem = (props) => {
})
}

const FormMegaLayout = createVirtualBox('mega-layout', MegaLayout)
const FormMegaLayout = createVirtualBox<ILayoutProps>('mega-layout', MegaLayout)

export {
MegaLayout,
Expand Down

0 comments on commit f37a093

Please sign in to comment.