ant-design/components/_util/statusUtils.tsx
Tom Xu 1719748a29
chore: eslint add consistent-type-imports (#35419)
* chore: eslint add consistent-type-imports

* fix avatar

* Update Item.tsx
2022-05-07 14:31:54 +08:00

24 lines
795 B
TypeScript

import classNames from 'classnames';
import type { ValidateStatus } from '../form/FormItem';
import { tuple } from './type';
const InputStatuses = tuple('warning', 'error', '');
export type InputStatus = typeof InputStatuses[number];
export function getStatusClassNames(
prefixCls: string,
status?: ValidateStatus,
hasFeedback?: boolean,
) {
return classNames({
[`${prefixCls}-status-success`]: status === 'success',
[`${prefixCls}-status-warning`]: status === 'warning',
[`${prefixCls}-status-error`]: status === 'error',
[`${prefixCls}-status-validating`]: status === 'validating',
[`${prefixCls}-has-feedback`]: hasFeedback,
});
}
export const getMergedStatus = (contextStatus?: ValidateStatus, customStatus?: InputStatus) =>
customStatus || contextStatus;