-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): improve formily scope standard specification (#3212)
- Loading branch information
Showing
32 changed files
with
830 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
order: 8 | ||
--- | ||
|
||
# ExpressionScope | ||
|
||
## Description | ||
|
||
Used to pass local scopes to json-schema expressions inside custom components | ||
|
||
## Signature | ||
|
||
```ts | ||
interface IExpressionScopeProps { | ||
value?: any | ||
} | ||
type ExpressionScope = React.FC<React.PropsWithChildren<IExpressionScopeProps>> | ||
``` | ||
## Example | ||
```tsx | ||
import React from 'react' | ||
import { createForm } from '@formily/core' | ||
import { | ||
FormProvider, | ||
createSchemaField, | ||
ExpressionScope, | ||
} from '@formily/react' | ||
import { Input } from 'antd' | ||
|
||
const form = createForm() | ||
|
||
const Container = (props) => { | ||
return ( | ||
<ExpressionScope value={{ $innerScope: 'this inner scope value' }}> | ||
{props.children} | ||
</ExpressionScope> | ||
) | ||
} | ||
|
||
const SchemaField = createSchemaField({ | ||
components: { | ||
Container, | ||
Input, | ||
}, | ||
}) | ||
|
||
export default () => ( | ||
<FormProvider form={form}> | ||
<SchemaField> | ||
<SchemaField.Void x-component="Container"> | ||
<SchemaField.String | ||
name="input" | ||
x-component="Input" | ||
x-value="{{$innerScope}}" | ||
/> | ||
</SchemaField.Void> | ||
</SchemaField> | ||
</FormProvider> | ||
) | ||
``` |
Oops, something went wrong.