ant-design/components/_util/getAllowClear.tsx
lijianan 271daafa39
feat: CP support Input.TextArea allowClear、autoComplete、className、classNames、style、styles (#47589)
* feat: CP support Input allowClear

* feat: CP support Input allowClear

* fix: fix

* fix: fix

* revert

* revert

* Update Input.tsx

Signed-off-by: lijianan <574980606@qq.com>

* Update getAllowClear.tsx

Signed-off-by: lijianan <574980606@qq.com>

* Update getAllowClear.tsx

Signed-off-by: lijianan <574980606@qq.com>

* test: add test case

---------

Signed-off-by: lijianan <574980606@qq.com>
2024-02-28 09:54:48 +08:00

21 lines
582 B
TypeScript

import React from 'react';
import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
import type { BaseInputProps } from 'rc-input/lib/interface';
export type AllowClear = BaseInputProps['allowClear'];
const getAllowClear = (allowClear: AllowClear): AllowClear => {
let mergedAllowClear: AllowClear;
if (typeof allowClear === 'object' && allowClear?.clearIcon) {
mergedAllowClear = allowClear;
} else if (allowClear) {
mergedAllowClear = {
clearIcon: <CloseCircleFilled />,
};
}
return mergedAllowClear;
};
export default getAllowClear;