docs(client): add variable docs (#1556)

This commit is contained in:
Junyi 2023-03-10 17:42:15 +08:00 committed by GitHub
parent 1c2711920a
commit 243f9e2448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 148 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/**
* title: Variable.Input
*/
import { FormItem } from '@formily/antd';
import { SchemaComponent, SchemaComponentProvider, Variable } from '@nocobase/client';
import React from 'react';
const scope = [
{ label: 'v1', value: 'v1' },
{ label: 'nested', value: 'nested', children: [{ label: 'v2', value: 'v2'}] },
];
const schema = {
type: 'object',
properties: {
input: {
type: 'string',
title: `替换模式`,
'x-decorator': 'FormItem',
'x-component': 'Variable.Input',
'x-component-props': {
scope,
},
// 'x-reactions': {
// target: 'read',
// fulfill: {
// state: {
// value: '{{$self.value}}',
// },
// },
// },
},
},
};
export default () => {
return (
<SchemaComponentProvider components={{ Variable, FormItem }}>
<SchemaComponent schema={schema} />
</SchemaComponentProvider>
);
};

View File

@ -0,0 +1,42 @@
/**
* title: Variable.Input
*/
import { FormItem } from '@formily/antd';
import { SchemaComponent, SchemaComponentProvider, Variable } from '@nocobase/client';
import React from 'react';
const scope = [
{ label: 'v1', value: 'v1' },
{ label: 'nested', value: 'nested', children: [{ label: 'v2', value: 'v2'}] },
];
const schema = {
type: 'object',
properties: {
input: {
type: 'string',
title: `表达式模式`,
'x-decorator': 'FormItem',
'x-component': 'Variable.TextArea',
'x-component-props': {
scope,
},
// 'x-reactions': {
// target: 'read',
// fulfill: {
// state: {
// value: '{{$self.value}}',
// },
// },
// },
},
},
};
export default () => {
return (
<SchemaComponentProvider components={{ Variable, FormItem }}>
<SchemaComponent schema={schema} />
</SchemaComponentProvider>
);
};

View File

@ -0,0 +1,42 @@
/**
* title: Variable.Input
*/
import { FormItem } from '@formily/antd';
import { SchemaComponent, SchemaComponentProvider, Variable } from '@nocobase/client';
import React from 'react';
const scope = [
{ label: 'v1', value: 'v1' },
{ label: 'nested', value: 'nested', children: [{ label: 'v2', value: 'v2'}] },
];
const schema = {
type: 'object',
properties: {
input: {
type: 'string',
title: `JSON 模式`,
'x-decorator': 'FormItem',
'x-component': 'Variable.JSON',
'x-component-props': {
scope,
},
// 'x-reactions': {
// target: 'read',
// fulfill: {
// state: {
// value: '{{$self.value}}',
// },
// },
// },
},
},
};
export default () => {
return (
<SchemaComponentProvider components={{ Variable, FormItem }}>
<SchemaComponent schema={schema} />
</SchemaComponentProvider>
);
};

View File

@ -0,0 +1,22 @@
---
nav:
path: /client
group:
path: /schema-components
---
# Variable
## Examples
### `Variable.Input`
<code src="./demos/demo1.tsx" />
### `Variable.TextArea`
<code src="./demos/demo2.tsx" />
### `Variable.JSON`
<code src="./demos/demo3.tsx" />