tachybase_todo/packages/plugins/export/src/client/useShared.ts
SemmyWong d831a9b889
feat: plugin export (#479)
* feat: init export plugin

* feat: add client export

* fix: fix the word spell

* feat: export plugin done

* feat: init export plugin

* feat: add client export

* fix: fix the word spell

* feat: export plugin done

* ci: change plugin-export version

* refactor: renders add ctx params

* fix: fix select and multipleSelect export

* fix: array convert string

* refactor: move SchemaInitializerPluginProvider

* fix: build error

* fix: change umijs config

* fix: update SchemaInitializerPluginProvider

* fix: import server

* fix: fix some bug

* fix: fix some bug

* refactor: export plugin refactor

* refactor: create all export fields by default

* fix: fix export plugin bug

* fix(plugin-collection-manager): uiSchema toJSON

* fix: update yarn.lock

* fix: fix init fields bug

* refactor: enum params pass by client

* fix: fix export table header title

* refactor: refactor dataIndex

* fix: fix dataIndex maybe complex object

* fix: add checkboxGroup in export plugin

* fix: add checkbox and i18n

* feat: improve code

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-06-14 15:01:53 +08:00

93 lines
2.8 KiB
TypeScript

import { css } from '@emotion/css';
import { useCollection } from '@nocobase/client';
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',
'x-component': 'Cascader',
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);
}
`,
},
},
},
},
},
},
};
};