mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-19 03:54:28 +08:00
21 lines
580 B
TypeScript
21 lines
580 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;
|