SemmyWong c5220ce09b
feat: add select component into schema component (#168)
* feat: select migrate

* feat: select migrate

* feat: add Select component into schema components

* refactor

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-01-26 10:43:29 +08:00

61 lines
1.3 KiB
TypeScript

/**
* title: Select
*/
import { FormItem } from '@formily/antd';
import { SchemaComponent, SchemaComponentProvider, Select } from '@nocobase/client';
import React from 'react';
const dataSource = [
{
label: '福建',
value: 'FuJian',
children: [
{ label: '{{t("福州")}}', value: 'FZ' },
{ label: '莆田', value: 'PT' },
],
},
{ label: '江苏', value: 'XZ' },
{ label: '浙江', value: 'ZX' },
];
const schema = {
type: 'object',
properties: {
editable: {
type: 'string',
title: `Editable`,
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {},
enum: dataSource,
'x-reactions': {
target: 'read',
fulfill: {
state: {
value: '{{$self.value}}',
},
},
},
},
read: {
type: 'string',
title: `Read pretty`,
'x-read-pretty': true,
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {},
enum: dataSource,
},
},
};
const t = (text?: any) => text;
export default () => {
return (
<SchemaComponentProvider scope={{ t }} components={{ Select, FormItem }}>
<SchemaComponent schema={schema} />
</SchemaComponentProvider>
);
};