Skip to content

Commit

Permalink
feat: recursion field props recursion (#3966)
Browse files Browse the repository at this point in the history
* feat: recursion field props recursion

* feat: cn doc chenged
  • Loading branch information
nicetooo committed Oct 20, 2023
1 parent 83b7473 commit 72d533f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react/docs/api/components/RecursionField.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface IRecursionFieldProps {
schema: ISchema //Field schema
name?: string //Path name
basePath?: FormPathPattern //base path
propsRecursion?: boolean //Whether to recursiveliy pass mapProperties and filterProperties
onlyRenderProperties?: boolean //Whether to only render properties
onlyRenderSelf?: boolean //Whether to only render itself without rendering properties
mapProperties?: (schema: Schema, name: string) => Schema //schema properties mapper, mainly used to rewrite the schema
Expand Down
1 change: 1 addition & 0 deletions packages/react/docs/api/components/RecursionField.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface IRecursionFieldProps {
schema: ISchema //字段schema
name?: string //路径名称
basePath?: FormPathPattern //基础路径
propsRecursion?: boolean //是否递归传递 mapProperties 和 filterProperties
onlyRenderProperties?: boolean //是否只渲染properties
onlyRenderSelf?: boolean //是否只渲染自身,不渲染properties
mapProperties?: (schema: Schema, name: string) => Schema //schema properties映射器,主要用于改写schema
Expand Down
15 changes: 14 additions & 1 deletion packages/react/src/components/RecursionField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment, useMemo } from 'react'
import { isFn, isValid } from '@formily/shared'
import { isBool, isFn, isValid } from '@formily/shared'
import { GeneralField } from '@formily/core'
import { Schema } from '@formily/json-schema'
import { SchemaContext } from '../shared'
Expand Down Expand Up @@ -49,6 +49,19 @@ export const RecursionField: ReactFC<IRecursionFieldProps> = (props) => {
return null
}
}
if (isBool(props.propsRecursion) && props.propsRecursion) {
return (
<RecursionField
propsRecursion={true}
filterProperties={props.filterProperties}
mapProperties={props.mapProperties}
schema={schema}
key={`${index}-${name}`}
name={name}
basePath={base}
/>
)
}
return (
<RecursionField
schema={schema}
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface IRecursionFieldProps {
schema: ISchema
name?: SchemaKey
basePath?: FormPathPattern
propsRecursion?: boolean
onlyRenderProperties?: boolean
onlyRenderSelf?: boolean
mapProperties?: ISchemaMapper
Expand Down

0 comments on commit 72d533f

Please sign in to comment.