mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
* 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>
57 lines
1.1 KiB
TypeScript
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>
|
|
);
|
|
};
|