SemmyWong e40565e90a
feat: add radio into schema component (#154)
* feat: add radio to schema component

* docs: add Radio  demos into schema component

* rafactor: change import path

* docs: change demo language

* fix: add title and description to demos

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-01-17 15:39:52 +08:00

57 lines
1.1 KiB
TypeScript

/**
* title: Radio Group with color
*/
import { FormItem } from '@formily/antd';
import { Radio, SchemaComponent, SchemaComponentProvider } from '@nocobase/client';
import React from 'react';
const options = [
{
label: '男',
value: 1,
color: 'blue',
},
{
label: '女',
value: 2,
color: 'red',
},
];
const schema = {
type: 'object',
properties: {
input: {
type: 'number',
title: `编辑模式`,
enum: options,
'x-decorator': 'FormItem',
'x-component': 'Radio.Group',
'x-reactions': {
target: 'read',
fulfill: {
state: {
value: '{{$self.value}}',
},
},
},
},
read: {
type: 'number',
title: `阅读模式`,
enum: options,
'x-read-pretty': true,
'x-decorator': 'FormItem',
'x-component': 'Radio.Group',
},
},
};
export default () => {
return (
<SchemaComponentProvider components={{ Radio, FormItem }}>
<SchemaComponent schema={schema} />
</SchemaComponentProvider>
);
};