@1money/component-ui 0.0.76 → 0.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/Dialog/Dialog.js +11 -3
- package/es/components/Dialog/interface.d.ts +1 -0
- package/es/components/Grid/Col.js +60 -4
- package/es/components/Grid/Grid.d.ts +4 -1
- package/es/components/Grid/Grid.js +5 -4
- package/es/components/Grid/Row.js +7 -5
- package/es/components/Grid/constants.d.ts +5 -3
- package/es/components/Grid/constants.js +13 -4
- package/es/components/Grid/helper.d.ts +8 -6
- package/es/components/Grid/helper.js +63 -15
- package/es/components/Grid/interface.d.ts +2 -1
- package/es/components/Grid/style/Grid.css +240 -196
- package/es/components/ProForm/ProForm.d.ts +1 -1
- package/es/components/ProForm/ProForm.js +4 -5
- package/es/components/ProForm/ProFormDependency.d.ts +2 -1
- package/es/components/ProForm/ProFormDependency.js +1 -1
- package/es/components/ProForm/ProFormItem.d.ts +7 -2
- package/es/components/ProForm/ProFormItem.js +1 -1
- package/es/components/ProForm/ProFormList.d.ts +6 -1
- package/es/components/ProForm/ProFormList.js +13 -5
- package/es/components/ProForm/SchemaForm.d.ts +1 -1
- package/es/components/ProForm/SchemaForm.js +8 -5
- package/es/components/ProForm/constants.d.ts +1 -1
- package/es/components/ProForm/constants.js +5 -2
- package/es/components/ProForm/context.d.ts +8 -7
- package/es/components/ProForm/context.js +1 -1
- package/es/components/ProForm/core/constants.d.ts +1 -1
- package/es/components/ProForm/core/constants.js +2 -2
- package/es/components/ProForm/core/devWarning.d.ts +1 -3
- package/es/components/ProForm/core/devWarning.js +5 -15
- package/es/components/ProForm/core/formStore.d.ts +4 -4
- package/es/components/ProForm/core/formStore.js +1 -1
- package/es/components/ProForm/core/hooks/useForm.d.ts +1 -1
- package/es/components/ProForm/core/hooks/useForm.js +34 -9
- package/es/components/ProForm/core/hooks/useFormCore.d.ts +2 -2
- package/es/components/ProForm/core/hooks/useFormCore.js +17 -123
- package/es/components/ProForm/core/interface.d.ts +70 -91
- package/es/components/ProForm/core/namePathType.d.ts +25 -0
- package/es/components/ProForm/core/namePathType.js +2 -0
- package/es/components/ProForm/core/pathUtils.d.ts +5 -3
- package/es/components/ProForm/core/pathUtils.js +19 -1
- package/es/components/ProForm/core/runRules.d.ts +8 -17
- package/es/components/ProForm/core/runRules.js +22 -129
- package/es/components/ProForm/core/useFormItem.d.ts +1 -1
- package/es/components/ProForm/core/useFormItem.js +14 -66
- package/es/components/ProForm/core/validationError.d.ts +2 -2
- package/es/components/ProForm/core/validationError.js +1 -1
- package/es/components/ProForm/fields/ProFormCheckbox.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormCheckboxGroup.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormCheckboxGroup.js +1 -1
- package/es/components/ProForm/fields/ProFormDatePicker.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormDatePicker.js +1 -1
- package/es/components/ProForm/fields/ProFormFieldSet.d.ts +7 -2
- package/es/components/ProForm/fields/ProFormFieldSet.js +5 -7
- package/es/components/ProForm/fields/ProFormPassword.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormRadioGroup.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormRadioGroup.js +1 -1
- package/es/components/ProForm/fields/ProFormSelect.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormSelect.js +1 -1
- package/es/components/ProForm/fields/ProFormSlider.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormSwitch.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormText.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormTextArea.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormUpload.d.ts +1 -1
- package/es/components/ProForm/fields/ProFormUpload.js +1 -1
- package/es/components/ProForm/fields/createProFormField.d.ts +8 -2
- package/es/components/ProForm/fields/createProFormField.js +3 -3
- package/es/components/ProForm/hooks/useFieldRequest.d.ts +1 -1
- package/es/components/ProForm/hooks/useFieldRequest.js +1 -1
- package/es/components/ProForm/hooks/useUrlSync.d.ts +8 -7
- package/es/components/ProForm/hooks/useUrlSync.js +1 -1
- package/es/components/ProForm/index.d.ts +35 -26
- package/es/components/ProForm/index.js +1 -1
- package/es/components/ProForm/interface.d.ts +96 -91
- package/es/components/ProForm/layouts/DialogForm.d.ts +1 -1
- package/es/components/ProForm/layouts/DialogForm.js +2 -4
- package/es/components/ProForm/layouts/DrawerForm.d.ts +1 -1
- package/es/components/ProForm/layouts/DrawerForm.js +1 -1
- package/es/components/ProForm/layouts/QueryFilter.d.ts +1 -1
- package/es/components/ProForm/layouts/QueryFilter.js +1 -1
- package/es/components/ProForm/layouts/useOverlayForm.d.ts +2 -2
- package/es/components/ProForm/layouts/useOverlayForm.js +1 -1
- package/es/components/ProForm/utils.d.ts +8 -8
- package/es/components/ProForm/utils.js +1 -1
- package/es/index.css +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/utils/devWarn.d.ts +4 -0
- package/es/utils/devWarn.js +23 -0
- package/lib/components/Dialog/Dialog.js +11 -3
- package/lib/components/Dialog/interface.d.ts +1 -0
- package/lib/components/Grid/Col.js +59 -3
- package/lib/components/Grid/Grid.d.ts +4 -1
- package/lib/components/Grid/Grid.js +5 -4
- package/lib/components/Grid/Row.js +6 -4
- package/lib/components/Grid/constants.d.ts +5 -3
- package/lib/components/Grid/constants.js +14 -5
- package/lib/components/Grid/helper.d.ts +8 -6
- package/lib/components/Grid/helper.js +63 -15
- package/lib/components/Grid/interface.d.ts +2 -1
- package/lib/components/Grid/style/Grid.css +240 -196
- package/lib/components/ProForm/ProForm.d.ts +1 -1
- package/lib/components/ProForm/ProForm.js +3 -4
- package/lib/components/ProForm/ProFormDependency.d.ts +2 -1
- package/lib/components/ProForm/ProFormDependency.js +1 -1
- package/lib/components/ProForm/ProFormItem.d.ts +7 -2
- package/lib/components/ProForm/ProFormItem.js +1 -1
- package/lib/components/ProForm/ProFormList.d.ts +6 -1
- package/lib/components/ProForm/ProFormList.js +13 -5
- package/lib/components/ProForm/SchemaForm.d.ts +1 -1
- package/lib/components/ProForm/SchemaForm.js +8 -5
- package/lib/components/ProForm/constants.d.ts +1 -1
- package/lib/components/ProForm/constants.js +5 -2
- package/lib/components/ProForm/context.d.ts +8 -7
- package/lib/components/ProForm/context.js +1 -1
- package/lib/components/ProForm/core/constants.d.ts +1 -1
- package/lib/components/ProForm/core/constants.js +2 -2
- package/lib/components/ProForm/core/devWarning.d.ts +1 -3
- package/lib/components/ProForm/core/devWarning.js +23 -24
- package/lib/components/ProForm/core/formStore.d.ts +4 -4
- package/lib/components/ProForm/core/formStore.js +1 -1
- package/lib/components/ProForm/core/hooks/useForm.d.ts +1 -1
- package/lib/components/ProForm/core/hooks/useForm.js +34 -9
- package/lib/components/ProForm/core/hooks/useFormCore.d.ts +2 -2
- package/lib/components/ProForm/core/hooks/useFormCore.js +16 -122
- package/lib/components/ProForm/core/interface.d.ts +70 -91
- package/lib/components/ProForm/core/namePathType.d.ts +25 -0
- package/lib/components/ProForm/core/namePathType.js +6 -0
- package/lib/components/ProForm/core/pathUtils.d.ts +5 -3
- package/lib/components/ProForm/core/pathUtils.js +20 -1
- package/lib/components/ProForm/core/runRules.d.ts +8 -17
- package/lib/components/ProForm/core/runRules.js +22 -130
- package/lib/components/ProForm/core/useFormItem.d.ts +1 -1
- package/lib/components/ProForm/core/useFormItem.js +17 -69
- package/lib/components/ProForm/core/validationError.d.ts +2 -2
- package/lib/components/ProForm/core/validationError.js +1 -1
- package/lib/components/ProForm/fields/ProFormCheckbox.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormCheckboxGroup.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormCheckboxGroup.js +1 -1
- package/lib/components/ProForm/fields/ProFormDatePicker.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormDatePicker.js +1 -1
- package/lib/components/ProForm/fields/ProFormFieldSet.d.ts +7 -2
- package/lib/components/ProForm/fields/ProFormFieldSet.js +5 -7
- package/lib/components/ProForm/fields/ProFormPassword.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormRadioGroup.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormRadioGroup.js +1 -1
- package/lib/components/ProForm/fields/ProFormSelect.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormSelect.js +1 -1
- package/lib/components/ProForm/fields/ProFormSlider.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormSwitch.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormText.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormTextArea.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormUpload.d.ts +1 -1
- package/lib/components/ProForm/fields/ProFormUpload.js +1 -1
- package/lib/components/ProForm/fields/createProFormField.d.ts +8 -2
- package/lib/components/ProForm/fields/createProFormField.js +3 -3
- package/lib/components/ProForm/hooks/useFieldRequest.d.ts +1 -1
- package/lib/components/ProForm/hooks/useFieldRequest.js +1 -1
- package/lib/components/ProForm/hooks/useUrlSync.d.ts +8 -7
- package/lib/components/ProForm/hooks/useUrlSync.js +1 -1
- package/lib/components/ProForm/index.d.ts +35 -26
- package/lib/components/ProForm/index.js +1 -1
- package/lib/components/ProForm/interface.d.ts +96 -91
- package/lib/components/ProForm/layouts/DialogForm.d.ts +1 -1
- package/lib/components/ProForm/layouts/DialogForm.js +2 -4
- package/lib/components/ProForm/layouts/DrawerForm.d.ts +1 -1
- package/lib/components/ProForm/layouts/DrawerForm.js +1 -1
- package/lib/components/ProForm/layouts/QueryFilter.d.ts +1 -1
- package/lib/components/ProForm/layouts/QueryFilter.js +1 -1
- package/lib/components/ProForm/layouts/useOverlayForm.d.ts +2 -2
- package/lib/components/ProForm/layouts/useOverlayForm.js +1 -1
- package/lib/components/ProForm/utils.d.ts +8 -8
- package/lib/components/ProForm/utils.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/utils/devWarn.d.ts +4 -0
- package/lib/utils/devWarn.js +31 -0
- package/package.json +1 -1
- package/scripts/mcp-server/examples.generated.json +224 -74
- package/scripts/mcp-server/index.generated.json +1758 -100
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { FC, ReactNode } from 'react';
|
|
3
|
+
import type { ProFormFieldName, ProFormFieldValueMap, ProFormPathValue, ProFormRecursivePartial, ProFormValuesPatch } from './namePathType';
|
|
3
4
|
import type { FormSize, FormLayout, LabelAlign, ValidateStatus, ValidateTrigger } from './constants';
|
|
4
5
|
import { RULE_CONTEXT_READ_MEMBERS, RULE_CONTEXT_MUTATOR_MEMBERS } from './constants';
|
|
5
6
|
export type { FormSize, FormLayout, LabelAlign, ValidateStatus, ValidateTrigger, };
|
|
7
|
+
export type { ProFormFieldName, ProFormFieldValueMap, ProFormPathValue, ProFormRecursivePartial, ProFormValuesPatch, } from './namePathType';
|
|
6
8
|
/** Built-in `type` check names. */
|
|
7
9
|
export type RuleType = 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'object' | 'array' | 'date' | 'url' | 'hex' | 'email' | 'enum';
|
|
8
10
|
export interface Rule {
|
|
@@ -18,11 +20,11 @@ export interface Rule {
|
|
|
18
20
|
len?: number;
|
|
19
21
|
pattern?: RegExp;
|
|
20
22
|
type?: RuleType;
|
|
21
|
-
enum?:
|
|
23
|
+
enum?: any[];
|
|
22
24
|
/** Fails a non-empty string consisting only of whitespace */
|
|
23
25
|
whitespace?: boolean;
|
|
24
26
|
/** Transform the value before every check (builtin and validator) of THIS rule */
|
|
25
|
-
transform?: (value:
|
|
27
|
+
transform?: (value: any) => any;
|
|
26
28
|
/** Deep rule(s) applied to every member of an array/object value */
|
|
27
29
|
defaultField?: Rule | Rule[];
|
|
28
30
|
/** Deep rules applied per key of an object/array value */
|
|
@@ -43,7 +45,7 @@ export interface Rule {
|
|
|
43
45
|
* fallback. Return values are ignored — returning `false` or a string does
|
|
44
46
|
* NOT fail the rule.
|
|
45
47
|
*/
|
|
46
|
-
validator?: (rule: Rule, value:
|
|
48
|
+
validator?: (rule: Rule, value: any) => Promise<void> | void;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Form/Item-level validateTrigger config: a single event, a
|
|
@@ -59,23 +61,23 @@ export type ValidateTriggerProp = ValidateTrigger | ValidateTrigger[] | false;
|
|
|
59
61
|
* whenever rules run inside a mounted form — they are only absent when the
|
|
60
62
|
* pure rule engine is invoked directly without an instance.
|
|
61
63
|
*/
|
|
62
|
-
export interface RuleContext {
|
|
63
|
-
getFieldValue: (name:
|
|
64
|
-
getFieldsValue: () =>
|
|
65
|
-
setFieldValue?: (name:
|
|
66
|
-
setFieldsValue?: (values:
|
|
64
|
+
export interface RuleContext<Values = Record<string, any>> {
|
|
65
|
+
getFieldValue: <Name extends ProFormFieldName<Values>>(name: Name) => ProFormPathValue<Values, Name>;
|
|
66
|
+
getFieldsValue: () => Values;
|
|
67
|
+
setFieldValue?: <Name extends ProFormFieldName<Values>>(name: Name, value: ProFormPathValue<Values, Name>) => void;
|
|
68
|
+
setFieldsValue?: (values: ProFormValuesPatch<Values>) => void;
|
|
67
69
|
resetFields?: () => void;
|
|
68
|
-
getFieldError?: (name:
|
|
69
|
-
getFieldWarning?: (name:
|
|
70
|
-
isFieldTouched?: (name:
|
|
71
|
-
isFieldValidating?: (name:
|
|
70
|
+
getFieldError?: (name: ProFormFieldName<Values>) => ReactNode | undefined;
|
|
71
|
+
getFieldWarning?: (name: ProFormFieldName<Values>) => ReactNode | undefined;
|
|
72
|
+
isFieldTouched?: (name: ProFormFieldName<Values>) => boolean;
|
|
73
|
+
isFieldValidating?: (name: ProFormFieldName<Values>) => boolean;
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
76
|
* A rule entry as consumers write it: a static Rule, or — for cross-field
|
|
75
77
|
* validation — a function of the form context returning a Rule (the
|
|
76
78
|
* `({ getFieldValue }) => ({ validator })` idiom).
|
|
77
79
|
*/
|
|
78
|
-
export type FormRule = Rule | ((ctx: RuleContext) => Rule);
|
|
80
|
+
export type FormRule<Values = Record<string, any>> = Rule | ((ctx: RuleContext<Values>) => Rule);
|
|
79
81
|
export type RuleContextReadMember = (typeof RULE_CONTEXT_READ_MEMBERS)[number];
|
|
80
82
|
export type RuleContextMutatorMember = (typeof RULE_CONTEXT_MUTATOR_MEMBERS)[number];
|
|
81
83
|
type AssertRuleContextMembers<T extends keyof RuleContext> = T;
|
|
@@ -86,11 +88,11 @@ type AssertRuleContextMembers<T extends keyof RuleContext> = T;
|
|
|
86
88
|
export type RuleContextInstanceMember = AssertRuleContextMembers<RuleContextReadMember | RuleContextMutatorMember>;
|
|
87
89
|
export interface FieldProps {
|
|
88
90
|
name: string;
|
|
89
|
-
value:
|
|
91
|
+
value: any;
|
|
90
92
|
error?: ReactNode;
|
|
91
93
|
touched?: boolean;
|
|
92
94
|
validating?: boolean;
|
|
93
|
-
onChange: (value:
|
|
95
|
+
onChange: (value: any) => void;
|
|
94
96
|
onBlur: () => void;
|
|
95
97
|
}
|
|
96
98
|
export interface FieldOptions {
|
|
@@ -102,102 +104,83 @@ export interface FieldComponentProps {
|
|
|
102
104
|
render?: (props: FieldProps) => ReactNode;
|
|
103
105
|
}
|
|
104
106
|
/** Lightweight form instance returned by useFormCore */
|
|
105
|
-
export interface FormCoreInstance {
|
|
106
|
-
submit: () => {
|
|
107
|
-
success: boolean;
|
|
108
|
-
values?: Record<string, unknown>;
|
|
109
|
-
errors?: Record<string, ReactNode>;
|
|
110
|
-
};
|
|
107
|
+
export interface FormCoreInstance<Values = Record<string, any>> {
|
|
111
108
|
resetFields: () => void;
|
|
112
|
-
getFieldValue: (name:
|
|
113
|
-
getFieldsValue: () =>
|
|
114
|
-
setFieldsValue: (values:
|
|
115
|
-
setFieldValue: (name:
|
|
116
|
-
validateFields: (fieldsRules?: Record<string, FormRule[]>) => boolean;
|
|
109
|
+
getFieldValue: <Name extends ProFormFieldName<Values>>(name: Name) => ProFormPathValue<Values, Name>;
|
|
110
|
+
getFieldsValue: () => Values;
|
|
111
|
+
setFieldsValue: (values: ProFormValuesPatch<Values>) => void;
|
|
112
|
+
setFieldValue: <Name extends ProFormFieldName<Values>>(name: Name, value: ProFormPathValue<Values, Name>) => void;
|
|
117
113
|
}
|
|
118
114
|
/**
|
|
119
115
|
* Full form instance returned by useForm — extends FormCoreInstance with async
|
|
120
116
|
* validation, field helpers, etc. `Values` types the whole-form value shape
|
|
121
117
|
* (defaults to an open record for backward compatibility).
|
|
122
118
|
*/
|
|
123
|
-
export interface FormInstance<Values = Record<string,
|
|
124
|
-
getFieldValue: (name:
|
|
125
|
-
getFieldsValue:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
export interface FormInstance<Values = Record<string, any>> {
|
|
120
|
+
getFieldValue: <Name extends ProFormFieldName<Values>>(name: Name) => ProFormPathValue<Values, Name>;
|
|
121
|
+
getFieldsValue: {
|
|
122
|
+
(): Values;
|
|
123
|
+
<Name extends ProFormFieldName<Values>>(nameList: Name[]): ProFormFieldValueMap<Values, Name>;
|
|
124
|
+
};
|
|
125
|
+
setFieldValue: <Name extends ProFormFieldName<Values>>(name: Name, value: ProFormPathValue<Values, Name>) => void;
|
|
126
|
+
setFieldsValue: (values: ProFormValuesPatch<Values>) => void;
|
|
127
|
+
setFieldError: (name: ProFormFieldName<Values>, error: ReactNode | null) => void;
|
|
129
128
|
setFieldsError: (errors: Record<string, ReactNode>) => void;
|
|
130
|
-
resetFields: (fields?:
|
|
131
|
-
validateFields:
|
|
129
|
+
resetFields: (fields?: ProFormFieldName<Values>[]) => void;
|
|
130
|
+
validateFields: {
|
|
131
|
+
(): Promise<Values>;
|
|
132
|
+
<Name extends ProFormFieldName<Values>>(nameList: Name[]): Promise<ProFormFieldValueMap<Values, Name>>;
|
|
133
|
+
};
|
|
132
134
|
submit: (callback?: (values: Values) => void | Promise<void>) => Promise<Values | undefined>;
|
|
133
|
-
getFieldError: (name:
|
|
134
|
-
getFieldsError: (nameList?:
|
|
135
|
-
getFieldWarning: (name:
|
|
136
|
-
isFieldTouched: (name:
|
|
137
|
-
isFieldsTouched: (nameList?:
|
|
138
|
-
isFieldValidating: (name:
|
|
139
|
-
setFieldTouched: (name:
|
|
135
|
+
getFieldError: (name: ProFormFieldName<Values>) => ReactNode | undefined;
|
|
136
|
+
getFieldsError: (nameList?: ProFormFieldName<Values>[]) => Record<string, ReactNode>;
|
|
137
|
+
getFieldWarning: (name: ProFormFieldName<Values>) => ReactNode | undefined;
|
|
138
|
+
isFieldTouched: (name: ProFormFieldName<Values>) => boolean;
|
|
139
|
+
isFieldsTouched: (nameList?: ProFormFieldName<Values>[], allTouched?: boolean) => boolean;
|
|
140
|
+
isFieldValidating: (name: ProFormFieldName<Values>) => boolean;
|
|
141
|
+
setFieldTouched: (name: ProFormFieldName<Values>, isTouched?: boolean) => void;
|
|
140
142
|
setFieldsTouched: (touched: Record<string, boolean>) => void;
|
|
141
143
|
defineField: (name: string, options?: FieldOptions) => FC<FieldComponentProps>;
|
|
142
|
-
registerField: (name: string, rules: FormRule[]) => void;
|
|
144
|
+
registerField: (name: string, rules: FormRule<Values>[]) => void;
|
|
143
145
|
unregisterField: (name: string) => void;
|
|
144
146
|
}
|
|
145
147
|
export interface UseFormOptions {
|
|
146
|
-
onValuesChange?: (changedValues: Record<string,
|
|
148
|
+
onValuesChange?: (changedValues: Record<string, any>, allValues: Record<string, any>) => void;
|
|
147
149
|
validateTrigger?: ValidateTriggerProp;
|
|
148
150
|
rules?: Record<string, FormRule[]>;
|
|
149
151
|
}
|
|
150
|
-
export interface UseFormCoreConfig<Values = Record<string,
|
|
151
|
-
initialValues?:
|
|
152
|
+
export interface UseFormCoreConfig<Values = Record<string, any>> {
|
|
153
|
+
initialValues?: ProFormRecursivePartial<Values>;
|
|
152
154
|
onFinish?: (values: Values) => void;
|
|
153
155
|
onFinishFailed?: (errorInfo: {
|
|
154
156
|
values: Values;
|
|
155
157
|
errors: Record<string, ReactNode>;
|
|
156
158
|
}) => void;
|
|
157
|
-
onValuesChange?: (changedValues:
|
|
159
|
+
onValuesChange?: (changedValues: ProFormValuesPatch<Values>, allValues: Values) => void;
|
|
158
160
|
onReset?: () => void;
|
|
159
161
|
size?: FormSize;
|
|
160
162
|
labelAlign?: LabelAlign;
|
|
161
163
|
disabled?: boolean;
|
|
162
164
|
validateTrigger?: ValidateTriggerProp;
|
|
163
165
|
}
|
|
164
|
-
/** Internal shape of data produced by useFormCore, consumed by ProForm to build ProFormContext */
|
|
165
|
-
export interface FormCoreContextShape {
|
|
166
|
-
values: Record<string, unknown>;
|
|
167
|
-
errors: Record<string, ReactNode>;
|
|
168
|
-
warnings: Record<string, ReactNode>;
|
|
169
|
-
touched: Record<string, boolean>;
|
|
170
|
-
formInstance: FormCoreInstance;
|
|
171
|
-
setFieldValue: (name: string, value: unknown) => void;
|
|
172
|
-
setFieldError: (name: string, error: ReactNode | null) => void;
|
|
173
|
-
setFieldWarning: (name: string, warning: ReactNode | null) => void;
|
|
174
|
-
validateField: (name: string, rules: FormRule[], providedValue?: unknown) => boolean;
|
|
175
|
-
registerField: (name: string, rules: FormRule[]) => void;
|
|
176
|
-
unregisterField: (name: string) => void;
|
|
177
|
-
size: FormSize;
|
|
178
|
-
labelAlign: LabelAlign;
|
|
179
|
-
disabled: boolean;
|
|
180
|
-
validateTrigger: ValidateTriggerProp;
|
|
181
|
-
}
|
|
182
166
|
/** Config for useForm — accepts all UseFormCoreConfig fields */
|
|
183
|
-
export type UseFormConfig<Values = Record<string,
|
|
167
|
+
export type UseFormConfig<Values = Record<string, any>> = UseFormCoreConfig<Values>;
|
|
184
168
|
/** Internal state exposed by useForm for ProForm integration */
|
|
185
|
-
export interface UseFormInternals {
|
|
186
|
-
values: Record<string,
|
|
169
|
+
export interface UseFormInternals<Values = Record<string, any>> {
|
|
170
|
+
values: Record<string, any>;
|
|
187
171
|
errors: Record<string, ReactNode>;
|
|
188
172
|
warnings: Record<string, ReactNode>;
|
|
189
173
|
touched: Record<string, boolean>;
|
|
190
174
|
validating: Record<string, boolean>;
|
|
191
|
-
fieldRules: Record<string, FormRule[]>;
|
|
192
|
-
setFieldValue: (name: string, value:
|
|
175
|
+
fieldRules: Record<string, FormRule<Values>[]>;
|
|
176
|
+
setFieldValue: (name: string, value: any) => void;
|
|
193
177
|
setFieldError: (name: string, error: ReactNode | null) => void;
|
|
194
178
|
setFieldWarning: (name: string, warning: ReactNode | null) => void;
|
|
195
|
-
|
|
196
|
-
validateFieldAsync: (name: string, value: unknown, rules: FormRule[]) => Promise<{
|
|
179
|
+
validateFieldAsync: (name: string, value: any, rules: FormRule<Values>[]) => Promise<{
|
|
197
180
|
isValid: boolean;
|
|
198
181
|
error: ReactNode | null;
|
|
199
182
|
}>;
|
|
200
|
-
registerField: (name: string, rules: FormRule[]) => void;
|
|
183
|
+
registerField: (name: string, rules: FormRule<Values>[]) => void;
|
|
201
184
|
unregisterField: (name: string) => void;
|
|
202
185
|
/** Count a mounted instance for `name` — pair with `releaseField` on unmount. */
|
|
203
186
|
retainField: (name: string) => void;
|
|
@@ -207,43 +190,39 @@ export interface UseFormInternals {
|
|
|
207
190
|
handleReset: (e?: React.FormEvent) => void;
|
|
208
191
|
}
|
|
209
192
|
/** Return type for useForm */
|
|
210
|
-
export interface UseFormReturn {
|
|
211
|
-
formInstance: FormInstance
|
|
212
|
-
internals: UseFormInternals
|
|
193
|
+
export interface UseFormReturn<Values = Record<string, any>> {
|
|
194
|
+
formInstance: FormInstance<Values>;
|
|
195
|
+
internals: UseFormInternals<Values>;
|
|
213
196
|
}
|
|
214
|
-
export interface UseFormCoreReturn {
|
|
215
|
-
values: Record<string,
|
|
197
|
+
export interface UseFormCoreReturn<Values = Record<string, any>> {
|
|
198
|
+
values: Record<string, any>;
|
|
216
199
|
errors: Record<string, ReactNode>;
|
|
217
200
|
warnings: Record<string, ReactNode>;
|
|
218
201
|
touched: Record<string, boolean>;
|
|
219
|
-
fieldRules: Record<string, FormRule[]>;
|
|
220
|
-
getFieldRules: (name: string) => FormRule[] | undefined;
|
|
202
|
+
fieldRules: Record<string, FormRule<Values>[]>;
|
|
203
|
+
getFieldRules: (name: string) => FormRule<Values>[] | undefined;
|
|
221
204
|
/** Instance handed to function-form rules; useForm upgrades it to the full form instance. */
|
|
222
|
-
getRuleContextInstance: () => Partial<RuleContext
|
|
223
|
-
setRuleContextInstance: (instance: Partial<RuleContext
|
|
205
|
+
getRuleContextInstance: () => Partial<RuleContext<Values>>;
|
|
206
|
+
setRuleContextInstance: (instance: Partial<RuleContext<Values>>) => void;
|
|
224
207
|
/** Bump and return the field's validation epoch — every run captures one. */
|
|
225
208
|
beginValidationRun: (name: string) => number;
|
|
226
209
|
/** True while no newer run has started for the field since `epoch` was issued. */
|
|
227
210
|
isValidationRunCurrent: (name: string, epoch: number) => boolean;
|
|
228
211
|
/** Invalidate in-flight runs (all fields, or the given ones) — e.g. on reset. */
|
|
229
212
|
invalidateValidationRuns: (names?: string[]) => void;
|
|
230
|
-
setFieldValue: (name: string, value:
|
|
213
|
+
setFieldValue: (name: string, value: any) => void;
|
|
231
214
|
setFieldError: (name: string, error: ReactNode | null) => void;
|
|
232
215
|
setFieldWarning: (name: string, warning: ReactNode | null) => void;
|
|
233
|
-
setFieldsValue: (values:
|
|
234
|
-
getFieldValue: (name: string) =>
|
|
235
|
-
getFieldsValue: () =>
|
|
236
|
-
|
|
237
|
-
validateFields: (fieldsRules?: Record<string, FormRule[]>) => boolean;
|
|
238
|
-
registerField: (name: string, rules: FormRule[]) => void;
|
|
216
|
+
setFieldsValue: (values: ProFormValuesPatch<Values>) => void;
|
|
217
|
+
getFieldValue: (name: string) => any;
|
|
218
|
+
getFieldsValue: () => Values;
|
|
219
|
+
registerField: (name: string, rules: FormRule<Values>[]) => void;
|
|
239
220
|
unregisterField: (name: string) => void;
|
|
240
221
|
/** Count a mounted instance for `name` — pair with `releaseField` on unmount. */
|
|
241
222
|
retainField: (name: string) => void;
|
|
242
223
|
/** Drop one instance count; the field's rules are removed only at zero. */
|
|
243
224
|
releaseField: (name: string) => void;
|
|
244
|
-
handleSubmit: (e?: React.FormEvent) => void;
|
|
245
225
|
handleReset: (e?: React.FormEvent) => void;
|
|
246
226
|
resetFields: () => void;
|
|
247
|
-
formInstance: FormCoreInstance
|
|
248
|
-
coreContextShape: FormCoreContextShape;
|
|
227
|
+
formInstance: FormCoreInstance<Values>;
|
|
249
228
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date | File | Blob | ((...args: never[]) => any);
|
|
2
|
+
type PreviousDepth = [never, 0, 1, 2, 3, 4, 5, 6];
|
|
3
|
+
type StringKey<T> = Extract<keyof T, string>;
|
|
4
|
+
type DotPathInternal<Value, Depth extends number> = [Depth] extends [never] ? never : Value extends Primitive ? never : Value extends readonly (infer Item)[] ? `${number}` | `${number}.${DotPathInternal<NonNullable<Item>, PreviousDepth[Depth]>}` : {
|
|
5
|
+
[Key in StringKey<Value>]: NonNullable<Value[Key]> extends Primitive ? Key : NonNullable<Value[Key]> extends readonly (infer Item)[] ? Key | `${Key}.${number}` | `${Key}.${number}.${DotPathInternal<NonNullable<Item>, PreviousDepth[Depth]>}` : Key | `${Key}.${DotPathInternal<NonNullable<Value[Key]>, PreviousDepth[Depth]>}`;
|
|
6
|
+
}[StringKey<Value>];
|
|
7
|
+
type SegmentValue<Value, Segment extends string> = Value extends readonly (infer Item)[] ? Segment extends `${number}` ? Item : any : Segment extends keyof Value ? Value[Segment] : any;
|
|
8
|
+
/**
|
|
9
|
+
* Runtime ProForm field names are dot-path strings (`user.name`,
|
|
10
|
+
* `items.0.title`). When no concrete `Values` shape is supplied, names remain
|
|
11
|
+
* open strings for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export type ProFormFieldName<Values = Record<string, any>> = string extends keyof Values ? string : DotPathInternal<NonNullable<Values>, 6>;
|
|
14
|
+
export type ProFormPathValue<Values, Path> = Path extends string ? Path extends `${infer Head}.${infer Tail}` ? ProFormPathValue<NonNullable<SegmentValue<NonNullable<Values>, Head>>, Tail> : SegmentValue<NonNullable<Values>, Path> : any;
|
|
15
|
+
export type ProFormRecursivePartial<Value> = Value extends Primitive ? Value : Value extends readonly (infer Item)[] ? ProFormRecursivePartial<Item>[] : Value extends object ? {
|
|
16
|
+
[Key in keyof Value]?: ProFormRecursivePartial<Value[Key]>;
|
|
17
|
+
} : Value;
|
|
18
|
+
export type ProFormFieldValueMap<Values, Name extends ProFormFieldName<Values> = ProFormFieldName<Values>> = Partial<{
|
|
19
|
+
[FieldName in Name]: ProFormPathValue<Values, FieldName>;
|
|
20
|
+
}>;
|
|
21
|
+
type ProFormFieldPatchValue<Values, FieldName extends ProFormFieldName<Values>> = FieldName extends StringKey<Values> ? ProFormRecursivePartial<ProFormPathValue<Values, FieldName>> : ProFormPathValue<Values, FieldName>;
|
|
22
|
+
export type ProFormValuesPatch<Values> = ProFormRecursivePartial<Values> | Partial<{
|
|
23
|
+
[FieldName in ProFormFieldName<Values>]: ProFormFieldPatchValue<Values, FieldName>;
|
|
24
|
+
}>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9uZW50cy9Qcm9Gb3JtL2NvcmUvbmFtZVBhdGhUeXBlLmpzIiwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjIiwic291cmNlcyI6WyJjb21wb25lbnRzL1Byb0Zvcm0vY29yZS9uYW1lUGF0aFR5cGUuanMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHt9OyJdLCJtYXBwaW5ncyI6IkFBQUEiLCJpZ25vcmVMaXN0IjpbXX0=
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Read a dot-path value out of a nested object. Returns undefined if any segment is missing. */
|
|
2
|
-
export declare function getNestedValue(obj: Record<string,
|
|
2
|
+
export declare function getNestedValue(obj: Record<string, any>, path: string): any;
|
|
3
3
|
/** Immutably set a dot-path value, cloning each object/array along the path. */
|
|
4
|
-
export declare function setNestedValue(obj: Record<string,
|
|
4
|
+
export declare function setNestedValue(obj: Record<string, any>, path: string, value: any): Record<string, any>;
|
|
5
|
+
/** Immutably deep-merge a form values patch. Arrays and non-plain objects replace. */
|
|
6
|
+
export declare function mergeValuesPatch(values: Record<string, any>, patch: Record<string, any>): Record<string, any>;
|
|
5
7
|
/** Read a field value, taking the fast path for flat (non-dotted) names. */
|
|
6
|
-
export declare function resolveValue(values: Record<string,
|
|
8
|
+
export declare function resolveValue(values: Record<string, any>, name: string): any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
4
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
@@ -52,8 +53,25 @@ export function setNestedValue(obj, path, value) {
|
|
|
52
53
|
current[keys[keys.length - 1]] = value;
|
|
53
54
|
return result;
|
|
54
55
|
}
|
|
56
|
+
function isPlainObject(value) {
|
|
57
|
+
if (value === null || _typeof(value) !== 'object') return false;
|
|
58
|
+
var prototype = Object.getPrototypeOf(value);
|
|
59
|
+
return prototype === Object.prototype || prototype === null;
|
|
60
|
+
}
|
|
61
|
+
/** Immutably deep-merge a form values patch. Arrays and non-plain objects replace. */
|
|
62
|
+
export function mergeValuesPatch(values, patch) {
|
|
63
|
+
var result = Object.assign({}, values);
|
|
64
|
+
for (var _i = 0, _Object$entries = Object.entries(patch); _i < _Object$entries.length; _i++) {
|
|
65
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
66
|
+
key = _Object$entries$_i[0],
|
|
67
|
+
patchValue = _Object$entries$_i[1];
|
|
68
|
+
var currentValue = result[key];
|
|
69
|
+
result[key] = isPlainObject(currentValue) && isPlainObject(patchValue) ? mergeValuesPatch(currentValue, patchValue) : patchValue;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
55
73
|
/** Read a field value, taking the fast path for flat (non-dotted) names. */
|
|
56
74
|
export function resolveValue(values, name) {
|
|
57
75
|
return name.includes('.') ? getNestedValue(values, name) : values[name];
|
|
58
76
|
}
|
|
59
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvUHJvRm9ybS9zcmMvY29tcG9uZW50cy9Qcm9Gb3JtL2NvcmUvcGF0aFV0aWxzLnRzIl0sIm5hbWVzIjpbImdldE5lc3RlZFZhbHVlIiwib2JqIiwicGF0aCIsImtleXMiLCJzcGxpdCIsImN1cnJlbnQiLCJfaXRlcmF0b3IiLCJfY3JlYXRlRm9yT2ZJdGVyYXRvckhlbHBlciIsIl9zdGVwIiwicyIsIm4iLCJkb25lIiwia2V5IiwidmFsdWUiLCJ1bmRlZmluZWQiLCJfdHlwZW9mIiwiZXJyIiwiZSIsImYiLCJzZXROZXN0ZWRWYWx1ZSIsImxlbmd0aCIsIk9iamVjdCIsImFzc2lnbiIsIl9kZWZpbmVQcm9wZXJ0eSIsInJlc3VsdCIsImkiLCJuZXh0S2V5IiwiaXNOZXh0QXJyYXkiLCJ0ZXN0IiwiQXJyYXkiLCJpc0FycmF5IiwiX3RvQ29uc3VtYWJsZUFycmF5IiwiaXNQbGFpbk9iamVjdCIsInByb3RvdHlwZSIsImdldFByb3RvdHlwZU9mIiwibWVyZ2VWYWx1ZXNQYXRjaCIsInZhbHVlcyIsInBhdGNoIiwiX2kiLCJfT2JqZWN0JGVudHJpZXMiLCJlbnRyaWVzIiwiX09iamVjdCRlbnRyaWVzJF9pIiwiX3Nsa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xFQUFBa0IsRUFBQSxJQUFFO0lBQWxELElBQUFHLGtCQUFBLEdBQUFDLGNBQUEsQ0FBQUgsZUFBQSxDQUFBRCxFQUFBO01BQU8xQixHQUFHLEdBQUE2QixrQkFBQTtNQUFFRSxVQUFVLEdBQUFGLGtCQUFBO0lBQ3pCLElBQU1HLFlBQVksR0FBR3BCLE1BQU0sQ0FBQ1osR0FBRyxDQUFDO0lBQ2hDWSxNQUFNLENBQUNaLEdBQUcsQ0FBQyxHQUNUb0IsYUFBYSxDQUFDWSxZQUFZLENBQUMsSUFBSVosYUFBYSxDQUFDVyxVQUFVLENBQUMsR0FDcERSLGdCQUFnQixDQUFDUyxZQUFZLEVBQUVELFVBQVUsQ0FBQyxHQUMxQ0EsVUFBVTtFQUNsQjtFQUNBLE9BQU9uQixNQUFNO0FBQ2Y7QUFFQTtBQUNBLE9BQU0sU0FBVXFCLFlBQVlBLENBQUNULE1BQTJCLEVBQUVVLElBQVksRUFBQTtFQUNwRSxPQUFPQSxJQUFJLENBQUNDLFFBQVEsQ0FBQyxHQUFHLENBQUMsR0FBRy9DLGNBQWMsQ0FBQ29DLE1BQU0sRUFBRVUsSUFBSSxDQUFDLEdBQUdWLE1BQU0sQ0FBQ1UsSUFBSSxDQUFDO0FBQ3pFIiwiZmlsZSI6ImNvbXBvbmVudHMvUHJvRm9ybS9jb3JlL3BhdGhVdGlscy5qcyIsInNvdXJjZXNDb250ZW50IjpbbnVsbF0sInNvdXJjZVJvb3QiOiIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMifQ==
|
|
@@ -9,14 +9,14 @@ export interface RuleRunResult {
|
|
|
9
9
|
* a non-empty Error.message or a non-empty plain string — otherwise null
|
|
10
10
|
* (caller picks its fallback). Shared with the form-level last-resort nets.
|
|
11
11
|
*/
|
|
12
|
-
export declare function coerceFailureReason(reason:
|
|
12
|
+
export declare function coerceFailureReason(reason: any): ReactNode | null;
|
|
13
13
|
/**
|
|
14
14
|
* Resolve function-form rules into static rules. The
|
|
15
15
|
* context exposes the value snapshot the run was invoked with; function rules
|
|
16
16
|
* must be cheap and side-effect free — they may be resolved more than once
|
|
17
17
|
* per validation pass.
|
|
18
18
|
*/
|
|
19
|
-
export declare function resolveRules(rules: FormRule[], values:
|
|
19
|
+
export declare function resolveRules<Values = Record<string, any>>(rules: FormRule<Values>[], values: Values, instance?: Partial<RuleContext<Values>>): Rule[];
|
|
20
20
|
/**
|
|
21
21
|
* Normalize a form/item-level validateTrigger config into the effective
|
|
22
22
|
* interactive event list: item-level (when present) overrides form-level;
|
|
@@ -38,20 +38,11 @@ export declare function normalizeTriggers(itemTrigger: ValidateTriggerProp | und
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function filterRulesByTrigger(rules: Rule[], trigger: ValidateTrigger, activeTriggers: ValidateTrigger[], fieldName?: string): Rule[];
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* swallowed) and left to the async runs (blur/submit), which always await it.
|
|
44
|
-
* Failing it instead would mis-report "Validation failed" on every keystroke
|
|
45
|
-
* for perfectly valid input.
|
|
41
|
+
* Rule run. Custom validators are awaited (sync or async): resolving passes,
|
|
42
|
+
* rejecting/throwing fails. Return values are ignored.
|
|
46
43
|
*
|
|
47
|
-
* The per-rule try/catch is the
|
|
48
|
-
*
|
|
49
|
-
*
|
|
44
|
+
* The per-rule try/catch is the totality choke point: NO input — including
|
|
45
|
+
* exotic values that break a builtin check — may escape as a throw; every
|
|
46
|
+
* failure surfaces through the error/warning channels.
|
|
50
47
|
*/
|
|
51
|
-
export declare function
|
|
52
|
-
/**
|
|
53
|
-
* Asynchronous rule run. Custom validators are awaited (sync or async):
|
|
54
|
-
* resolving passes, rejecting/throwing fails. Return values are ignored.
|
|
55
|
-
* Shares the totality choke point with runRulesSync.
|
|
56
|
-
*/
|
|
57
|
-
export declare function runRulesAsync(name: string, value: unknown, values: Record<string, unknown>, rules: FormRule[], instance?: Partial<RuleContext>): Promise<RuleRunResult>;
|
|
48
|
+
export declare function runRulesAsync<Values = Record<string, any>>(name: string, value: any, values: Values, rules: FormRule<Values>[], instance?: Partial<RuleContext<Values>>): Promise<RuleRunResult>;
|