fix: form creator bug and added tests

This commit is contained in:
alam00000
2026-03-12 18:37:35 +05:30
parent e55c2f6b6a
commit e117ab93bd
5 changed files with 962 additions and 268 deletions

View File

@@ -1,16 +1,57 @@
export const FORM_CREATOR_FIELD_TYPES = [
'text',
'checkbox',
'radio',
'dropdown',
'optionlist',
'button',
'signature',
'date',
'image',
'barcode',
] as const;
export type FormCreatorFieldType = (typeof FORM_CREATOR_FIELD_TYPES)[number];
export interface ExtractionViewportMetrics {
pdfViewerOffset: {
x: number;
y: number;
};
pdfViewerScale: number;
}
export interface ExtractExistingFieldsOptions {
pdfDoc: import('pdf-lib').PDFDocument;
fieldCounterStart: number;
metrics: ExtractionViewportMetrics;
}
export interface ExtractExistingFieldsResult {
fields: FormField[];
extractedFieldNames: Set<string>;
nextFieldCounter: number;
}
export interface ExtractedFieldLike {
type: 'text' | 'radio';
name: string;
pageIndex: number;
x: number;
y: number;
width: number;
height: number;
tooltip: string;
required: boolean;
readOnly: boolean;
checked?: boolean;
exportValue?: string;
groupName?: string;
}
export interface FormField {
id: string;
type:
| 'text'
| 'checkbox'
| 'radio'
| 'dropdown'
| 'optionlist'
| 'button'
| 'signature'
| 'date'
| 'image'
| 'barcode';
type: FormCreatorFieldType;
x: number;
y: number;
width: number;