mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:47:20 +00:00
fix: show clear button
This commit is contained in:
parent
6b7e26fb90
commit
797da5bdb0
@ -1,42 +1,48 @@
|
||||
import React, { useState } from 'react';
|
||||
import { connect } from '@formily/react-schema-renderer';
|
||||
import { Popover, Button } from 'antd';
|
||||
import { Popover, Button, Input } from 'antd';
|
||||
import { acceptEnum, mapStyledProps, mapTextComponent } from '../shared';
|
||||
import { icons, hasIcon, Icon as IconComponent } from '@/components/icons';
|
||||
import { CloseOutlined } from '@ant-design/icons';
|
||||
|
||||
function IconField(props: any) {
|
||||
const { value, onChange } = props;
|
||||
const [visible, setVisible] = useState(false);
|
||||
return (
|
||||
<div>
|
||||
<Popover
|
||||
placement={'bottom'}
|
||||
visible={visible}
|
||||
onVisibleChange={val => {
|
||||
setVisible(val);
|
||||
}}
|
||||
content={
|
||||
<div>
|
||||
{[...icons.keys()].map(key => (
|
||||
<span
|
||||
style={{ fontSize: 18, marginRight: 10, cursor: 'pointer' }}
|
||||
onClick={() => {
|
||||
onChange(key);
|
||||
setVisible(false);
|
||||
}}
|
||||
>
|
||||
<IconComponent type={key} />
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
}
|
||||
title="图标"
|
||||
trigger="click"
|
||||
>
|
||||
<Button>
|
||||
{hasIcon(value) ? <IconComponent type={value} /> : '选择图标'}
|
||||
</Button>
|
||||
</Popover>
|
||||
<Input.Group compact>
|
||||
<Popover
|
||||
placement={'bottom'}
|
||||
visible={visible}
|
||||
onVisibleChange={val => {
|
||||
setVisible(val);
|
||||
}}
|
||||
content={
|
||||
<div>
|
||||
{[...icons.keys()].map(key => (
|
||||
<span
|
||||
style={{ fontSize: 18, marginRight: 10, cursor: 'pointer' }}
|
||||
onClick={() => {
|
||||
onChange(key);
|
||||
setVisible(false);
|
||||
}}
|
||||
>
|
||||
<IconComponent type={key} />
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
}
|
||||
title="图标"
|
||||
trigger="click"
|
||||
>
|
||||
<Button>
|
||||
{hasIcon(value) ? <IconComponent type={value} /> : '选择图标'}
|
||||
</Button>
|
||||
</Popover>
|
||||
{value && <Button icon={<CloseOutlined/>} onClick={e => {
|
||||
onChange(null);
|
||||
}}></Button>}
|
||||
</Input.Group>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user