2022-02-14 17:09:35 +08:00
|
|
|
import classNames from 'classnames';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { ValidateStatus } from '../form/FormItem';
|
2022-02-14 17:09:35 +08:00
|
|
|
|
2022-12-13 14:57:40 +08:00
|
|
|
const InputStatuses = ['warning', 'error', ''] as const;
|
|
|
|
|
2024-04-08 14:04:08 +08:00
|
|
|
export type InputStatus = (typeof InputStatuses)[number];
|
2022-02-14 17:09:35 +08:00
|
|
|
|
|
|
|
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,
|
|
|
|
});
|
|
|
|
}
|
2022-02-16 11:48:24 +08:00
|
|
|
|
|
|
|
export const getMergedStatus = (contextStatus?: ValidateStatus, customStatus?: InputStatus) =>
|
|
|
|
customStatus || contextStatus;
|