@1money/component-ui 0.0.75 → 0.0.77

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.
Files changed (153) hide show
  1. package/es/components/ProForm/ProForm.d.ts +1 -1
  2. package/es/components/ProForm/ProForm.js +46 -34
  3. package/es/components/ProForm/ProFormDependency.d.ts +2 -1
  4. package/es/components/ProForm/ProFormDependency.js +6 -16
  5. package/es/components/ProForm/ProFormItem.d.ts +7 -2
  6. package/es/components/ProForm/ProFormItem.js +5 -7
  7. package/es/components/ProForm/ProFormList.d.ts +6 -1
  8. package/es/components/ProForm/ProFormList.js +122 -42
  9. package/es/components/ProForm/SchemaForm.d.ts +1 -1
  10. package/es/components/ProForm/SchemaForm.js +8 -5
  11. package/es/components/ProForm/context.d.ts +8 -7
  12. package/es/components/ProForm/context.js +1 -1
  13. package/es/components/ProForm/core/constants.d.ts +3 -1
  14. package/es/components/ProForm/core/constants.js +8 -2
  15. package/es/components/ProForm/core/devWarning.d.ts +3 -0
  16. package/es/components/ProForm/core/devWarning.js +22 -0
  17. package/es/components/ProForm/core/formStore.d.ts +14 -6
  18. package/es/components/ProForm/core/formStore.js +21 -2
  19. package/es/components/ProForm/core/hooks/useForm.d.ts +1 -1
  20. package/es/components/ProForm/core/hooks/useForm.js +275 -107
  21. package/es/components/ProForm/core/hooks/useFormCore.d.ts +2 -2
  22. package/es/components/ProForm/core/hooks/useFormCore.js +121 -121
  23. package/es/components/ProForm/core/interface.d.ts +157 -103
  24. package/es/components/ProForm/core/namePathType.d.ts +25 -0
  25. package/es/components/ProForm/core/namePathType.js +2 -0
  26. package/es/components/ProForm/core/pathUtils.d.ts +5 -3
  27. package/es/components/ProForm/core/pathUtils.js +19 -1
  28. package/es/components/ProForm/core/runRules.d.ts +40 -17
  29. package/es/components/ProForm/core/runRules.js +480 -136
  30. package/es/components/ProForm/core/useFormItem.d.ts +7 -8
  31. package/es/components/ProForm/core/useFormItem.js +52 -82
  32. package/es/components/ProForm/core/validationError.d.ts +13 -0
  33. package/es/components/ProForm/core/validationError.js +29 -0
  34. package/es/components/ProForm/fields/ProFormCheckbox.d.ts +1 -1
  35. package/es/components/ProForm/fields/ProFormCheckboxGroup.d.ts +1 -1
  36. package/es/components/ProForm/fields/ProFormCheckboxGroup.js +19 -5
  37. package/es/components/ProForm/fields/ProFormDatePicker.d.ts +1 -1
  38. package/es/components/ProForm/fields/ProFormDatePicker.js +1 -1
  39. package/es/components/ProForm/fields/ProFormFieldSet.d.ts +7 -2
  40. package/es/components/ProForm/fields/ProFormFieldSet.js +49 -12
  41. package/es/components/ProForm/fields/ProFormPassword.d.ts +1 -1
  42. package/es/components/ProForm/fields/ProFormRadioGroup.d.ts +1 -1
  43. package/es/components/ProForm/fields/ProFormRadioGroup.js +8 -3
  44. package/es/components/ProForm/fields/ProFormSelect.d.ts +1 -1
  45. package/es/components/ProForm/fields/ProFormSelect.js +13 -7
  46. package/es/components/ProForm/fields/ProFormSlider.d.ts +1 -1
  47. package/es/components/ProForm/fields/ProFormSwitch.d.ts +1 -1
  48. package/es/components/ProForm/fields/ProFormText.d.ts +1 -1
  49. package/es/components/ProForm/fields/ProFormTextArea.d.ts +1 -1
  50. package/es/components/ProForm/fields/ProFormUpload.d.ts +1 -1
  51. package/es/components/ProForm/fields/ProFormUpload.js +1 -1
  52. package/es/components/ProForm/fields/createProFormField.d.ts +8 -2
  53. package/es/components/ProForm/fields/createProFormField.js +20 -27
  54. package/es/components/ProForm/hooks/useFieldRequest.d.ts +1 -1
  55. package/es/components/ProForm/hooks/useFieldRequest.js +10 -8
  56. package/es/components/ProForm/hooks/useUrlSync.d.ts +8 -7
  57. package/es/components/ProForm/hooks/useUrlSync.js +1 -1
  58. package/es/components/ProForm/index.d.ts +37 -27
  59. package/es/components/ProForm/index.js +4 -1
  60. package/es/components/ProForm/interface.d.ts +115 -119
  61. package/es/components/ProForm/layouts/DialogForm.d.ts +1 -1
  62. package/es/components/ProForm/layouts/DialogForm.js +1 -1
  63. package/es/components/ProForm/layouts/DrawerForm.d.ts +1 -1
  64. package/es/components/ProForm/layouts/DrawerForm.js +1 -1
  65. package/es/components/ProForm/layouts/QueryFilter.d.ts +1 -1
  66. package/es/components/ProForm/layouts/QueryFilter.js +24 -16
  67. package/es/components/ProForm/layouts/useOverlayForm.d.ts +2 -2
  68. package/es/components/ProForm/layouts/useOverlayForm.js +1 -1
  69. package/es/components/ProForm/utils.d.ts +15 -7
  70. package/es/components/ProForm/utils.js +51 -3
  71. package/es/components/Table/core/useTableSetup.js +2 -2
  72. package/es/components/Table/interface.d.ts +1 -1
  73. package/es/index.css +1 -1
  74. package/es/index.d.ts +1 -1
  75. package/es/index.js +1 -1
  76. package/lib/components/ProForm/ProForm.d.ts +1 -1
  77. package/lib/components/ProForm/ProForm.js +45 -33
  78. package/lib/components/ProForm/ProFormDependency.d.ts +2 -1
  79. package/lib/components/ProForm/ProFormDependency.js +5 -15
  80. package/lib/components/ProForm/ProFormItem.d.ts +7 -2
  81. package/lib/components/ProForm/ProFormItem.js +5 -7
  82. package/lib/components/ProForm/ProFormList.d.ts +6 -1
  83. package/lib/components/ProForm/ProFormList.js +120 -40
  84. package/lib/components/ProForm/SchemaForm.d.ts +1 -1
  85. package/lib/components/ProForm/SchemaForm.js +8 -5
  86. package/lib/components/ProForm/context.d.ts +8 -7
  87. package/lib/components/ProForm/context.js +1 -1
  88. package/lib/components/ProForm/core/constants.d.ts +3 -1
  89. package/lib/components/ProForm/core/constants.js +9 -3
  90. package/lib/components/ProForm/core/devWarning.d.ts +3 -0
  91. package/lib/components/ProForm/core/devWarning.js +29 -0
  92. package/lib/components/ProForm/core/formStore.d.ts +14 -6
  93. package/lib/components/ProForm/core/formStore.js +23 -2
  94. package/lib/components/ProForm/core/hooks/useForm.d.ts +1 -1
  95. package/lib/components/ProForm/core/hooks/useForm.js +271 -103
  96. package/lib/components/ProForm/core/hooks/useFormCore.d.ts +2 -2
  97. package/lib/components/ProForm/core/hooks/useFormCore.js +119 -119
  98. package/lib/components/ProForm/core/interface.d.ts +157 -103
  99. package/lib/components/ProForm/core/namePathType.d.ts +25 -0
  100. package/lib/components/ProForm/core/namePathType.js +6 -0
  101. package/lib/components/ProForm/core/pathUtils.d.ts +5 -3
  102. package/lib/components/ProForm/core/pathUtils.js +20 -1
  103. package/lib/components/ProForm/core/runRules.d.ts +40 -17
  104. package/lib/components/ProForm/core/runRules.js +483 -137
  105. package/lib/components/ProForm/core/useFormItem.d.ts +7 -8
  106. package/lib/components/ProForm/core/useFormItem.js +54 -84
  107. package/lib/components/ProForm/core/validationError.d.ts +13 -0
  108. package/lib/components/ProForm/core/validationError.js +36 -0
  109. package/lib/components/ProForm/fields/ProFormCheckbox.d.ts +1 -1
  110. package/lib/components/ProForm/fields/ProFormCheckboxGroup.d.ts +1 -1
  111. package/lib/components/ProForm/fields/ProFormCheckboxGroup.js +18 -4
  112. package/lib/components/ProForm/fields/ProFormDatePicker.d.ts +1 -1
  113. package/lib/components/ProForm/fields/ProFormDatePicker.js +1 -1
  114. package/lib/components/ProForm/fields/ProFormFieldSet.d.ts +7 -2
  115. package/lib/components/ProForm/fields/ProFormFieldSet.js +49 -12
  116. package/lib/components/ProForm/fields/ProFormPassword.d.ts +1 -1
  117. package/lib/components/ProForm/fields/ProFormRadioGroup.d.ts +1 -1
  118. package/lib/components/ProForm/fields/ProFormRadioGroup.js +7 -2
  119. package/lib/components/ProForm/fields/ProFormSelect.d.ts +1 -1
  120. package/lib/components/ProForm/fields/ProFormSelect.js +13 -7
  121. package/lib/components/ProForm/fields/ProFormSlider.d.ts +1 -1
  122. package/lib/components/ProForm/fields/ProFormSwitch.d.ts +1 -1
  123. package/lib/components/ProForm/fields/ProFormText.d.ts +1 -1
  124. package/lib/components/ProForm/fields/ProFormTextArea.d.ts +1 -1
  125. package/lib/components/ProForm/fields/ProFormUpload.d.ts +1 -1
  126. package/lib/components/ProForm/fields/ProFormUpload.js +1 -1
  127. package/lib/components/ProForm/fields/createProFormField.d.ts +8 -2
  128. package/lib/components/ProForm/fields/createProFormField.js +20 -27
  129. package/lib/components/ProForm/hooks/useFieldRequest.d.ts +1 -1
  130. package/lib/components/ProForm/hooks/useFieldRequest.js +10 -8
  131. package/lib/components/ProForm/hooks/useUrlSync.d.ts +8 -7
  132. package/lib/components/ProForm/hooks/useUrlSync.js +1 -1
  133. package/lib/components/ProForm/index.d.ts +37 -27
  134. package/lib/components/ProForm/index.js +10 -1
  135. package/lib/components/ProForm/interface.d.ts +115 -119
  136. package/lib/components/ProForm/layouts/DialogForm.d.ts +1 -1
  137. package/lib/components/ProForm/layouts/DialogForm.js +1 -1
  138. package/lib/components/ProForm/layouts/DrawerForm.d.ts +1 -1
  139. package/lib/components/ProForm/layouts/DrawerForm.js +1 -1
  140. package/lib/components/ProForm/layouts/QueryFilter.d.ts +1 -1
  141. package/lib/components/ProForm/layouts/QueryFilter.js +24 -16
  142. package/lib/components/ProForm/layouts/useOverlayForm.d.ts +2 -2
  143. package/lib/components/ProForm/layouts/useOverlayForm.js +1 -1
  144. package/lib/components/ProForm/utils.d.ts +15 -7
  145. package/lib/components/ProForm/utils.js +52 -3
  146. package/lib/components/Table/core/useTableSetup.js +2 -2
  147. package/lib/components/Table/interface.d.ts +1 -1
  148. package/lib/index.css +1 -1
  149. package/lib/index.d.ts +1 -1
  150. package/lib/index.js +1 -1
  151. package/package.json +1 -1
  152. package/scripts/mcp-server/examples.generated.json +95 -53
  153. package/scripts/mcp-server/index.generated.json +1715 -185
