form-hook-kit 1.2.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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +753 -0
  3. package/dist/FormContext.d.ts +8 -0
  4. package/dist/FormContext.d.ts.map +1 -0
  5. package/dist/FormProvider.d.ts +33 -0
  6. package/dist/FormProvider.d.ts.map +1 -0
  7. package/dist/devtools/FormDevTools.d.ts +86 -0
  8. package/dist/devtools/FormDevTools.d.ts.map +1 -0
  9. package/dist/devtools/index.d.ts +3 -0
  10. package/dist/devtools/index.d.ts.map +1 -0
  11. package/dist/hooks/index.d.ts +4 -0
  12. package/dist/hooks/index.d.ts.map +1 -0
  13. package/dist/hooks/useForm.d.ts +30 -0
  14. package/dist/hooks/useForm.d.ts.map +1 -0
  15. package/dist/hooks/useFormField.d.ts +40 -0
  16. package/dist/hooks/useFormField.d.ts.map +1 -0
  17. package/dist/hooks/useFormPerformance.d.ts +57 -0
  18. package/dist/hooks/useFormPerformance.d.ts.map +1 -0
  19. package/dist/index.d.ts +12 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.esm.js +394 -0
  22. package/dist/index.esm.js.map +1 -0
  23. package/dist/index.js +408 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/types/index.d.ts +94 -0
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/utils/debounce.d.ts +6 -0
  28. package/dist/utils/debounce.d.ts.map +1 -0
  29. package/dist/utils/errors.d.ts +11 -0
  30. package/dist/utils/errors.d.ts.map +1 -0
  31. package/dist/utils/formActions.d.ts +57 -0
  32. package/dist/utils/formActions.d.ts.map +1 -0
  33. package/dist/utils/formReducer.d.ts +7 -0
  34. package/dist/utils/formReducer.d.ts.map +1 -0
  35. package/dist/utils/index.d.ts +7 -0
  36. package/dist/utils/index.d.ts.map +1 -0
  37. package/dist/utils/performance.d.ts +7 -0
  38. package/dist/utils/performance.d.ts.map +1 -0
  39. package/dist/utils/validation.d.ts +25 -0
  40. package/dist/utils/validation.d.ts.map +1 -0
  41. package/package.json +91 -0
