fix(client): missing layout size and disabled props
This commit is contained in:
parent
6990347013
commit
faf0977a0b
@ -1,4 +1,5 @@
|
|||||||
import { CloseOutlined, LoadingOutlined } from '@ant-design/icons';
|
import { CloseOutlined, LoadingOutlined } from '@ant-design/icons';
|
||||||
|
import { useFormLayout } from '@formily/antd';
|
||||||
import { connect, mapProps, mapReadPretty } from '@formily/react';
|
import { connect, mapProps, mapReadPretty } from '@formily/react';
|
||||||
import { isValid } from '@formily/shared';
|
import { isValid } from '@formily/shared';
|
||||||
import { Button, Input, Popover } from 'antd';
|
import { Button, Input, Popover } from 'antd';
|
||||||
@ -7,7 +8,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { hasIcon, Icon, icons } from '../../../icon';
|
import { hasIcon, Icon, icons } from '../../../icon';
|
||||||
|
|
||||||
function IconField(props: any) {
|
function IconField(props: any) {
|
||||||
const { value, onChange } = props;
|
const layout = useFormLayout();
|
||||||
|
const { value, onChange, disabled } = props;
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
@ -17,6 +19,9 @@ function IconField(props: any) {
|
|||||||
placement={'bottom'}
|
placement={'bottom'}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
onVisibleChange={(val) => {
|
onVisibleChange={(val) => {
|
||||||
|
if (disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setVisible(val);
|
setVisible(val);
|
||||||
}}
|
}}
|
||||||
content={
|
content={
|
||||||
@ -37,10 +42,13 @@ function IconField(props: any) {
|
|||||||
title={t('Icon')}
|
title={t('Icon')}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
>
|
>
|
||||||
<Button>{hasIcon(value) ? <Icon type={value} /> : t('Select icon')}</Button>
|
<Button size={layout.size as any} disabled={disabled}>
|
||||||
|
{hasIcon(value) ? <Icon type={value} /> : t('Select icon')}
|
||||||
|
</Button>
|
||||||
</Popover>
|
</Popover>
|
||||||
{value && (
|
{value && !disabled && (
|
||||||
<Button
|
<Button
|
||||||
|
size={layout.size as any}
|
||||||
icon={<CloseOutlined />}
|
icon={<CloseOutlined />}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user