ant-design/components/input/utils.ts
MadCcc 37e042358d
feat: Input support status (#33995)
* feat: remove form status style && input support status

* test: update snapshot

* feat: update status prop in config provider

* fix: form item validateStatus support

* chore: code clean

* feat: status classname change

* test: update snapshot

* refactor: move formItemStatusContext to form folder

* refactor: merge utils

* refactor: rename statusUtils

* chore: code clean

* test: fix coverage

* chore: remove status prop of Form.Item

* chore: code clean

* docs: update demo

* test: fix lint

* feat: status only success and warning

* test: fix lint

* docs: update deamo
2022-02-14 17:09:35 +08:00

34 lines
1.0 KiB
TypeScript

import classNames from 'classnames';
import { ValidateStatus } from '../form/FormItem';
import type { DirectionType } from '../config-provider';
import type { SizeType } from '../config-provider/SizeContext';
import type { ClearableInputProps } from './ClearableLabeledInput';
import type { InputProps } from './Input';
import { getStatusClassNames } from '../_util/statusUtils';
export function getInputClassName(
prefixCls: string,
bordered: boolean,
size?: SizeType,
disabled?: boolean,
direction?: DirectionType,
status?: ValidateStatus,
hasFeedback?: boolean,
) {
return classNames(
prefixCls,
{
[`${prefixCls}-sm`]: size === 'small',
[`${prefixCls}-lg`]: size === 'large',
[`${prefixCls}-disabled`]: disabled,
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-borderless`]: !bordered,
},
getStatusClassNames(prefixCls, status, hasFeedback),
);
}
export function hasPrefixSuffix(props: InputProps | ClearableInputProps) {
return !!(props.prefix || props.suffix || props.allowClear);
}