@@ -1,174 +1,228 @@
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';
5
+ import { RULE_CONTEXT_READ_MEMBERS, RULE_CONTEXT_MUTATOR_MEMBERS } from './constants';
4
6
  export type { FormSize, FormLayout, LabelAlign, ValidateStatus, ValidateTrigger, };
7
+ export type { ProFormFieldName, ProFormFieldValueMap, ProFormPathValue, ProFormRecursivePartial, ProFormValuesPatch, } from './namePathType';
8
+ /** Built-in `type` check names. */
9
+ export type RuleType = 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'object' | 'array' | 'date' | 'url' | 'hex' | 'email' | 'enum';
5
10
  export interface Rule {
6
11
  /** Fails on undefined / null / '' / empty array */
7
12
  required?: boolean;
8
- message?: string;
13
+ /** Error content shown on failure — any ReactNode (falls back to a generated string) */
14
+ message?: ReactNode;
9
15
  /** For strings: min length; arrays: min item count; numbers: min value */
10
16
  min?: number;
11
17
  /** For strings: max length; arrays: max item count; numbers: max value */
12
18
  max?: number;
19
+ /** Exact string length / array item count / numeric value. Takes precedence over min/max */
20
+ len?: number;
13
21
  pattern?: RegExp;
14
- type?: 'number' | 'email' | 'url';
15
- enum?: unknown[];
22
+ type?: RuleType;
23
+ enum?: any[];
24
+ /** Fails a non-empty string consisting only of whitespace */
25
+ whitespace?: boolean;
26
+ /** Transform the value before every check (builtin and validator) of THIS rule */
27
+ transform?: (value: any) => any;
28
+ /** Deep rule(s) applied to every member of an array/object value */
29
+ defaultField?: Rule | Rule[];
30
+ /** Deep rules applied per key of an object/array value */
31
+ fields?: Record<string, Rule | Rule[]>;
16
32
  /** A failing rule produces a non-blocking warning instead of an error */
17
33
  warningOnly?: boolean;
18
34
  /**
19
- * Run this rule only on the given interactive trigger(s); rules without it
20
- * follow the form-level validateTrigger. Submit always runs every rule.
35
+ * Run this rule only on the given interactive event(s). It
36
+ * must be a subset of the item's effective triggers to fire interactively.
37
+ * Rules without it run on every effective trigger. Submit always runs
38
+ * every rule.
21
39
  */
22
40
  validateTrigger?: ValidateTrigger | ValidateTrigger[];
23
- validator?: (value: unknown, values: Record<string, unknown>) => boolean | string | Promise<boolean | string>;
41
+ /**
42
+ * Custom validator: resolve (or return undefined) to pass,
43
+ * reject/throw to fail. The failure message is taken from the rejection
44
+ * (Error.message or a plain string), then `rule.message`, then a generic
45
+ * fallback. Return values are ignored — returning `false` or a string does
46
+ * NOT fail the rule.
47
+ */
48
+ validator?: (rule: Rule, value: any) => Promise<void> | void;
24
49
  }
