mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
1cb644d476
* fix: fix control value not show in dom * chore: update title * add test case * change test title * fix: cleared color should change after controlled value changed * chore: code clean * test: change test * comment * fix: should respect empty string * test: add test case * chore: update demo --------- Co-authored-by: tanghui <yoyo837@hotmail.com> Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: lijianan <574980606@qq.com>
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;
|