mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 13:37:52 +08:00
28aaeafbbc
* feat(mentions): supports 'allowClear' option * feat(mentions): add allowClear testcase * feat(mentions): update package and styles * feat(mentions): update lint and styles * fix: fixed lint error * test: add case for custom clearIcon * feat: add useAllowClear hook * feat: rename useAllowClear to getAllowClear * feat: rename useAllowClear to getAllowClear * feat(mentions): add demo for allowClear * feat(mentions): update demo desc * feat(mentions): update demo desc * feat(mentions): style align middle * feat: add multi line mentions demo and update icon position * feat: fixing visual regression report --------- Co-authored-by: afc163 <afc163@gmail.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;
|