50
+ /**
51
+ * Form/Item-level validateTrigger config: a single event, a
52
+ * list of events, or `false` to disable interactive validation entirely
53
+ * (submit / validateFields still run every rule). Item-level overrides
54
+ * form-level.
55
+ */
56
+ export type ValidateTriggerProp = ValidateTrigger | ValidateTrigger[] | false;
57
+ /**
58
+ * The form context handed to function-form rules. The read helpers are
59
+ * always available (derived from the validation-time value snapshot). The
60
+ * remaining members are backed by the live form instance and are present
61
+ * whenever rules run inside a mounted form — they are only absent when the
62
+ * pure rule engine is invoked directly without an instance.
63
+ */
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;
69
+ resetFields?: () => void;
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;
74
+ }
75
+ /**
76
+ * A rule entry as consumers write it: a static Rule, or — for cross-field
77
+ * validation — a function of the form context returning a Rule (the
78
+ * `({ getFieldValue }) => ({ validator })` idiom).
79
+ */
80
+ export type FormRule<Values = Record<string, any>> = Rule | ((ctx: RuleContext<Values>) => Rule);
81
+ export type RuleContextReadMember = (typeof RULE_CONTEXT_READ_MEMBERS)[number];
82
+ export type RuleContextMutatorMember = (typeof RULE_CONTEXT_MUTATOR_MEMBERS)[number];
83
+ type AssertRuleContextMembers<T extends keyof RuleContext> = T;
84
+ /**
85
+ * Compile-time guard: the member lists in constants.ts must stay subsets of
86
+ * RuleContext — renaming or removing a member there breaks this line.
87
+ */
88
+ export type RuleContextInstanceMember = AssertRuleContextMembers<RuleContextReadMember | RuleContextMutatorMember>;
25
89
  export interface FieldProps {
26
90
  name: string;
27
- value: unknown;
28
- error?: string;
91
+ value: any;
92
+ error?: ReactNode;
29
93
  touched?: boolean;
30
94
  validating?: boolean;
31
- onChange: (value: unknown) => void;
95
+ onChange: (value: any) => void;
32
96
  onBlur: () => void;
33
97
  }