package/dist/index.js ADDED
@@ -0,0 +1,408 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var yup = require('yup');
5
+
6
+ /**
7
+ * Form context
8
+ * Provides form state and methods to child components
9
+ */
10
+ const FormContext = React.createContext(null);
11
+
12
+ /**
13
+ * Get validation error for a specific field
14
+ * @param name - Field name
15
+ * @param schema - Yup schema
16
+ * @param values - Current form values
17
+ * @returns Error message or null if valid
18
+ */
19
+ function getFieldError({ name, schema, values, }) {
20
+ try {
21
+ schema.validateSyncAt(name, values);
22
+ return null;
23
+ }
24
+ catch (error) {
25
+ if (error instanceof yup.ValidationError) {
26
+ return error.message;
27
+ }
28
+ return 'Validation error';
29
+ }
30
+ }
31
+ /**
32
+ * Get validation errors for entire form
33
+ * @param schema - Yup schema
34
+ * @param values - Current form values
35
+ * @returns Object with errors by field name
36
+ */
37
+ function getFormErrors({ schema, values, }) {
38
+ // Type guard to check if schema is an ObjectSchema with fields
39
+ const objectSchema = schema;
40
+ const fields = objectSchema.fields
41
+ ? Object.keys(objectSchema.fields)
42
+ : Object.keys(values);
43
+ return fields.reduce((acc, field) => {
44
+ acc[field] = getFieldError({ name: field, schema, values });
45
+ return acc;
46
+ }, {});
47
+ }
48
+
49
+ /**
50
+ * Form actions
51
+ */
52
+ var FormActions;
53
+ (function (FormActions) {
54
+ FormActions["UPDATE_ERRORS"] = "UPDATE_ERRORS";
55
+ FormActions["UPDATE_VALUES"] = "UPDATE_VALUES";
56
+ })(FormActions || (FormActions = {}));
57
+
58
+ /**
59
+ * Form state reducer
60
+ * Manages form state updates for values and errors
61
+ */
62
+ function formReducer(state, action) {
63
+ switch (action.type) {
64
+ case FormActions.UPDATE_ERRORS:
65
+ return {
66
+ ...state,
67
+ errors: {
68
+ ...state.errors,
69
+ ...action.payload,
70
+ },
71
+ };
72
+ case FormActions.UPDATE_VALUES:
73
+ return {
74
+ ...state,
75
+ values: action.payload,
76
+ };
77
+ default:
78
+ return state;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Generate changeValue function
84
+ * Updates a single field value
85
+ */
86
+ function generateChangeValue({ dispatch, values, }) {
87
+ return ({ name, value }) => {
88
+ const payload = { ...values };
89
+ payload[name] = value;
90
+ dispatch({
91
+ payload,
92
+ type: FormActions.UPDATE_VALUES,
93
+ });
94
+ };
95
+ }
96
+ /**
97
+ * Generate changeValues function
98
+ * Updates multiple field values at once
99
+ */
100
+ function generateChangeValues({ dispatch, }) {
101
+ return (values) => {
102
+ dispatch({
103
+ payload: values,
104
+ type: FormActions.UPDATE_VALUES,
105
+ });
106
+ };
107
+ }
108
+ /**
109
+ * Generate clearError function
110
+ * Clears error for a specific field
111
+ */
112
+ function generateClearError({ dispatch, }) {
113
+ return (name) => {
114
+ dispatch({
115
+ payload: { [name]: null },
116
+ type: FormActions.UPDATE_ERRORS,
117
+ });
118
+ };
119
+ }
120
+ /**
121
+ * Generate setError function
122
+ * Sets error for a specific field
123
+ */
124
+ function generateSetError({ dispatch, }) {
125
+ return ({ error, name }) => {
126
+ dispatch({
127
+ payload: { [name]: error },
128
+ type: FormActions.UPDATE_ERRORS,
129
+ });
130
+ };
131
+ }
132
+ /**
133
+ * Generate validateField function
134
+ * Validates a single field against the schema
135
+ */
136
+ function generateValidateField({ dispatch, schema, values, }) {
137
+ return (name, value) => {
138
+ const newErrors = {};
139
+ newErrors[name] = getFieldError({
140
+ name,
141
+ schema,
142
+ values: value === undefined ? values : { ...values, [name]: value },
143
+ });
144
+ dispatch({
145
+ payload: newErrors,
146
+ type: FormActions.UPDATE_ERRORS,
147
+ });
148
+ return newErrors[name];
149
+ };
150
+ }
151
+ /**
152
+ * Generate validateForm function
153
+ * Validates entire form against the schema
154
+ */
155
+ function generateValidateForm({ dispatch, schema, values, }) {
156
+ return () => {
157
+ const newErrors = getFormErrors({ schema, values });
158
+ dispatch({
159
+ payload: newErrors,
160
+ type: FormActions.UPDATE_ERRORS,
161
+ });
162
+ return newErrors;
163
+ };
164
+ }
165
+
166
+ /**
167
+ * Creates a debounced function that delays invoking func until after wait milliseconds
168
+ * have elapsed since the last time the debounced function was invoked.
169
+ */
170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
+ function debounce(func, wait) {
172
+ let timeoutId;
173
+ return function debounced(...args) {
174
+ if (timeoutId !== undefined) {
175
+ clearTimeout(timeoutId);
176
+ }
177
+ timeoutId = setTimeout(() => {
178
+ func(...args);
179
+ }, wait);
180
+ };
181
+ }
182
+
183
+ /**
184
+ * Enhanced error messages with helpful suggestions
185
+ */
186
+ class FormHookKitError extends Error {
187
+ constructor(message, suggestion) {
188
+ super(message);
189
+ this.suggestion = suggestion;
190
+ this.name = 'FormHookKitError';
191
+ }
192
+ }
193
+ function createContextError() {
194
+ return new FormHookKitError('useForm must be used within a FormProvider', 'Wrap your component tree with <FormProvider> to use form hooks. Example:\n\n' +
195
+ '<FormProvider schema={schema} initialValues={{}}>\n' +
196
+ ' <YourComponent />\n' +
197
+ '</FormProvider>');
198
+ }
199
+
200
+ /**
201
+ * Form Provider Component
202
+ *
203
+ * Wraps your form and provides form state management using React Context.
204
+ * Integrates with Yup for validation.
205
+ *
206
+ * @example
207
+ * ```tsx
208
+ * import * as yup from 'yup';
209
+ * import {FormProvider} from 'form-hook-kit';
210
+ *
211
+ * const schema = yup.object({
212
+ * email: yup.string().email().required(),
213
+ * password: yup.string().min(8).required(),
214
+ * });
215
+ *
216
+ * function MyForm() {
217
+ * return (
218
+ * <FormProvider
219
+ * schema={schema}
220
+ * initialValues={{ email: '', password: '' }}
221
+ * >
222
+ * <MyFormFields />
223
+ * </FormProvider>
224
+ * );
225
+ * }
226
+ * ```
227
+ */
228
+ function FormProvider({ children, initialErrors = {}, initialValues = {}, schema, validationDebounce = 0, }) {
229
+ const fieldRefs = React.useRef({});
230
+ const [state, dispatch] = React.useReducer(formReducer, {
231
+ errors: initialErrors,
232
+ values: initialValues,
233
+ });
234
+ // Memoize action generators to prevent unnecessary re-renders
235
+ const changeValue = React.useMemo(() => generateChangeValue({ dispatch, values: state.values }), [state.values]);
236
+ const changeValues = React.useMemo(() => generateChangeValues({ dispatch }), []);
237
+ const clearError = React.useMemo(() => generateClearError({ dispatch }), []);
238
+ const setError = React.useMemo(() => generateSetError({ dispatch }), []);
239
+ // Create validation functions with optional debouncing
240
+ const validateField = React.useMemo(() => {
241
+ const validator = generateValidateField({
242
+ dispatch,
243
+ schema,
244
+ values: state.values,
245
+ });
246
+ if (validationDebounce > 0) {
247
+ const debouncedValidator = debounce(validator, validationDebounce);
248
+ // Return a wrapper that calls debounced but still returns the result synchronously
249
+ return (name, value) => {
250
+ debouncedValidator(name, value);
251
+ return validator(name, value);
252
+ };
253
+ }
254
+ return validator;
255
+ }, [schema, state.values, validationDebounce]);
256
+ const validateForm = React.useMemo(() => {
257
+ const validator = generateValidateForm({
258
+ dispatch,
259
+ schema,
260
+ values: state.values,
261
+ });
262
+ if (validationDebounce > 0) {
263
+ const debouncedValidator = debounce(validator, validationDebounce);
264
+ // Return a wrapper that calls debounced but still returns the result synchronously
265
+ return () => {
266
+ debouncedValidator();
267
+ return validator();
268
+ };
269
+ }
270
+ return validator;
271
+ }, [schema, state.values, validationDebounce]);
272
+ // Memoize context value to prevent unnecessary re-renders of consumers
273
+ const contextValue = React.useMemo(() => ({
274
+ fieldRefs,
275
+ errors: state.errors,
276
+ values: state.values,
277
+ changeValue,
278
+ changeValues,
279
+ clearError,
280
+ setError,
281
+ validateField,
282
+ validateForm,
283
+ }), [
284
+ state.errors,
285
+ state.values,
286
+ changeValue,
287
+ changeValues,
288
+ clearError,
289
+ setError,
290
+ validateField,
291
+ validateForm,
292
+ ]);
293
+ return (React.createElement(FormContext.Provider, { value: contextValue }, children));
294
+ }
295
+
296
+ /**
297
+ * Hook to access form context
298
+ *
299
+ * Must be used within a FormProvider component.
300
+ * Provides access to form state, values, errors, and methods.
301
+ *
302
+ * @returns Form context value with state and methods
303
+ *
304
+ * @example
305
+ * ```tsx
306
+ * function MyFormField() {
307
+ * const {values, errors, changeValue, validateField} = useForm();
308
+ *
309
+ * return (
310
+ * <div>
311
+ * <input
312
+ * value={values.email || ''}
313
+ * onChange={(e) => changeValue({name: 'email', value: e.target.value})}
314
+ * onBlur={() => validateField('email')}
315
+ * />
316
+ * {errors.email && <span>{errors.email}</span>}
317
+ * </div>
318
+ * );
319
+ * }
320
+ * ```
321
+ */
322
+ function useForm() {
323
+ const context = React.useContext(FormContext);
324
+ if (!context) {
325
+ const error = createContextError();
326
+ // Log suggestion to console for better DX
327
+ if (error.suggestion) {
328
+ console.error(error.suggestion);
329
+ }
330
+ throw error;
331
+ }
332
+ return context;
333
+ }
334
+
335
+ /**
336
+ * Hook for managing a single form field
337
+ *
338
+ * Provides field-specific state and handlers for common field operations.
339
+ *
340
+ * @param name - Field name
341
+ * @returns Field state and handlers
342
+ *
343
+ * @example
344
+ * ```tsx
345
+ * function EmailField() {
346
+ * const {value, error, onChange, onBlur} = useFormField('email');
347
+ *
348
+ * return (
349
+ * <div>
350
+ * <input
351
+ * type="email"
352
+ * value={value || ''}
353
+ * onChange={onChange}
354
+ * onBlur={onBlur}
355
+ * />
356
+ * {error && <span className="error">{error}</span>}
357
+ * </div>
358
+ * );
359
+ * }
360
+ * ```
361
+ */
362
+ function useFormField(name) {
363
+ const { values, errors, changeValue, validateField, clearError, fieldRefs } = useForm();
364
+ const value = values[name];
365
+ const error = errors[name];
366
+ const onChange = React.useCallback((e) => {
367
+ changeValue({ name, value: e.target.value });
368
+ }, [name, changeValue]);
369
+ const onChangeValue = React.useCallback((newValue) => {
370
+ changeValue({ name, value: newValue });
371
+ }, [name, changeValue]);
372
+ const onBlur = React.useCallback(() => {
373
+ validateField(name);
374
+ }, [name, validateField]);
375
+ const onFocus = React.useCallback(() => {
376
+ clearError(name);
377
+ }, [name, clearError]);
378
+ const setRef = React.useCallback((ref) => {
379
+ if (ref) {
380
+ fieldRefs.current[name] = ref;
381
+ }
382
+ }, [name, fieldRefs]);
383
+ return {
384
+ value,
385
+ error,
386
+ onChange,
387
+ onChangeValue,
388
+ onBlur,
389
+ onFocus,
390
+ setRef,
391
+ name,
392
+ };
393
+ }
394
+
395
+ exports.FormContext = FormContext;
396
+ exports.FormProvider = FormProvider;
397
+ exports.formReducer = formReducer;
398
+ exports.generateChangeValue = generateChangeValue;
399
+ exports.generateChangeValues = generateChangeValues;
400
+ exports.generateClearError = generateClearError;
401
+ exports.generateSetError = generateSetError;
402
+ exports.generateValidateField = generateValidateField;
403
+ exports.generateValidateForm = generateValidateForm;
404
+ exports.getFieldError = getFieldError;
405
+ exports.getFormErrors = getFormErrors;
406
+ exports.useForm = useForm;
407
+ exports.useFormField = useFormField;
408
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/FormContext.tsx","../src/utils/validation.ts","../src/types/index.ts","../src/utils/formReducer.ts","../src/utils/formActions.ts","../src/utils/debounce.ts","../src/utils/errors.ts","../src/FormProvider.tsx","../src/hooks/useForm.ts","../src/hooks/useFormField.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null],"names":["createContext","ValidationError","useRef","useReducer","useMemo","useContext","useCallback"],"mappings":";;;;;AAGA;;;AAGG;MACU,WAAW,GAAGA,mBAAa,CAA0B,IAAI;;ACJtE;;;;;;AAMG;AACG,SAAU,aAAa,CAAC,EAC5B,IAAI,EACJ,MAAM,EACN,MAAM,GAKP,EAAA;AACC,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC;AACnC,QAAA,OAAO,IAAI;IACb;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,KAAK,YAAYC,mBAAe,EAAE;YACpC,OAAO,KAAK,CAAC,OAAO;QACtB;AACA,QAAA,OAAO,kBAAkB;IAC3B;AACF;AAEA;;;;;AAKG;SACa,aAAa,CAAC,EAC5B,MAAM,EACN,MAAM,G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E,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AAEzB,IAAA,MAAM,OAAO,GAAGA,iBAAW,CAAC,MAAK;QAC/B,UAAU,CAAC,IAAI,CAAC;AAClB,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAEtB,IAAA,MAAM,MAAM,GAAGA,iBAAW,CACxB,CAAC,GAAiB,KAAI;QACpB,IAAI,GAAG,EAAE;AACP,YAAA,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG;QAC/B;AACF,IAAA,CAAC,EACD,CAAC,IAAI,EAAE,SAAS,CAAC,CAClB;IAED,OAAO;QACL,KAAK;QACL,KAAK;QACL,QAAQ;QACR,aAAa;QACb,MAAM;QACN,OAAO;QACP,MAAM;QACN,IAAI;KACL;AACH;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,94 @@
1
+ import { AnySchema } from 'yup';
2
+ /**
3
+ * Generic form field value type
4
+ */
5
+ export type FormFieldValue = string | number | boolean | null | undefined;
6
+ /**
7
+ * Form values object
8
+ */
9
+ export type FormValues = Record<string, FormFieldValue>;
10
+ /**
11
+ * Minimal interface for form field refs
12
+ * Works with both web inputs and React Native TextInput
13
+ */
14
+ export interface FocusableElement {
15
+ focus: () => void;
16
+ }
17
+ /**
18
+ * Form field ref type (for React Native TextInput or HTML input elements)
19
+ *
20
+ * Supports both web (HTMLInputElement, HTMLTextAreaElement) and React Native (any object with focus method)
21
+ */
22
+ export type FormFieldRef = FocusableElement | null;
23
+ /**
24
+ * Form context state
25
+ */
26
+ export interface FormState {
27
+ errors: Record<string, string | null>;
28
+ values: FormValues;
29
+ }
30
+ /**
31
+ * Form context value interface
32
+ */
33
+ export interface FormContextValue {
34
+ /** Refs to form fields for focus management */
35
+ fieldRefs: React.MutableRefObject<Record<string, FormFieldRef>>;
36
+ /** Current form errors by field name */
37
+ errors: Record<string, string | null>;
38
+ /** Current form values by field name */
39
+ values: FormValues;
40
+ /** Change a single field value */
41
+ changeValue: (params: {
42
+ name: string;
43
+ value: FormFieldValue;
44
+ }) => void;
45
+ /** Change multiple field values at once */
46
+ changeValues: (values: FormValues) => void;
47
+ /** Clear error for a specific field */
48
+ clearError: (name: string) => void;
49
+ /** Set error for a specific field */
50
+ setError: (params: {
51
+ name: string;
52
+ error: string;
53
+ }) => void;
54
+ /** Validate a single field and return error if any */
55
+ validateField: (name: string, value?: FormFieldValue) => string | null;
56
+ /** Validate entire form and return errors object */
57
+ validateForm: () => Record<string, string | null>;
58
+ }
59
+ /**
60
+ * Form provider props
61
+ */
62
+ export interface FormProviderProps {
63
+ /** Form child components */
64
+ children: React.ReactNode;
65
+ /** Initial error state */
66
+ initialErrors?: Record<string, string>;
67
+ /** Initial form values */
68
+ initialValues?: FormValues;
69
+ /** Yup validation schema */
70
+ schema: AnySchema;
71
+ /**
72
+ * Debounce validation in milliseconds. Useful for performance optimization.
73
+ * @default 0 (no debounce)
74
+ */
75
+ validationDebounce?: number;
76
+ }
77
+ /**
78
+ * Form actions
79
+ */
80
+ export declare enum FormActions {
81
+ UPDATE_ERRORS = "UPDATE_ERRORS",
82
+ UPDATE_VALUES = "UPDATE_VALUES"
83
+ }
84
+ /**
85
+ * Form action types
86
+ */
87
+ export type FormAction = {
88
+ type: FormActions.UPDATE_ERRORS;
89
+ payload: Record<string, string | null>;
90
+ } | {
91
+ type: FormActions.UPDATE_VALUES;
92
+ payload: FormValues;
93
+ };
94
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA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ACH,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,0BAA0B;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,0BAA0B;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,4BAA4B;IAC5B,MAAM,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACxC,GACD;IACE,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC;IAChC,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Creates a debounced function that delays invoking func until after wait milliseconds
3
+ * have elapsed since the last time the debounced function was invoked.
4
+ */
5
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
6
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAYlC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Enhanced error messages with helpful suggestions
3
+ */
4
+ export declare class FormHookKitError extends Error {
5
+ suggestion?: string | undefined;
6
+ constructor(message: string, suggestion?: string | undefined);
7
+ }
8
+ export declare function createContextError(): FormHookKitError;
9
+ export declare function createInvalidSchemaError(): FormHookKitError;
10
+ export declare function createValidationError(fieldName: string, error: string): FormHookKitError;
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,gBAAiB,SAAQ,KAAK;IACL,UAAU,CAAC,EAAE,MAAM;gBAA3C,OAAO,EAAE,MAAM,EAAS,UAAU,CAAC,EAAE,MAAM,YAAA;CAIxD;AAED,wBAAgB,kBAAkB,IAAI,gBAAgB,CAQrD;AAED,wBAAgB,wBAAwB,IAAI,gBAAgB,CAU3D;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAKxF"}
@@ -0,0 +1,57 @@
1
+ import { Dispatch } from 'react';
2
+ import { AnySchema } from 'yup';
3
+ import { FormAction, FormValues, FormFieldValue } from '../types';
4
+ /**
5
+ * Generate changeValue function
6
+ * Updates a single field value
7
+ */
8
+ export declare function generateChangeValue({ dispatch, values, }: {
9
+ dispatch: Dispatch<FormAction>;
10
+ values: FormValues;
11
+ }): ({ name, value }: {
12
+ name: string;
13
+ value: FormFieldValue;
14
+ }) => void;
15
+ /**
16
+ * Generate changeValues function
17
+ * Updates multiple field values at once
18
+ */
19
+ export declare function generateChangeValues({ dispatch, }: {
20
+ dispatch: Dispatch<FormAction>;
21
+ }): (values: FormValues) => void;
22
+ /**
23
+ * Generate clearError function
24
+ * Clears error for a specific field
25
+ */
26
+ export declare function generateClearError({ dispatch, }: {
27
+ dispatch: Dispatch<FormAction>;
28
+ }): (name: string) => void;
29
+ /**
30
+ * Generate setError function
31
+ * Sets error for a specific field
32
+ */
33
+ export declare function generateSetError({ dispatch, }: {
34
+ dispatch: Dispatch<FormAction>;
35
+ }): ({ error, name }: {
36
+ error: string;
37
+ name: string;
38
+ }) => void;
39
+ /**
40
+ * Generate validateField function
41
+ * Validates a single field against the schema
42
+ */
43
+ export declare function generateValidateField({ dispatch, schema, values, }: {
44
+ dispatch: Dispatch<FormAction>;
45
+ schema: AnySchema;
46
+ values: FormValues;
47
+ }): (name: string, value?: FormFieldValue) => string | null;
48
+ /**
49
+ * Generate validateForm function
50
+ * Validates entire form against the schema
51
+ */
52
+ export declare function generateValidateForm({ dispatch, schema, values, }: {
53
+ dispatch: Dispatch<FormAction>;
54
+ schema: AnySchema;
55
+ values: FormValues;
56
+ }): () => Record<string, string | null>;
57
+ //# sourceMappingURL=formActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formActions.d.ts","sourceRoot":"","sources":["../../src/utils/formActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAc,UAAU,EAAE,UAAU,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAG7E;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,EAAE,UAAU,CAAC;CACpB,IACS,iBAAe;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAC,UAS7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAChC,IACS,QAAQ,UAAU,UAM3B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAChC,IACS,MAAM,MAAM,UAMrB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAChC,IACS,iBAAe;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,UAMrD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,MAAM,EACN,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB,IACS,MAAM,MAAM,EAAE,QAAQ,cAAc,KAAG,MAAM,GAAG,IAAI,CAe7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,MAAM,EACN,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB,SACY,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAUzC"}
@@ -0,0 +1,7 @@
1
+ import { FormAction, FormState } from '../types';
2
+ /**
3
+ * Form state reducer
4
+ * Manages form state updates for values and errors
5
+ */
6
+ export declare function formReducer(state: FormState, action: FormAction): FormState;
7
+ //# sourceMappingURL=formReducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formReducer.d.ts","sourceRoot":"","sources":["../../src/utils/formReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,CAkB3E"}
@@ -0,0 +1,7 @@
1
+ export * from './validation';
2
+ export * from './formReducer';
3
+ export * from './formActions';
4
+ export * from './debounce';
5
+ export * from './errors';
6
+ export * from './performance';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Cross-platform performance utilities
3
+ *
4
+ * Provides performance.now() polyfill for React Native
5
+ */
6
+ export declare const now: () => number;
7
+ //# sourceMappingURL=performance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/utils/performance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,GAAG,QAAO,MAKtB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { AnySchema } from 'yup';
2
+ import { FormValues } from '../types';
3
+ /**
4
+ * Get validation error for a specific field
5
+ * @param name - Field name
6
+ * @param schema - Yup schema
7
+ * @param values - Current form values
8
+ * @returns Error message or null if valid
9
+ */
10
+ export declare function getFieldError({ name, schema, values, }: {
11
+ name: string;
12
+ schema: AnySchema;
13
+ values: FormValues;
14
+ }): string | null;
15
+ /**
16
+ * Get validation errors for entire form
17
+ * @param schema - Yup schema
18
+ * @param values - Current form values
19
+ * @returns Object with errors by field name
20
+ */
21
+ export declare function getFormErrors({ schema, values, }: {
22
+ schema: AnySchema;
23
+ values: FormValues;
24
+ }): Record<string, string | null>;
25
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAgC,MAAM,KAAK,CAAC;AAC7D,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,MAAM,EACN,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB,GAAG,MAAM,GAAG,IAAI,CAUhB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,MAAM,GACP,EAAE;IACD,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAWhC"}