mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
* feat: select migrate * feat: select migrate * feat: add Select component into schema components * refactor Co-authored-by: chenos <chenlinxh@gmail.com>
61 lines
1.3 KiB
TypeScript
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>
|
|
);
|
|
};
|