@octanejs/hook-form 0.1.0

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 (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/package.json +46 -0
  4. package/src/FormProvider.tsrx +76 -0
  5. package/src/FormProvider.tsrx.d.ts +10 -0
  6. package/src/constants.ts +31 -0
  7. package/src/controller.tsrx +8 -0
  8. package/src/controller.tsrx.d.ts +52 -0
  9. package/src/form.tsrx +119 -0
  10. package/src/form.tsrx.d.ts +6 -0
  11. package/src/formStateSubscribe.tsrx +10 -0
  12. package/src/formStateSubscribe.tsrx.d.ts +16 -0
  13. package/src/index.ts +19 -0
  14. package/src/logic/appendErrors.ts +19 -0
  15. package/src/logic/createFormControl.ts +1841 -0
  16. package/src/logic/generateId.ts +14 -0
  17. package/src/logic/generateWatchOutput.ts +27 -0
  18. package/src/logic/getCheckboxValue.ts +36 -0
  19. package/src/logic/getDirtyFields.ts +120 -0
  20. package/src/logic/getEventValue.ts +12 -0
  21. package/src/logic/getFieldValue.ts +33 -0
  22. package/src/logic/getFieldValueAs.ts +22 -0
  23. package/src/logic/getFocusFieldName.ts +13 -0
  24. package/src/logic/getNodeParentName.ts +4 -0
  25. package/src/logic/getProxyFormState.ts +33 -0
  26. package/src/logic/getRadioValue.ts +24 -0
  27. package/src/logic/getResolverOptions.ts +33 -0
  28. package/src/logic/getRuleValue.ts +16 -0
  29. package/src/logic/getValidateError.ts +22 -0
  30. package/src/logic/getValidationModes.ts +11 -0
  31. package/src/logic/getValueAndMessage.ts +12 -0
  32. package/src/logic/hasPromiseValidation.ts +27 -0
  33. package/src/logic/hasValidation.ts +12 -0
  34. package/src/logic/index.ts +3 -0
  35. package/src/logic/isNameInFieldArray.ts +7 -0
  36. package/src/logic/isWatched.ts +11 -0
  37. package/src/logic/iterateFieldsByAction.ts +37 -0
  38. package/src/logic/schemaErrorLookup.ts +54 -0
  39. package/src/logic/shouldRenderFormState.ts +25 -0
  40. package/src/logic/shouldSubscribeByName.ts +18 -0
  41. package/src/logic/skipValidation.ts +21 -0
  42. package/src/logic/unsetEmptyArray.ts +6 -0
  43. package/src/logic/updateFieldArrayRootError.ts +17 -0
  44. package/src/logic/validateField.ts +273 -0
  45. package/src/types/controller.ts +98 -0
  46. package/src/types/errors.ts +56 -0
  47. package/src/types/events.ts +26 -0
  48. package/src/types/fieldArray.ts +288 -0
  49. package/src/types/fields.ts +46 -0
  50. package/src/types/form.ts +961 -0
  51. package/src/types/index.ts +12 -0
  52. package/src/types/path/common.ts +391 -0
  53. package/src/types/path/eager.ts +224 -0
  54. package/src/types/path/index.ts +16 -0
  55. package/src/types/resolvers.ts +38 -0
  56. package/src/types/utils.ts +125 -0
  57. package/src/types/validator.ts +94 -0
  58. package/src/types/watch.ts +66 -0
  59. package/src/useController.ts +268 -0
  60. package/src/useFieldArray.ts +490 -0
  61. package/src/useForm.ts +182 -0
  62. package/src/useFormContext.ts +47 -0
  63. package/src/useFormControlContext.ts +25 -0
  64. package/src/useFormState.ts +86 -0
  65. package/src/useIsomorphicLayoutEffect.ts +6 -0
  66. package/src/useWatch.ts +356 -0
  67. package/src/utils/append.ts +4 -0
  68. package/src/utils/cloneObject.ts +32 -0
  69. package/src/utils/compact.ts +2 -0
  70. package/src/utils/convertToArrayPayload.ts +2 -0
  71. package/src/utils/createSubject.ts +48 -0
  72. package/src/utils/deepEqual.ts +81 -0
  73. package/src/utils/deepMerge.ts +27 -0
  74. package/src/utils/extractFormValues.ts +28 -0
  75. package/src/utils/fillEmptyArray.ts +3 -0
  76. package/src/utils/flatten.ts +23 -0
  77. package/src/utils/get.ts +29 -0
  78. package/src/utils/index.ts +3 -0
  79. package/src/utils/insert.ts +8 -0
  80. package/src/utils/isBoolean.ts +2 -0
  81. package/src/utils/isCheckBoxInput.ts +4 -0
  82. package/src/utils/isDateObject.ts +2 -0
  83. package/src/utils/isEmptyObject.ts +7 -0
  84. package/src/utils/isFileInput.ts +4 -0
  85. package/src/utils/isFunction.ts +2 -0
  86. package/src/utils/isHTMLElement.ts +13 -0
  87. package/src/utils/isKey.ts +4 -0
  88. package/src/utils/isMultipleSelect.ts +5 -0
  89. package/src/utils/isNullOrUndefined.ts +2 -0
  90. package/src/utils/isObject.ts +8 -0
  91. package/src/utils/isPlainObject.ts +8 -0
  92. package/src/utils/isPrimitive.ts +8 -0
  93. package/src/utils/isRadioInput.ts +4 -0
  94. package/src/utils/isRadioOrCheckbox.ts +8 -0
  95. package/src/utils/isRegex.ts +2 -0
  96. package/src/utils/isString.ts +2 -0
  97. package/src/utils/isUndefined.ts +2 -0
  98. package/src/utils/isWeb.ts +4 -0
  99. package/src/utils/live.ts +6 -0
  100. package/src/utils/move.ts +15 -0
  101. package/src/utils/noop.ts +2 -0
  102. package/src/utils/objectHasFunction.ts +11 -0
  103. package/src/utils/prepend.ts +7 -0
  104. package/src/utils/remove.ts +24 -0
  105. package/src/utils/set.ts +36 -0
  106. package/src/utils/sleep.ts +2 -0
  107. package/src/utils/stringToPath.ts +4 -0
  108. package/src/utils/swap.ts +4 -0
  109. package/src/utils/unset.ts +65 -0
  110. package/src/utils/update.ts +5 -0
  111. package/src/watch.tsrx +7 -0
  112. package/src/watch.tsrx.d.ts +42 -0
@@ -0,0 +1,21 @@
1
+ // Vendored from react-hook-form@7.81.0 src/logic/skipValidation.ts (octane port).
2
+ import type { ValidationModeFlags } from '../types';
3
+
4
+ export default (
5
+ isBlurEvent: boolean,
6
+ isTouched: boolean,
7
+ isSubmitted: boolean,
8
+ reValidateMode: Pick<ValidationModeFlags, 'isOnBlur' | 'isOnChange'>,
9
+ mode: Partial<ValidationModeFlags>,
10
+ ) => {
11
+ if (mode.isOnAll) {
12
+ return false;
13
+ } else if (!isSubmitted && mode.isOnTouch) {
14
+ return !(isTouched || isBlurEvent);
15
+ } else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
16
+ return !isBlurEvent;
17
+ } else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
18
+ return isBlurEvent;
19
+ }
20
+ return true;
21
+ };
@@ -0,0 +1,6 @@
1
+ // Vendored from react-hook-form@7.81.0 src/logic/unsetEmptyArray.ts (octane port).
2
+ import compact from '../utils/compact';
3
+ import get from '../utils/get';
4
+ import unset from '../utils/unset';
5
+
6
+ export default <T>(ref: T, name: string) => !compact(get(ref, name)).length && unset(ref, name);
@@ -0,0 +1,17 @@
1
+ // Vendored from react-hook-form@7.81.0 src/logic/updateFieldArrayRootError.ts (octane port).
2
+ import { ROOT_ERROR_TYPE } from '../constants';
3
+ import type { FieldError, FieldErrors, FieldValues, InternalFieldName } from '../types';
4
+ import get from '../utils/get';
5
+ import set from '../utils/set';
6
+
7
+ export default <T extends FieldValues = FieldValues>(
8
+ errors: FieldErrors<T>,
9
+ error: Partial<Record<string, FieldError>>,
10
+ name: InternalFieldName,
11
+ ): FieldErrors<T> => {
12
+ const existingErrors = get(errors, name);
13
+ const fieldArrayErrors = Array.isArray(existingErrors) ? existingErrors : [];
14
+ set(fieldArrayErrors, ROOT_ERROR_TYPE, error[name]);
15
+ set(errors, name, fieldArrayErrors);
16
+ return errors;
17
+ };
@@ -0,0 +1,273 @@
1
+ // Vendored from react-hook-form@7.81.0 src/logic/validateField.ts (octane port).
2
+ import { INPUT_VALIDATION_RULES } from '../constants';
3
+ import type {
4
+ Field,
5
+ FieldError,
6
+ FieldValues,
7
+ InternalFieldErrors,
8
+ InternalNameSet,
9
+ MaxType,
10
+ Message,
11
+ MinType,
12
+ NativeFieldValue,
13
+ } from '../types';
14
+ import get from '../utils/get';
15
+ import isBoolean from '../utils/isBoolean';
16
+ import isCheckBoxInput from '../utils/isCheckBoxInput';
17
+ import isEmptyObject from '../utils/isEmptyObject';
18
+ import isFileInput from '../utils/isFileInput';
19
+ import isFunction from '../utils/isFunction';
20
+ import isHTMLElement from '../utils/isHTMLElement';
21
+ import isNullOrUndefined from '../utils/isNullOrUndefined';
22
+ import isObject from '../utils/isObject';
23
+ import isRadioInput from '../utils/isRadioInput';
24
+ import isRegex from '../utils/isRegex';
25
+ import isString from '../utils/isString';
26
+ import isUndefined from '../utils/isUndefined';
27
+
28
+ import appendErrors from './appendErrors';
29
+ import getCheckboxValue from './getCheckboxValue';
30
+ import getRadioValue from './getRadioValue';
31
+ import getValidateError from './getValidateError';
32
+ import getValueAndMessage from './getValueAndMessage';
33
+
34
+ export default async <T extends FieldValues>(
35
+ field: Field,
36
+ disabledFieldNames: InternalNameSet,
37
+ formValues: T,
38
+ validateAllFieldCriteria: boolean,
39
+ shouldUseNativeValidation?: boolean,
40
+ isFieldArray?: boolean,
41
+ ): Promise<InternalFieldErrors> => {
42
+ const {
43
+ ref,
44
+ refs,
45
+ required,
46
+ maxLength,
47
+ minLength,
48
+ min,
49
+ max,
50
+ pattern,
51
+ validate,
52
+ name,
53
+ valueAsNumber,
54
+ mount,
55
+ } = field._f;
56
+ const inputValue: NativeFieldValue = get(formValues, name);
57
+ if (!mount || disabledFieldNames.has(name)) {
58
+ return {};
59
+ }
60
+ const inputRef: HTMLInputElement = refs ? refs[0] : (ref as HTMLInputElement);
61
+ const setCustomValidity = (message?: string | boolean) => {
62
+ if (shouldUseNativeValidation && inputRef.reportValidity) {
63
+ const validityMessage = isBoolean(message) ? '' : message || '';
64
+ if (refs) {
65
+ refs.forEach((ref) => ref.setCustomValidity(validityMessage));
66
+ } else {
67
+ inputRef.setCustomValidity(validityMessage);
68
+ }
69
+ inputRef.reportValidity();
70
+ }
71
+ };
72
+ const error: InternalFieldErrors = {};
73
+ const isRadio = isRadioInput(ref);
74
+ const isCheckBox = isCheckBoxInput(ref);
75
+ const isRadioOrCheckbox = isRadio || isCheckBox;
76
+ const isEmpty =
77
+ ((valueAsNumber || isFileInput(ref)) && isUndefined(ref.value) && isUndefined(inputValue)) ||
78
+ (isHTMLElement(ref) && ref.value === '') ||
79
+ inputValue === '' ||
80
+ (Array.isArray(inputValue) && !inputValue.length);
81
+ const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
82
+ const getMinMaxMessage = (
83
+ exceedMax: boolean,
84
+ maxLengthMessage: Message,
85
+ minLengthMessage: Message,
86
+ maxType: MaxType = INPUT_VALIDATION_RULES.maxLength,
87
+ minType: MinType = INPUT_VALIDATION_RULES.minLength,
88
+ ) => {
89
+ const message = exceedMax ? maxLengthMessage : minLengthMessage;
90
+ error[name] = {
91
+ type: exceedMax ? maxType : minType,
92
+ message,
93
+ ref,
94
+ ...appendErrorsCurry(exceedMax ? maxType : minType, message),
95
+ };
96
+ };
97
+
98
+ if (
99
+ isFieldArray
100
+ ? !Array.isArray(inputValue) || !inputValue.length
101
+ : required &&
102
+ ((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
103
+ (isBoolean(inputValue) && !inputValue) ||
104
+ (isCheckBox && !getCheckboxValue(refs).isValid) ||
105
+ (isRadio && !getRadioValue(refs).isValid))
106
+ ) {
107
+ const { value, message } = isString(required)
108
+ ? { value: !!required, message: required }
109
+ : getValueAndMessage(required);
110
+
111
+ if (value) {
112
+ error[name] = {
113
+ type: INPUT_VALIDATION_RULES.required,
114
+ message,
115
+ ref: inputRef,
116
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
117
+ };
118
+ if (!validateAllFieldCriteria) {
119
+ setCustomValidity(message);
120
+ return error;
121
+ }
122
+ }
123
+ }
124
+
125
+ if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
126
+ let exceedMax;
127
+ let exceedMin;
128
+ const maxOutput = getValueAndMessage(max);
129
+ const minOutput = getValueAndMessage(min);
130
+
131
+ if (!isNullOrUndefined(inputValue) && !isNaN(inputValue as number)) {
132
+ const valueNumber =
133
+ (ref as HTMLInputElement).valueAsNumber || (inputValue ? +inputValue : inputValue);
134
+ if (!isNullOrUndefined(maxOutput.value)) {
135
+ exceedMax = valueNumber > maxOutput.value;
136
+ }
137
+ if (!isNullOrUndefined(minOutput.value)) {
138
+ exceedMin = valueNumber < minOutput.value;
139
+ }
140
+ } else {
141
+ const valueDate = (ref as HTMLInputElement).valueAsDate || new Date(inputValue as string);
142
+ const convertTimeToDate = (time: unknown) => new Date(new Date().toDateString() + ' ' + time);
143
+ const isTime = ref.type == 'time';
144
+ const isWeek = ref.type == 'week';
145
+
146
+ if (isString(maxOutput.value) && inputValue) {
147
+ exceedMax = isTime
148
+ ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
149
+ : isWeek
150
+ ? inputValue > maxOutput.value
151
+ : valueDate > new Date(maxOutput.value);
152
+ }
153
+
154
+ if (isString(minOutput.value) && inputValue) {
155
+ exceedMin = isTime
156
+ ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
157
+ : isWeek
158
+ ? inputValue < minOutput.value
159
+ : valueDate < new Date(minOutput.value);
160
+ }
161
+ }
162
+
163
+ if (exceedMax || exceedMin) {
164
+ getMinMaxMessage(
165
+ !!exceedMax,
166
+ maxOutput.message,
167
+ minOutput.message,
168
+ INPUT_VALIDATION_RULES.max,
169
+ INPUT_VALIDATION_RULES.min,
170
+ );
171
+ if (!validateAllFieldCriteria) {
172
+ setCustomValidity(error[name]!.message);
173
+ return error;
174
+ }
175
+ }
176
+ }
177
+
178
+ if (
179
+ (maxLength || minLength) &&
180
+ !isEmpty &&
181
+ (isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))
182
+ ) {
183
+ const maxLengthOutput = getValueAndMessage(maxLength);
184
+ const minLengthOutput = getValueAndMessage(minLength);
185
+ const exceedMax =
186
+ !isNullOrUndefined(maxLengthOutput.value) && inputValue.length > +maxLengthOutput.value;
187
+ const exceedMin =
188
+ !isNullOrUndefined(minLengthOutput.value) && inputValue.length < +minLengthOutput.value;
189
+
190
+ if (exceedMax || exceedMin) {
191
+ getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
192
+ if (!validateAllFieldCriteria) {
193
+ setCustomValidity(error[name]!.message);
194
+ return error;
195
+ }
196
+ }
197
+ }
198
+
199
+ if (pattern && !isEmpty && isString(inputValue)) {
200
+ const { value: patternValue, message } = getValueAndMessage(pattern);
201
+
202
+ if (isRegex(patternValue) && !inputValue.match(patternValue)) {
203
+ error[name] = {
204
+ type: INPUT_VALIDATION_RULES.pattern,
205
+ message,
206
+ ref,
207
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
208
+ };
209
+ if (!validateAllFieldCriteria) {
210
+ setCustomValidity(message);
211
+ return error;
212
+ }
213
+ }
214
+ }
215
+
216
+ if (validate) {
217
+ if (isFunction(validate)) {
218
+ const result = await validate(inputValue, formValues);
219
+ const validateError = getValidateError(result, inputRef);
220
+
221
+ if (validateError) {
222
+ error[name] = {
223
+ ...validateError,
224
+ ...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
225
+ };
226
+ if (!validateAllFieldCriteria) {
227
+ setCustomValidity(validateError.message);
228
+ return error;
229
+ }
230
+ }
231
+ } else if (isObject(validate)) {
232
+ let validationResult = {} as FieldError;
233
+
234
+ for (const key in validate) {
235
+ if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
236
+ break;
237
+ }
238
+
239
+ const validateError = getValidateError(
240
+ await validate[key](inputValue, formValues),
241
+ inputRef,
242
+ key,
243
+ );
244
+
245
+ if (validateError) {
246
+ validationResult = {
247
+ ...validateError,
248
+ ...appendErrorsCurry(key, validateError.message),
249
+ };
250
+
251
+ setCustomValidity(validateError.message);
252
+
253
+ if (validateAllFieldCriteria) {
254
+ error[name] = validationResult;
255
+ }
256
+ }
257
+ }
258
+
259
+ if (!isEmptyObject(validationResult)) {
260
+ error[name] = {
261
+ ref: inputRef,
262
+ ...validationResult,
263
+ };
264
+ if (!validateAllFieldCriteria) {
265
+ return error;
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ setCustomValidity(true);
272
+ return error;
273
+ };
@@ -0,0 +1,98 @@
1
+ // Vendored from react-hook-form@7.81.0 src/types/controller.ts.
2
+ // octane: upstream's React.ReactElement return becomes `unknown` (any octane
3
+ // renderable), and `onChange` becomes `onInput` — octane events are native, so
4
+ // the per-keystroke handler is the platform `input` event.
5
+ import type {
6
+ Control,
7
+ FieldError,
8
+ FieldPath,
9
+ FieldPathValue,
10
+ FieldValues,
11
+ Noop,
12
+ RefCallBack,
13
+ UseFormStateReturn,
14
+ } from './';
15
+ import type { RegisterOptions } from './validator';
16
+
17
+ export type ControllerFieldState = {
18
+ invalid: boolean;
19
+ isTouched: boolean;
20
+ isDirty: boolean;
21
+ isValidating: boolean;
22
+ error?: FieldError;
23
+ };
24
+
25
+ export type ControllerRenderProps<
26
+ TFieldValues extends FieldValues = FieldValues,
27
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
28
+ > = {
29
+ onInput: (...event: any[]) => void;
30
+ onBlur: Noop;
31
+ value: FieldPathValue<TFieldValues, TName>;
32
+ disabled?: boolean;
33
+ name: TName;
34
+ ref: RefCallBack;
35
+ };
36
+
37
+ export type UseControllerProps<
38
+ TFieldValues extends FieldValues = FieldValues,
39
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
40
+ TTransformedValues = TFieldValues,
41
+ > = {
42
+ name: TName;
43
+ rules?: Omit<
44
+ RegisterOptions<TFieldValues, TName>,
45
+ 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'
46
+ >;
47
+ shouldUnregister?: boolean;
48
+ defaultValue?: FieldPathValue<TFieldValues, TName>;
49
+ control?: Control<TFieldValues, any, TTransformedValues>;
50
+ disabled?: boolean;
51
+ exact?: boolean;
52
+ };
53
+
54
+ export type UseControllerReturn<
55
+ TFieldValues extends FieldValues = FieldValues,
56
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
57
+ > = {
58
+ field: ControllerRenderProps<TFieldValues, TName>;
59
+ formState: UseFormStateReturn<TFieldValues>;
60
+ fieldState: ControllerFieldState;
61
+ };
62
+
63
+ /**
64
+ * Render function to provide the control for the field.
65
+ *
66
+ * @returns all the event handlers, and relevant field and form state.
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * const { field, fieldState, formState } = useController();
71
+ *
72
+ * <Controller
73
+ * render={({ field, formState, fieldState }) => ({
74
+ * <input
75
+ * onInput={field.onInput}
76
+ * onBlur={field.onBlur}
77
+ * name={field.name}
78
+ * ref={field.ref} // optional for focus management
79
+ * />
80
+ * })}
81
+ * />
82
+ * ```
83
+ */
84
+ export type ControllerProps<
85
+ TFieldValues extends FieldValues = FieldValues,
86
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
87
+ TTransformedValues = TFieldValues,
88
+ > = {
89
+ render: ({
90
+ field,
91
+ fieldState,
92
+ formState,
93
+ }: {
94
+ field: ControllerRenderProps<TFieldValues, TName>;
95
+ fieldState: ControllerFieldState;
96
+ formState: UseFormStateReturn<TFieldValues>;
97
+ }) => unknown;
98
+ } & UseControllerProps<TFieldValues, TName, TTransformedValues>;
@@ -0,0 +1,56 @@
1
+ // Vendored from react-hook-form@7.81.0 src/types/errors.ts (octane port).
2
+ import type { FieldValues, InternalFieldName, Ref } from './fields';
3
+ import type { BrowserNativeObject, IsAny, LiteralUnion, Merge } from './utils';
4
+ import type { RegisterOptions, ValidateResult } from './validator';
5
+
6
+ export type Message = string;
7
+
8
+ export type MultipleFieldErrors = {
9
+ [K in keyof RegisterOptions]?: ValidateResult;
10
+ } & {
11
+ [key: string]: ValidateResult;
12
+ };
13
+
14
+ export type FieldError = {
15
+ type: LiteralUnion<keyof RegisterOptions, string>;
16
+ root?: FieldError;
17
+ ref?: Ref;
18
+ types?: MultipleFieldErrors;
19
+ message?: Message;
20
+ };
21
+
22
+ export type ErrorOption = {
23
+ message?: Message;
24
+ type?: LiteralUnion<keyof RegisterOptions, string>;
25
+ types?: MultipleFieldErrors;
26
+ };
27
+
28
+ export type DeepRequired<T> = T extends BrowserNativeObject | Blob
29
+ ? T
30
+ : {
31
+ [K in keyof T]-?: NonNullable<DeepRequired<T[K]>>;
32
+ };
33
+
34
+ export type FieldErrorsImpl<T extends FieldValues = FieldValues> = {
35
+ [K in keyof T]?: T[K] extends BrowserNativeObject | Blob
36
+ ? FieldError
37
+ : K extends 'root' | `root.${string}`
38
+ ? GlobalError
39
+ : T[K] extends object
40
+ ? Merge<FieldError, FieldErrorsImpl<T[K]>>
41
+ : FieldError;
42
+ };
43
+
44
+ export type GlobalError = Partial<{
45
+ type: string | number;
46
+ message: Message;
47
+ }>;
48
+
49
+ export type FieldErrors<T extends FieldValues = FieldValues> = Partial<
50
+ FieldValues extends IsAny<FieldValues> ? any : FieldErrorsImpl<DeepRequired<T>>
51
+ > & {
52
+ root?: Record<string, GlobalError> & GlobalError;
53
+ form?: GlobalError;
54
+ };
55
+
56
+ export type InternalFieldErrors = Partial<Record<InternalFieldName, FieldError>>;
@@ -0,0 +1,26 @@
1
+ // Vendored from react-hook-form@7.81.0 src/types/events.ts (octane port).
2
+ export type EventType =
3
+ | 'focus'
4
+ | 'blur'
5
+ | 'change'
6
+ | 'changeText'
7
+ | 'valueChange'
8
+ | 'contentSizeChange'
9
+ | 'endEditing'
10
+ | 'keyPress'
11
+ | 'submitEditing'
12
+ | 'layout'
13
+ | 'selectionChange'
14
+ | 'longPress'
15
+ | 'press'
16
+ | 'pressIn'
17
+ | 'pressOut'
18
+ | 'momentumScrollBegin'
19
+ | 'momentumScrollEnd'
20
+ | 'scroll'
21
+ | 'scrollBeginDrag'
22
+ | 'scrollEndDrag'
23
+ | 'load'
24
+ | 'error'
25
+ | 'progress'
26
+ | 'custom';