feat(client): tab icon
This commit is contained in:
parent
8f64061e65
commit
d9b2bf8af1
@ -20,26 +20,37 @@ export const TabsDesigner = () => {
|
|||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
title: t('Tab name'),
|
title: t('Tab name'),
|
||||||
|
required: true,
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
},
|
},
|
||||||
|
icon: {
|
||||||
|
title: t('Icon'),
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
'x-component': 'IconPicker',
|
||||||
|
'x-component-props': {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as ISchema
|
} as ISchema
|
||||||
}
|
}
|
||||||
initialValues={{ title: field.title }}
|
initialValues={{ title: field.title, icon: field.componentProps.icon }}
|
||||||
onSubmit={({ title }) => {
|
onSubmit={({ title, icon }) => {
|
||||||
if (title) {
|
const props = fieldSchema['x-component-props'] || {};
|
||||||
fieldSchema.title = title;
|
fieldSchema.title = title;
|
||||||
field.title = title;
|
field.title = title;
|
||||||
dn.emit('patch', {
|
props.icon = icon;
|
||||||
schema: {
|
field.componentProps.icon = icon;
|
||||||
['x-uid']: fieldSchema['x-uid'],
|
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||||
title,
|
fieldSchema['x-component-props'].icon = icon;
|
||||||
},
|
dn.emit('patch', {
|
||||||
});
|
schema: {
|
||||||
dn.refresh();
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
}
|
title,
|
||||||
|
['x-component-props']: props,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
dn.refresh();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<SchemaSettings.Divider />
|
<SchemaSettings.Divider />
|
||||||
|
@ -3,6 +3,7 @@ import { observer, RecursionField, useField, useFieldSchema } from '@formily/rea
|
|||||||
import { TabPaneProps, Tabs as AntdTabs, TabsProps } from 'antd';
|
import { TabPaneProps, Tabs as AntdTabs, TabsProps } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Icon } from '../../../icon';
|
||||||
import { useSchemaInitializer } from '../../../schema-initializer';
|
import { useSchemaInitializer } from '../../../schema-initializer';
|
||||||
import { DndContext, SortableItem } from '../../common';
|
import { DndContext, SortableItem } from '../../common';
|
||||||
import { useDesigner } from '../../hooks/useDesigner';
|
import { useDesigner } from '../../hooks/useDesigner';
|
||||||
@ -77,12 +78,12 @@ const designerCss = css`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
Tabs.TabPane = observer((props: TabPaneProps) => {
|
Tabs.TabPane = observer((props: TabPaneProps & { icon?: any }) => {
|
||||||
const Designer = useDesigner();
|
const Designer = useDesigner();
|
||||||
const field = useField();
|
const field = useField();
|
||||||
return (
|
return (
|
||||||
<SortableItem className={classNames('nb-action-link', designerCss, props.className)}>
|
<SortableItem className={classNames('nb-action-link', designerCss, props.className)}>
|
||||||
{props.tab || field.title}
|
{props.icon && <Icon style={{ marginRight: 2 }} type={props.icon} />} {props.tab || field.title}
|
||||||
<Designer />
|
<Designer />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
);
|
);
|
||||||
|
@ -13,13 +13,15 @@ export const TabPaneInitializers = () => {
|
|||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
await form.submit();
|
await form.submit();
|
||||||
const { title } = form.values;
|
const { title, icon } = form.values;
|
||||||
insertBeforeEnd({
|
insertBeforeEnd({
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title,
|
title,
|
||||||
'x-component': 'Tabs.TabPane',
|
'x-component': 'Tabs.TabPane',
|
||||||
'x-designer': 'Tabs.Designer',
|
'x-designer': 'Tabs.Designer',
|
||||||
'x-component-props': {},
|
'x-component-props': {
|
||||||
|
icon,
|
||||||
|
},
|
||||||
properties: {
|
properties: {
|
||||||
grid: {
|
grid: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
@ -67,6 +69,11 @@ export const TabPaneInitializers = () => {
|
|||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
|
icon: {
|
||||||
|
title: '{{t("Icon")}}',
|
||||||
|
'x-component': 'IconPicker',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
'x-component': 'Action.Modal.Footer',
|
'x-component': 'Action.Modal.Footer',
|
||||||
type: 'void',
|
type: 'void',
|
||||||
|
Loading…
Reference in New Issue
Block a user