2022-06-14 15:01:53 +08:00
|
|
|
import { css } from '@emotion/css';
|
2023-03-29 00:12:39 +08:00
|
|
|
import { Cascader, useCollection } from '@nocobase/client';
|
2022-06-14 15:01:53 +08:00
|
|
|
import { useFields } from './useFields';
|
|
|
|
|
|
|
|
export const useShared = () => {
|
|
|
|
const { name } = useCollection();
|
|
|
|
const fields = useFields(name);
|
|
|
|
return {
|
|
|
|
schema: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'Grid',
|
|
|
|
properties: {
|
|
|
|
exportSettings: {
|
|
|
|
type: 'array',
|
|
|
|
'x-component': 'ArrayItems',
|
|
|
|
'x-decorator': 'FormItem',
|
|
|
|
items: {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
space: {
|
|
|
|
type: 'void',
|
|
|
|
'x-component': 'Space',
|
|
|
|
'x-component-props': {
|
|
|
|
className: css`
|
|
|
|
width: 100%;
|
|
|
|
& .ant-space-item:nth-child(2),
|
|
|
|
& .ant-space-item:nth-child(3) {
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
sort: {
|
|
|
|
type: 'void',
|
|
|
|
'x-decorator': 'FormItem',
|
|
|
|
'x-component': 'ArrayItems.SortHandle',
|
|
|
|
},
|
|
|
|
dataIndex: {
|
|
|
|
type: 'array',
|
|
|
|
'x-decorator': 'FormItem',
|
2023-03-29 00:12:39 +08:00
|
|
|
'x-component': Cascader,
|
2022-06-14 15:01:53 +08:00
|
|
|
required: true,
|
|
|
|
enum: fields,
|
|
|
|
'x-component-props': {
|
|
|
|
fieldNames: {
|
|
|
|
label: 'title',
|
|
|
|
value: 'name',
|
|
|
|
children: 'children',
|
|
|
|
},
|
|
|
|
// labelInValue: true,
|
|
|
|
changeOnSelect: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
type: 'string',
|
|
|
|
'x-decorator': 'FormItem',
|
|
|
|
'x-component': 'Input',
|
|
|
|
'x-component-props': {
|
|
|
|
placeholder: '{{ t("Custom column title") }}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
remove: {
|
|
|
|
type: 'void',
|
|
|
|
'x-decorator': 'FormItem',
|
|
|
|
'x-component': 'ArrayItems.Remove',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
add: {
|
|
|
|
type: 'void',
|
|
|
|
title: '{{ t("Add exportable field") }}',
|
|
|
|
'x-component': 'ArrayItems.Addition',
|
|
|
|
'x-component-props': {
|
|
|
|
className: css`
|
|
|
|
border-color: rgb(241, 139, 98);
|
|
|
|
color: rgb(241, 139, 98);
|
|
|
|
&.ant-btn-dashed:hover {
|
|
|
|
border-color: rgb(241, 139, 98);
|
|
|
|
color: rgb(241, 139, 98);
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|