UNPKG

1.89 kBTypeScriptView Raw
1import * as React from 'react';
2import type { FieldProps } from 'rc-field-form/lib/Field';
3import type { FormInstance } from '../Form';
4import type { FormItemInputProps } from '../FormItemInput';
5import type { FormItemLabelProps, LabelTooltipType } from '../FormItemLabel';
6import useFormItemStatus from '../hooks/useFormItemStatus';
7declare const ValidateStatuses: readonly ["success", "warning", "error", "validating", ""];
8export type ValidateStatus = (typeof ValidateStatuses)[number];
9type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
10type RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>;
11type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
12export type FeedbackIcons = (itemStatus: {
13 status: ValidateStatus;
14 errors?: React.ReactNode[];
15 warnings?: React.ReactNode[];
16}) => {
17 [key in ValidateStatus]?: React.ReactNode;
18};
19export interface FormItemProps<Values = any> extends Omit<FormItemLabelProps, 'requiredMark'>, FormItemInputProps, RcFieldProps<Values> {
20 prefixCls?: string;
21 noStyle?: boolean;
22 style?: React.CSSProperties;
23 className?: string;
24 rootClassName?: string;
25 children?: ChildrenType<Values>;
26 id?: string;
27 hasFeedback?: boolean | {
28 icons: FeedbackIcons;
29 };
30 validateStatus?: ValidateStatus;
31 required?: boolean;
32 hidden?: boolean;
33 initialValue?: any;
34 messageVariables?: Record<string, string>;
35 tooltip?: LabelTooltipType;
36 /** @deprecated No need anymore */
37 fieldKey?: React.Key | React.Key[];
38}
39declare function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.ReactElement;
40type InternalFormItemType = typeof InternalFormItem;
41type CompoundedComponent = InternalFormItemType & {
42 useStatus: typeof useFormItemStatus;
43};
44declare const FormItem: CompoundedComponent;
45export default FormItem;