34
98
  export interface FieldOptions {
35
- rules?: Rule[];
36
- validateTrigger?: ValidateTrigger;
99
+ rules?: FormRule[];
100
+ validateTrigger?: ValidateTriggerProp;
37
101
  }
38
102
  export interface FieldComponentProps {
39
103
  children: ReactNode | ((props: FieldProps) => ReactNode);
40
104
  render?: (props: FieldProps) => ReactNode;
41
105
  }
42
106
  /** Lightweight form instance returned by useFormCore */
43
- export interface FormCoreInstance {
44
- submit: () => {
45
- success: boolean;
46
- values?: Record<string, unknown>;
47
- errors?: Record<string, string>;
48
- };
107
+ export interface FormCoreInstance<Values = Record<string, any>> {
49
108
  resetFields: () => void;
50
- getFieldValue: (name: string) => unknown;
51
- getFieldsValue: () => Record<string, unknown>;
52
- setFieldsValue: (values: Record<string, unknown>) => void;
53
- setFieldValue: (name: string, value: unknown) => void;
54
- validateFields: (fieldsRules?: Record<string, Rule[]>) => 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;
55
113
  }
56
114
  /**
57
115
  * Full form instance returned by useForm — extends FormCoreInstance with async
58
116
  * validation, field helpers, etc. `Values` types the whole-form value shape
59
117
  * (defaults to an open record for backward compatibility).
60
118
  */
61
- export interface FormInstance<Values = Record<string, unknown>> {
62
- getFieldValue: (name: string) => unknown;
63
- getFieldsValue: (nameList?: string[]) => Values;
64
- setFieldValue: (name: string, value: unknown) => void;
65
- setFieldsValue: (values: Partial<Values>) => void;
66
- setFieldError: (name: string, error: string | null) => void;
67
- setFieldsError: (errors: Record<string, string>) => void;
68
- resetFields: (fields?: string[]) => void;
69
- validateFields: (nameList?: string[]) => Promise<Values>;
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;
128
+ setFieldsError: (errors: Record<string, ReactNode>) => void;
129
+ resetFields: (fields?: ProFormFieldName<Values>[]) => void;
130
+ validateFields: {
131
+ (): Promise<Values>;
132
+ <Name extends ProFormFieldName<Values>>(nameList: Name[]): Promise<ProFormFieldValueMap<Values, Name>>;
133
+ };
70
134
  submit: (callback?: (values: Values) => void | Promise<void>) => Promise<Values | undefined>;
71
- getFieldError: (name: string) => string | undefined;
72
- getFieldsError: (nameList?: string[]) => Record<string, string>;
73
- getFieldWarning: (name: string) => string | undefined;
74
- isFieldTouched: (name: string) => boolean;
75
- isFieldsTouched: (nameList?: string[], allTouched?: boolean) => boolean;
76
- isFieldValidating: (name: string) => boolean;
77
- setFieldTouched: (name: string, isTouched?: boolean) => void;
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;
78
142
  setFieldsTouched: (touched: Record<string, boolean>) => void;
79
143
  defineField: (name: string, options?: FieldOptions) => FC<FieldComponentProps>;
80
- registerField: (name: string, rules: Rule[]) => void;
144
+ registerField: (name: string, rules: FormRule<Values>[]) => void;
81
145
  unregisterField: (name: string) => void;
82
146
  }
83
147
  export interface UseFormOptions {
84
- onValuesChange?: (changedValues: Record<string, unknown>, allValues: Record<string, unknown>) => void;
85
- validateTrigger?: ValidateTrigger;
86
- rules?: Record<string, Rule[]>;
148
+ onValuesChange?: (changedValues: Record<string, any>, allValues: Record<string, any>) => void;
149
+ validateTrigger?: ValidateTriggerProp;
150
+ rules?: Record<string, FormRule[]>;
87
151
  }
88
- export interface UseFormCoreConfig<Values = Record<string, unknown>> {
89
- initialValues?: Partial<Values>;
152
+ export interface UseFormCoreConfig<Values = Record<string, any>> {
153
+ initialValues?: ProFormRecursivePartial<Values>;
90
154
  onFinish?: (values: Values) => void;
91
155
  onFinishFailed?: (errorInfo: {
92
156
  values: Values;
93
- errors: Record<string, string>;
157
+ errors: Record<string, ReactNode>;
94
158
  }) => void;
95
- onValuesChange?: (changedValues: Partial<Values>, allValues: Values) => void;
159
+ onValuesChange?: (changedValues: ProFormValuesPatch<Values>, allValues: Values) => void;
96
160
  onReset?: () => void;
97
161
  size?: FormSize;
98
162
  labelAlign?: LabelAlign;
99
163
  disabled?: boolean;
100
- colon?: boolean;
101
- requiredMark?: boolean;
102
- validateTrigger?: ValidateTrigger;
103
- }
104
- /** Internal shape of data produced by useFormCore, consumed by ProForm to build ProFormContext */
105
- export interface FormCoreContextShape {
106
- values: Record<string, unknown>;
107
- errors: Record<string, string>;
108
- warnings: Record<string, string>;
109
- touched: Record<string, boolean>;
110
- formInstance: FormCoreInstance;
111
- setFieldValue: (name: string, value: unknown) => void;
112
- setFieldError: (name: string, error: string | null) => void;
113
- setFieldWarning: (name: string, warning: string | null) => void;
114
- validateField: (name: string, rules: Rule[], providedValue?: unknown) => boolean;
115
- registerField: (name: string, rules: Rule[]) => void;
116
- unregisterField: (name: string) => void;
117
- size: FormSize;
118
- labelAlign: LabelAlign;
119
- disabled: boolean;
120
- colon: boolean;
121
- requiredMark: boolean;
122
- validateTrigger: ValidateTrigger;
164
+ validateTrigger?: ValidateTriggerProp;
123
165
  }
124
166
  /** Config for useForm — accepts all UseFormCoreConfig fields */
125
- export type UseFormConfig<Values = Record<string, unknown>> = UseFormCoreConfig<Values>;
167
+ export type UseFormConfig<Values = Record<string, any>> = UseFormCoreConfig<Values>;
126
168
  /** Internal state exposed by useForm for ProForm integration */
127
- export interface UseFormInternals {
128
- values: Record<string, unknown>;
129
- errors: Record<string, string>;
130
- warnings: Record<string, string>;
169
+ export interface UseFormInternals<Values = Record<string, any>> {
170
+ values: Record<string, any>;
171
+ errors: Record<string, ReactNode>;
172
+ warnings: Record<string, ReactNode>;
131
173
  touched: Record<string, boolean>;
132
174
  validating: Record<string, boolean>;
133
- fieldRules: Record<string, Rule[]>;
134
- setFieldValue: (name: string, value: unknown) => void;
135
- setFieldError: (name: string, error: string | null) => void;
136
- setFieldWarning: (name: string, warning: string | null) => void;
137
- validateField: (name: string, rules: Rule[], providedValue?: unknown) => boolean;
138
- validateFieldAsync: (name: string, value: unknown, rules: Rule[]) => Promise<{
175
+ fieldRules: Record<string, FormRule<Values>[]>;
176
+ setFieldValue: (name: string, value: any) => void;
177
+ setFieldError: (name: string, error: ReactNode | null) => void;
178
+ setFieldWarning: (name: string, warning: ReactNode | null) => void;
179
+ validateFieldAsync: (name: string, value: any, rules: FormRule<Values>[]) => Promise<{
139
180
  isValid: boolean;
140
- error: string | null;
181
+ error: ReactNode | null;
141
182
  }>;
142
- registerField: (name: string, rules: Rule[]) => void;
183
+ registerField: (name: string, rules: FormRule<Values>[]) => void;
143
184
  unregisterField: (name: string) => void;
185
+ /** Count a mounted instance for `name` — pair with `releaseField` on unmount. */
186
+ retainField: (name: string) => void;
187
+ /** Drop one instance count; the field's rules are removed only at zero. */
188
+ releaseField: (name: string) => void;
144
189
  handleSubmit: (e?: React.FormEvent) => void;
145
190
  handleReset: (e?: React.FormEvent) => void;
146
191
  }
147
192
  /** Return type for useForm */
148
- export interface UseFormReturn {
149
- formInstance: FormInstance;
150
- internals: UseFormInternals;
193
+ export interface UseFormReturn<Values = Record<string, any>> {
194
+ formInstance: FormInstance<Values>;
195
+ internals: UseFormInternals<Values>;
151
196
  }
152
- export interface UseFormCoreReturn {
153
- values: Record<string, unknown>;
154
- errors: Record<string, string>;
155
- warnings: Record<string, string>;
197
+ export interface UseFormCoreReturn<Values = Record<string, any>> {
198
+ values: Record<string, any>;
199
+ errors: Record<string, ReactNode>;
200
+ warnings: Record<string, ReactNode>;
156
201
  touched: Record<string, boolean>;
157
- fieldRules: Record<string, Rule[]>;
158
- getFieldRules: (name: string) => Rule[] | undefined;
159
- setFieldValue: (name: string, value: unknown) => void;
160
- setFieldError: (name: string, error: string | null) => void;
161
- setFieldWarning: (name: string, warning: string | null) => void;
162
- setFieldsValue: (values: Record<string, unknown>) => void;
163
- getFieldValue: (name: string) => unknown;
164
- getFieldsValue: () => Record<string, unknown>;
165
- validateField: (name: string, rules: Rule[], providedValue?: unknown) => boolean;
166
- validateFields: (fieldsRules?: Record<string, Rule[]>) => boolean;
167
- registerField: (name: string, rules: Rule[]) => void;
202
+ fieldRules: Record<string, FormRule<Values>[]>;
203
+ getFieldRules: (name: string) => FormRule<Values>[] | undefined;
204
+ /** Instance handed to function-form rules; useForm upgrades it to the full form instance. */
205
+ getRuleContextInstance: () => Partial<RuleContext<Values>>;
206
+ setRuleContextInstance: (instance: Partial<RuleContext<Values>>) => void;
207
+ /** Bump and return the field's validation epoch — every run captures one. */
208
+ beginValidationRun: (name: string) => number;
209
+ /** True while no newer run has started for the field since `epoch` was issued. */
210
+ isValidationRunCurrent: (name: string, epoch: number) => boolean;
211
+ /** Invalidate in-flight runs (all fields, or the given ones) e.g. on reset. */
212
+ invalidateValidationRuns: (names?: string[]) => void;
213
+ setFieldValue: (name: string, value: any) => void;
214
+ setFieldError: (name: string, error: ReactNode | null) => void;
215
+ setFieldWarning: (name: string, warning: ReactNode | null) => void;
216
+ setFieldsValue: (values: ProFormValuesPatch<Values>) => void;
217
+ getFieldValue: (name: string) => any;
218
+ getFieldsValue: () => Values;
219
+ registerField: (name: string, rules: FormRule<Values>[]) => void;
168
220
  unregisterField: (name: string) => void;
169
- handleSubmit: (e?: React.FormEvent) => void;
221
+ /** Count a mounted instance for `name` — pair with `releaseField` on unmount. */
222
+ retainField: (name: string) => void;
223
+ /** Drop one instance count; the field's rules are removed only at zero. */
224
+ releaseField: (name: string) => void;
170
225
  handleReset: (e?: React.FormEvent) => void;
171
226
  resetFields: () => void;
172
- formInstance: FormCoreInstance;
173
- coreContextShape: FormCoreContextShape;
227
+ formInstance: FormCoreInstance<Values>;
174
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,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9uZW50cy9Qcm9Gb3JtL2NvcmUvbmFtZVBhdGhUeXBlLmpzIiwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjIiwic291cmNlcyI6WyJjb21wb25lbnRzL1Byb0Zvcm0vY29yZS9uYW1lUGF0aFR5cGUuanMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHt9OyJdLCJtYXBwaW5ncyI6IiIsImlnbm9yZUxpc3QiOltdfQ==
@@ -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, unknown>, path: string): unknown;
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, unknown>, path: string, value: unknown): Record<string, unknown>;
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, unknown>, name: string): unknown;
8
+ export declare function resolveValue(values: Record<string, any>, name: string): any;
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.getNestedValue = getNestedValue;
8
+ exports.mergeValuesPatch = mergeValuesPatch;
8
9
  exports.resolveValue = resolveValue;
9
10
  exports.setNestedValue = setNestedValue;
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
14
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
@@ -61,8 +63,25 @@ function setNestedValue(obj, path, value) {
61
63
  current[keys[keys.length - 1]] = value;
62
64
  return result;
63
65
  }
66
+ function isPlainObject(value) {
67
+ if (value === null || (0, _typeof2["default"])(value) !== 'object') return false;
68
+ var prototype = Object.getPrototypeOf(value);
69
+ return prototype === Object.prototype || prototype === null;
70
+ }
71
+ /** Immutably deep-merge a form values patch. Arrays and non-plain objects replace. */
72
+ function mergeValuesPatch(values, patch) {
73
+ var result = Object.assign({}, values);
74
+ for (var _i = 0, _Object$entries = Object.entries(patch); _i < _Object$entries.length; _i++) {
75
+ var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
76
+ key = _Object$entries$_i[0],
77
+ patchValue = _Object$entries$_i[1];
78
+ var currentValue = result[key];
79
+ result[key] = isPlainObject(currentValue) && isPlainObject(patchValue) ? mergeValuesPatch(currentValue, patchValue) : patchValue;
80
+ }
81
+ return result;
82
+ }
64
83
  /** Read a field value, taking the fast path for flat (non-dotted) names. */
65
84
  function resolveValue(values, name) {
66
85
  return name.includes('.') ? getNestedValue(values, name) : values[name];
67
86
  }
68
- //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvUHJvRm9ybS9zcmMvY29tcG9uZW50cy9Qcm9Gb3JtL2NvcmUvcGF0aFV0aWxzLnRzIl0sIm5hbWVzIjpbImdldE5lc3RlZFZhbHVlIiwib2JqIiwicGF0aCIsImtleXMiLCJzcGxpdCIsImN1cnJlbnQiLCJfaXRlcmF0b3IiLCJfY3JlYXRlRm9yT2ZJdGVyYXRvckhlbHBlciIsIl9zdGVwIiwicyIsIm4iLCJkb25lIiwia2V5IiwidmFsdWUiLCJ1bmRlZmluZWQiLCJfdHlwZW9mMiIsImVyciIsImUiLCJmIiwic2V0TmVzdGVkVmFsdWUiLCJsZW5ndGgiLCJPYmplY3QiLCJhc3NpZ24iLCJfZGVmaW5lUHJvcGVydHkyIiwicmVzdWx0IiwiaSIsIm5leHRLZXkiLCJpc05leHRBcnJheSIsInRlc3QiLCJBcnJheSIsImlzQXJyYXkiLCJfdG9Db25zdW1hYmxlQXJyYXkyIiwicmVzb2x2ZVZhbHVlIiw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29DLE1BQU0sRUFBRVUsSUFBSSxDQUFDLEdBQUdWLE1BQU0sQ0FBQ1UsSUFBSSxDQUFDO0FBQ3pFIiwiZmlsZSI6ImNvbXBvbmVudHMvUHJvRm9ybS9jb3JlL3BhdGhVdGlscy5qcyIsInNvdXJjZXNDb250ZW50IjpbbnVsbF0sInNvdXJjZVJvb3QiOiIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMifQ==
@@ -1,25 +1,48 @@
1
- import type { Rule, ValidateTrigger } from './interface';
1
+ import type { ReactNode } from 'react';
2
+ import type { FormRule, Rule, RuleContext, ValidateTrigger, ValidateTriggerProp } from './interface';
2
3
  export interface RuleRunResult {
3
- error: string | null;
4
- warning: string | null;
4
+ error: ReactNode | null;
5
+ warning: ReactNode | null;
5
6
  }
6
7
  /**
7
- * Filter rules applicable to an interactive trigger. A rule WITHOUT an
8
- * explicit `validateTrigger` follows the form-level trigger; a rule WITH one
9
- * runs on exactly those trigger(s), regardless of the form-level setting.
10
- * Submit-time validation bypasses this filter and runs every rule.
8
+ * Coerce a thrown/rejected reason into displayable failure content:
9
+ * a non-empty Error.message or a non-empty plain string otherwise null
10
+ * (caller picks its fallback). Shared with the form-level last-resort nets.
11
11
  */
12
- export declare function filterRulesByTrigger(rules: Rule[], trigger: ValidateTrigger, formTrigger: ValidateTrigger): Rule[];
12
+ export declare function coerceFailureReason(reason: any): ReactNode | null;
13
13
  /**
14
- * Synchronous rule run. A Promise-returning validator CANNOT be evaluated
15
- * here it is deferred (treated as passing for this run; its rejection is
16
- * swallowed) and left to the async runs (blur/submit), which always await it.
17
- * Failing it instead would mis-report "Validation failed" on every keystroke
18
- * for perfectly valid input.
14
+ * Resolve function-form rules into static rules. The
15
+ * context exposes the value snapshot the run was invoked with; function rules
16
+ * must be cheap and side-effect free they may be resolved more than once
17
+ * per validation pass.
19
18
  */
20
- export declare function runRulesSync(name: string, value: unknown, values: Record<string, unknown>, rules: Rule[]): RuleRunResult;
19
+ export declare function resolveRules<Values = Record<string, any>>(rules: FormRule<Values>[], values: Values, instance?: Partial<RuleContext<Values>>): Rule[];
21
20
  /**
22
- * Asynchronous rule run. Custom validators are awaited (sync or async). A
23
- * validator returning `undefined` is treated as passing.
21
+ * Normalize a form/item-level validateTrigger config into the effective
22
+ * interactive event list: item-level (when present) overrides form-level;
23
+ * `false` disables interactive validation entirely.
24
24
  */
25
- export declare function runRulesAsync(name: string, value: unknown, values: Record<string, unknown>, rules: Rule[]): Promise<RuleRunResult>;
25
+ export declare function normalizeTriggers(itemTrigger: ValidateTriggerProp | undefined, formTrigger: ValidateTriggerProp): ValidateTrigger[];
26
+ /**
27
+ * Filter rules applicable to an interactive event: the event
28
+ * validates only when it is in the item's effective trigger set. Within the
29
+ * set, a rule WITHOUT `validateTrigger` runs on every event; a rule WITH one
30
+ * runs only on matching events — so a rule trigger outside the item's set
31
+ * never fires interactively. Submit-time validation bypasses this filter and
32
+ * runs every rule.
33
+ *
34
+ * Dev guard: a rule whose (non-empty) trigger set is fully OUTSIDE the
35
+ * active set can never fire interactively — usually a leftover of the
36
+ * pre-0.0.76 override semantics, so it warns once. `validateTrigger: []`
37
+ * is the deliberate submit-only idiom and stays silent.
38
+ */
39
+ export declare function filterRulesByTrigger(rules: Rule[], trigger: ValidateTrigger, activeTriggers: ValidateTrigger[], fieldName?: string): Rule[];
40
+ /**
41
+ * Rule run. Custom validators are awaited (sync or async): resolving passes,
42
+ * rejecting/throwing fails. Return values are ignored.
43
+ *
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.
47
+ */
48
+ export declare function runRulesAsync<Values = Record<string, any>>(name: string, value: any, values: Values, rules: FormRule<Values>[], instance?: Partial<RuleContext<Values>>): Promise<RuleRunResult>;