mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
271daafa39
* 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>
21 lines
582 B
TypeScript
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;
|