2023-12-25 10:37:26 +08:00
|
|
|
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 />,
|
|
|
|
};
|
|
|
|
}
|
2024-02-28 09:54:48 +08:00
|
|
|
|
2023-12-25 10:37:26 +08:00
|
|
|
return mergedAllowClear;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default getAllowClear;
|