@gofranz/formshive-submit 1.0.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.
- package/README.md +619 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/field-errors.d.ts +95 -0
- package/dist/field-errors.d.ts.map +1 -0
- package/dist/file-handler.d.ts +43 -0
- package/dist/file-handler.d.ts.map +1 -0
- package/dist/formshive-submit.cjs +1714 -0
- package/dist/formshive-submit.cjs.map +1 -0
- package/dist/formshive-submit.esm.js +1644 -0
- package/dist/formshive-submit.esm.js.map +1 -0
- package/dist/formshive-submit.js +1720 -0
- package/dist/formshive-submit.js.map +1 -0
- package/dist/formshive-submit.min.js +2 -0
- package/dist/formshive-submit.min.js.map +1 -0
- package/dist/main.d.ts +66 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/retry.d.ts +73 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/submit.d.ts +49 -0
- package/dist/submit.d.ts.map +1 -0
- package/dist/test.html +1074 -0
- package/dist/types.d.ts +145 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +115 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field validation error handling utilities
|
|
3
|
+
*/
|
|
4
|
+
import type { SubmitError, FieldValidationError, FieldValidationErrorResponse } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Check if an error contains field validation errors
|
|
7
|
+
*/
|
|
8
|
+
export declare function isFieldValidationError(error: SubmitError): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Get all field validation errors from a SubmitError
|
|
11
|
+
*/
|
|
12
|
+
export declare function getFieldErrors(error: SubmitError): FieldValidationError[];
|
|
13
|
+
/**
|
|
14
|
+
* Get validation error for a specific field
|
|
15
|
+
*/
|
|
16
|
+
export declare function getFieldError(error: SubmitError, fieldName: string): FieldValidationError | null;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a specific field has validation errors
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasFieldError(error: SubmitError, fieldName: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get all field names that have validation errors
|
|
23
|
+
*/
|
|
24
|
+
export declare function getErrorFieldNames(error: SubmitError): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Get validation response if available
|
|
27
|
+
*/
|
|
28
|
+
export declare function getValidationResponse(error: SubmitError): FieldValidationErrorResponse | null;
|
|
29
|
+
/**
|
|
30
|
+
* Format field errors into a simple object for easy UI consumption
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatFieldErrors(error: SubmitError): Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Format field errors with codes for advanced error handling
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatFieldErrorsWithCodes(error: SubmitError): Record<string, FieldValidationError>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a human-readable summary of validation errors
|
|
39
|
+
*/
|
|
40
|
+
export declare function getValidationErrorSummary(error: SubmitError): string;
|
|
41
|
+
/**
|
|
42
|
+
* Create a map of field names to their error messages for easy form field highlighting
|
|
43
|
+
*/
|
|
44
|
+
export declare function createFieldErrorMap(error: SubmitError): Map<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the first field error (useful for focusing on the first invalid field)
|
|
47
|
+
*/
|
|
48
|
+
export declare function getFirstFieldError(error: SubmitError): FieldValidationError | null;
|
|
49
|
+
/**
|
|
50
|
+
* Check if validation errors include specific error codes
|
|
51
|
+
*/
|
|
52
|
+
export declare function hasErrorCode(error: SubmitError, code: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a specific field has a specific error code
|
|
55
|
+
*/
|
|
56
|
+
export declare function hasFieldErrorCode(error: SubmitError, fieldName: string, code: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get all errors with a specific code
|
|
59
|
+
*/
|
|
60
|
+
export declare function getErrorsByCode(error: SubmitError, code: string): FieldValidationError[];
|
|
61
|
+
/**
|
|
62
|
+
* Group errors by their error codes
|
|
63
|
+
*/
|
|
64
|
+
export declare function groupErrorsByCode(error: SubmitError): Record<string, FieldValidationError[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Utility to create field validation error display helpers for common UI frameworks
|
|
67
|
+
*/
|
|
68
|
+
export interface FieldErrorHelpers {
|
|
69
|
+
/**
|
|
70
|
+
* Get error message for a field (empty string if no error)
|
|
71
|
+
*/
|
|
72
|
+
getMessage: (fieldName: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* Check if field has error
|
|
75
|
+
*/
|
|
76
|
+
hasError: (fieldName: string) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Get CSS class names for field error state
|
|
79
|
+
*/
|
|
80
|
+
getFieldClass: (fieldName: string, errorClass?: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Get error object for field (null if no error)
|
|
83
|
+
*/
|
|
84
|
+
getError: (fieldName: string) => FieldValidationError | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create field error helpers for easy UI integration
|
|
88
|
+
*/
|
|
89
|
+
export declare function createFieldErrorHelpers(error: SubmitError | null, defaultErrorClass?: string): FieldErrorHelpers;
|
|
90
|
+
/**
|
|
91
|
+
* Extract field validation errors from any error object
|
|
92
|
+
* Useful when you're not sure if the error is a SubmitError
|
|
93
|
+
*/
|
|
94
|
+
export declare function extractFieldErrors(error: any): FieldValidationError[];
|
|
95
|
+
//# sourceMappingURL=field-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-errors.d.ts","sourceRoot":"","sources":["../src/field-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE/F;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAElE;AAED;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AW,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,EAAE,CAGxF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAY5F;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C;;OAEG;IACH,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC;;OAEG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAClE;;OAEG;IACH,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,oBAAoB,GAAG,IAAI,CAAC;CAC9D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,iBAAiB,GAAE,MAAgB,GAClC,iBAAiB,CAwBnB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,oBAAoB,EAAE,CAmBrE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File handling and validation utilities
|
|
3
|
+
*/
|
|
4
|
+
import type { FileConfig, FileInfo, ProcessedData, Logger } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Validate file against configuration rules
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateFile(file: File, config: Required<FileConfig>): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Format file size for human-readable display
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatFileSize(bytes: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Extract files from form data object
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractFiles(data: Record<string, any>): FileInfo[];
|
|
17
|
+
/**
|
|
18
|
+
* Validate all files in a collection
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateFiles(files: FileInfo[], config: Required<FileConfig>, logger?: Logger): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Process form data and handle files
|
|
23
|
+
*/
|
|
24
|
+
export declare function processFormData(inputData: Record<string, any> | FormData, fileConfig?: Partial<FileConfig>, logger?: Logger): ProcessedData;
|
|
25
|
+
/**
|
|
26
|
+
* Create progress tracker for file uploads
|
|
27
|
+
*/
|
|
28
|
+
export declare function createProgressTracker(files: FileInfo[], onProgress?: (percent: number, loaded: number, total: number) => void): ((progressEvent: ProgressEvent) => void) | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get MIME type from file extension (fallback if browser doesn't detect)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getMimeTypeFromExtension(filename: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Enhanced file information with additional metadata
|
|
35
|
+
*/
|
|
36
|
+
export declare function getEnhancedFileInfo(file: File): FileInfo & {
|
|
37
|
+
extension: string;
|
|
38
|
+
detectedMimeType: string | null;
|
|
39
|
+
isImage: boolean;
|
|
40
|
+
isDocument: boolean;
|
|
41
|
+
isArchive: boolean;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=file-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handler.d.ts","sourceRoot":"","sources":["../src/file-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAe,MAAM,EAAE,MAAM,SAAS,CAAC;AAGxF;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,IAAI,CAwBpF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,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