@drvillo/react-browser-e-signing 0.3.1 → 0.4.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/INTEGRATION_GUIDELINES.md +197 -16
- package/dist/index.d.ts +41 -8
- package/dist/index.js +257 -70
- package/dist/index.js.map +1 -1
- package/dist/styles.css +73 -7
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- import `getPdfWorkerSrc` from `@drvillo/react-browser-e-signing/worker`
|
|
12
12
|
- call `configure({ pdfWorkerSrc: getPdfWorkerSrc() })`
|
|
13
13
|
|
|
14
|
-
## 2) Full Public API
|
|
14
|
+
## 2) Full Public API
|
|
15
15
|
|
|
16
16
|
### 2.1 Components
|
|
17
17
|
|
|
@@ -49,6 +49,8 @@ interface FieldOverlayProps {
|
|
|
49
49
|
onAddField: (input: { pageIndex: number; type: FieldType; xPercent: number; yPercent: number }) => void
|
|
50
50
|
onUpdateField: (fieldId: string, partial: Partial<FieldPlacement>) => void
|
|
51
51
|
onRemoveField: (fieldId: string) => void
|
|
52
|
+
onUpdateCustomValue?: (label: string, value: string) => void
|
|
53
|
+
onCustomFieldRenamed?: (oldLabel: string, newLabel: string) => void
|
|
52
54
|
preview: SignatureFieldPreview
|
|
53
55
|
className?: string
|
|
54
56
|
}
|
|
@@ -60,6 +62,8 @@ interface SignatureFieldProps {
|
|
|
60
62
|
onUpdateField: (fieldId: string, partial: Partial<FieldPlacement>) => void
|
|
61
63
|
onRemoveField: (fieldId: string) => void
|
|
62
64
|
preview: SignatureFieldPreview
|
|
65
|
+
onUpdateCustomValue?: (label: string, value: string) => void
|
|
66
|
+
onCustomFieldRenamed?: (oldLabel: string, newLabel: string) => void
|
|
63
67
|
className?: string
|
|
64
68
|
}
|
|
65
69
|
```
|
|
@@ -68,6 +72,18 @@ interface SignatureFieldProps {
|
|
|
68
72
|
interface FieldPaletteProps {
|
|
69
73
|
selectedFieldType: FieldType | null
|
|
70
74
|
onSelectFieldType: (fieldType: FieldType | null) => void
|
|
75
|
+
fieldTypes?: FieldType[] // defaults to ['signature', 'fullName', 'title', 'date'] — excludes 'custom'
|
|
76
|
+
className?: string
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
interface CustomFieldsPanelProps {
|
|
82
|
+
fields: FieldPlacement[]
|
|
83
|
+
values: Record<string, string>
|
|
84
|
+
onValuesChange: (nextValues: Record<string, string>) => void
|
|
85
|
+
isPlacingField: boolean
|
|
86
|
+
onTogglePlacing: () => void
|
|
71
87
|
className?: string
|
|
72
88
|
}
|
|
73
89
|
```
|
|
@@ -134,9 +150,10 @@ function usePdfDocument(pdfInput: PdfInput): {
|
|
|
134
150
|
function useFieldPlacement(options?: {
|
|
135
151
|
defaultWidthPercent?: number
|
|
136
152
|
defaultHeightPercent?: number
|
|
153
|
+
initialFields?: FieldPlacement[]
|
|
137
154
|
}): {
|
|
138
155
|
fields: FieldPlacement[]
|
|
139
|
-
addField: (input: { pageIndex: number; type: FieldType; xPercent: number; yPercent: number }) => FieldPlacement
|
|
156
|
+
addField: (input: { pageIndex: number; type: FieldType; xPercent: number; yPercent: number; label?: string }) => FieldPlacement
|
|
140
157
|
updateField: (id: string, partial: Partial<FieldPlacement>) => void
|
|
141
158
|
removeField: (id: string) => void
|
|
142
159
|
clearFields: () => void
|
|
@@ -172,7 +189,7 @@ function usePdfPageVisibility(options: UsePdfPageVisibilityOptions): UsePdfPageV
|
|
|
172
189
|
### 2.3 Types
|
|
173
190
|
|
|
174
191
|
```ts
|
|
175
|
-
type FieldType = 'signature' | 'fullName' | 'title' | 'date'
|
|
192
|
+
type FieldType = 'signature' | 'fullName' | 'title' | 'date' | 'custom'
|
|
176
193
|
|
|
177
194
|
interface FieldPlacement {
|
|
178
195
|
id: string
|
|
@@ -182,12 +199,14 @@ interface FieldPlacement {
|
|
|
182
199
|
yPercent: number
|
|
183
200
|
widthPercent: number
|
|
184
201
|
heightPercent: number
|
|
202
|
+
label?: string // required for 'custom' fields; used as the key in SignerInfo.customFields
|
|
185
203
|
}
|
|
186
204
|
|
|
187
205
|
interface SignerInfo {
|
|
188
206
|
firstName: string
|
|
189
207
|
lastName: string
|
|
190
208
|
title: string
|
|
209
|
+
customFields?: Record<string, string>
|
|
191
210
|
}
|
|
192
211
|
|
|
193
212
|
type SignatureStyle =
|
|
@@ -210,6 +229,7 @@ interface SignatureFieldPreview {
|
|
|
210
229
|
fullName: string
|
|
211
230
|
title: string
|
|
212
231
|
dateText: string
|
|
232
|
+
customFields?: Record<string, string>
|
|
213
233
|
}
|
|
214
234
|
```
|
|
215
235
|
|
|
@@ -284,6 +304,13 @@ const SLOTS = {
|
|
|
284
304
|
signatureFieldPreviewText: 'signature-field-preview-text',
|
|
285
305
|
signatureFieldRemove: 'signature-field-remove',
|
|
286
306
|
signatureFieldResize: 'signature-field-resize',
|
|
307
|
+
signatureFieldLabelInput: 'signature-field-label-input',
|
|
308
|
+
signatureFieldValueInput: 'signature-field-value-input',
|
|
309
|
+
customFieldsPanel: 'custom-fields-panel',
|
|
310
|
+
customFieldsPanelHeading: 'custom-fields-panel-heading',
|
|
311
|
+
customFieldsPanelLabel: 'custom-fields-panel-label',
|
|
312
|
+
customFieldsPanelInput: 'custom-fields-panel-input',
|
|
313
|
+
customFieldsPanelAddButton: 'custom-fields-panel-add-button',
|
|
287
314
|
fieldPalette: 'field-palette',
|
|
288
315
|
fieldPaletteButton: 'field-palette-button',
|
|
289
316
|
signerPanel: 'signer-panel',
|
|
@@ -315,7 +342,7 @@ const SLOTS = {
|
|
|
315
342
|
} as const
|
|
316
343
|
```
|
|
317
344
|
|
|
318
|
-
## 3) Multi-Page behavior
|
|
345
|
+
## 3) Multi-Page behavior
|
|
319
346
|
|
|
320
347
|
- `pageMode='scroll'`:
|
|
321
348
|
- all pages rendered in vertical stack
|
|
@@ -329,7 +356,91 @@ const SLOTS = {
|
|
|
329
356
|
- add `FieldPalette`, `PdfPageNavigator`, or custom controls directly in viewer toolbar
|
|
330
357
|
- avoids losing field placement controls while moving across pages
|
|
331
358
|
|
|
332
|
-
## 4)
|
|
359
|
+
## 4) Custom fields wiring
|
|
360
|
+
|
|
361
|
+
Custom fields let consumers add freeform labeled fields to any PDF. The workflow is: place → label inline → optionally fill value inline or via `CustomFieldsPanel`.
|
|
362
|
+
|
|
363
|
+
### State the consumer owns
|
|
364
|
+
|
|
365
|
+
```tsx
|
|
366
|
+
const [selectedFieldType, setSelectedFieldType] = useState<FieldType | null>(null)
|
|
367
|
+
const [customFieldValues, setCustomFieldValues] = useState<Record<string, string>>({})
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Wire `CustomFieldsPanel` to drive placement
|
|
371
|
+
|
|
372
|
+
```tsx
|
|
373
|
+
<CustomFieldsPanel
|
|
374
|
+
fields={fields}
|
|
375
|
+
values={customFieldValues}
|
|
376
|
+
onValuesChange={setCustomFieldValues}
|
|
377
|
+
isPlacingField={selectedFieldType === 'custom'}
|
|
378
|
+
onTogglePlacing={() =>
|
|
379
|
+
setSelectedFieldType((prev) => (prev === 'custom' ? null : 'custom'))
|
|
380
|
+
}
|
|
381
|
+
/>
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
`isPlacingField` tells the panel which state to show ("Click on the PDF to place…" vs. "+ New field"). `onTogglePlacing` hands control of `selectedFieldType` back to the consumer so `FieldOverlay` also responds correctly.
|
|
385
|
+
|
|
386
|
+
### Wire `FieldOverlay` for placement, value updates, and renames
|
|
387
|
+
|
|
388
|
+
```tsx
|
|
389
|
+
renderOverlay={(pageIndex) => (
|
|
390
|
+
<FieldOverlay
|
|
391
|
+
pageIndex={pageIndex}
|
|
392
|
+
fields={fields}
|
|
393
|
+
selectedFieldType={selectedFieldType}
|
|
394
|
+
onAddField={(input) => { addField(input); setSelectedFieldType(null) }}
|
|
395
|
+
onUpdateField={updateField}
|
|
396
|
+
onRemoveField={removeField}
|
|
397
|
+
onUpdateCustomValue={(label, value) =>
|
|
398
|
+
setCustomFieldValues((prev) => ({ ...prev, [label]: value }))
|
|
399
|
+
}
|
|
400
|
+
onCustomFieldRenamed={(oldLabel, newLabel) =>
|
|
401
|
+
setCustomFieldValues((prev) => {
|
|
402
|
+
const { [oldLabel]: value, ...rest } = prev
|
|
403
|
+
return { ...rest, [newLabel]: value ?? '' }
|
|
404
|
+
})
|
|
405
|
+
}
|
|
406
|
+
preview={fieldPreview}
|
|
407
|
+
/>
|
|
408
|
+
)}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
`onUpdateCustomValue` fires when the user commits a value via inline editing inside `SignatureField`. `onCustomFieldRenamed` fires when the user renames a label; the consumer must migrate any stored value from the old key to the new key.
|
|
412
|
+
|
|
413
|
+
### Inline editing UX (managed by `SignatureField`)
|
|
414
|
+
|
|
415
|
+
When a custom field is placed without a label:
|
|
416
|
+
1. `SignatureField` immediately enters label-editing mode and focuses the label input.
|
|
417
|
+
2. The user types a label and commits with Enter, Tab, or blur.
|
|
418
|
+
3. On Tab or Enter the field transitions to value-editing mode; on blur/Escape it returns to idle.
|
|
419
|
+
4. When the value is committed, `onUpdateCustomValue(label, value)` fires and `CustomFieldsPanel` updates.
|
|
420
|
+
|
|
421
|
+
Consumers can also edit values directly in `CustomFieldsPanel` — both paths write to the same `customFieldValues` map.
|
|
422
|
+
|
|
423
|
+
### Pass custom values to `modifyPdf`
|
|
424
|
+
|
|
425
|
+
```tsx
|
|
426
|
+
const signerWithCustomFields: SignerInfo = {
|
|
427
|
+
...signerInfo,
|
|
428
|
+
customFields: customFieldValues,
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const signedPdfBytes = await modifyPdf({
|
|
432
|
+
pdfBytes: inputBytes,
|
|
433
|
+
fields,
|
|
434
|
+
signer: signerWithCustomFields,
|
|
435
|
+
signatureDataUrl,
|
|
436
|
+
pageDimensions,
|
|
437
|
+
dateText,
|
|
438
|
+
})
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
`modifyPdf` reads `signer.customFields[field.label]` for each `type === 'custom'` field and stamps the value onto the PDF.
|
|
442
|
+
|
|
443
|
+
## 5) Required wiring for page-aware UI
|
|
333
444
|
|
|
334
445
|
```tsx
|
|
335
446
|
const viewerContainerRef = useRef<HTMLDivElement | null>(null)
|
|
@@ -365,9 +476,18 @@ const { currentPageIndex, scrollToPage } = usePdfPageVisibility({
|
|
|
365
476
|
pageIndex={pageIndex}
|
|
366
477
|
fields={fields}
|
|
367
478
|
selectedFieldType={selectedFieldType}
|
|
368
|
-
onAddField={
|
|
479
|
+
onAddField={(input) => { addField(input); setSelectedFieldType(null) }}
|
|
369
480
|
onUpdateField={updateField}
|
|
370
481
|
onRemoveField={removeField}
|
|
482
|
+
onUpdateCustomValue={(label, value) =>
|
|
483
|
+
setCustomFieldValues((prev) => ({ ...prev, [label]: value }))
|
|
484
|
+
}
|
|
485
|
+
onCustomFieldRenamed={(oldLabel, newLabel) =>
|
|
486
|
+
setCustomFieldValues((prev) => {
|
|
487
|
+
const { [oldLabel]: value, ...rest } = prev
|
|
488
|
+
return { ...rest, [newLabel]: value ?? '' }
|
|
489
|
+
})
|
|
490
|
+
}
|
|
371
491
|
preview={fieldPreview}
|
|
372
492
|
/>
|
|
373
493
|
)}
|
|
@@ -375,7 +495,7 @@ const { currentPageIndex, scrollToPage } = usePdfPageVisibility({
|
|
|
375
495
|
</div>
|
|
376
496
|
```
|
|
377
497
|
|
|
378
|
-
##
|
|
498
|
+
## 6) Composition patterns
|
|
379
499
|
|
|
380
500
|
### PatternA_desktopStickySidebar
|
|
381
501
|
|
|
@@ -386,6 +506,13 @@ const { currentPageIndex, scrollToPage } = usePdfPageVisibility({
|
|
|
386
506
|
```tsx
|
|
387
507
|
<aside className="space-y-4 lg:sticky lg:top-6 lg:self-start">
|
|
388
508
|
<SignerDetailsPanel signerInfo={signerInfo} onSignerInfoChange={setSignerInfo} />
|
|
509
|
+
<CustomFieldsPanel
|
|
510
|
+
fields={fields}
|
|
511
|
+
values={customFieldValues}
|
|
512
|
+
onValuesChange={setCustomFieldValues}
|
|
513
|
+
isPlacingField={selectedFieldType === 'custom'}
|
|
514
|
+
onTogglePlacing={() => setSelectedFieldType((prev) => (prev === 'custom' ? null : 'custom'))}
|
|
515
|
+
/>
|
|
389
516
|
<SignaturePreview
|
|
390
517
|
signerName={displayName}
|
|
391
518
|
style={signatureStyle}
|
|
@@ -430,17 +557,64 @@ const handlePageChange = (pageIndex: number) =>
|
|
|
430
557
|
- no sidebar
|
|
431
558
|
- recommended for constrained panes/modals
|
|
432
559
|
|
|
433
|
-
|
|
560
|
+
### PatternF_customFields
|
|
561
|
+
|
|
562
|
+
- Use `CustomFieldsPanel` in the sidebar; it owns the "+ New field" button
|
|
563
|
+
- Do not add `'custom'` to `FieldPalette.fieldTypes` when `CustomFieldsPanel` is present — each is a standalone entry point
|
|
564
|
+
- When the user clicks "+ New field", `onTogglePlacing` sets `selectedFieldType = 'custom'`; `FieldOverlay` enters crosshair mode
|
|
565
|
+
- After placement, `SignatureField` auto-enters label-edit mode; Tab/Enter transitions to value-edit mode
|
|
566
|
+
- `onUpdateCustomValue` and `onCustomFieldRenamed` propagate changes back to consumer state
|
|
567
|
+
- `CustomFieldsPanel` re-renders automatically once `fields` contains entries with labels
|
|
434
568
|
|
|
435
|
-
|
|
569
|
+
```tsx
|
|
570
|
+
// Minimal custom fields integration
|
|
571
|
+
const [customFieldValues, setCustomFieldValues] = useState<Record<string, string>>({})
|
|
572
|
+
|
|
573
|
+
<CustomFieldsPanel
|
|
574
|
+
fields={fields}
|
|
575
|
+
values={customFieldValues}
|
|
576
|
+
onValuesChange={setCustomFieldValues}
|
|
577
|
+
isPlacingField={selectedFieldType === 'custom'}
|
|
578
|
+
onTogglePlacing={() => setSelectedFieldType((prev) => (prev === 'custom' ? null : 'custom'))}
|
|
579
|
+
/>
|
|
580
|
+
|
|
581
|
+
// In renderOverlay:
|
|
582
|
+
onUpdateCustomValue={(label, value) =>
|
|
583
|
+
setCustomFieldValues((prev) => ({ ...prev, [label]: value }))
|
|
584
|
+
}
|
|
585
|
+
onCustomFieldRenamed={(oldLabel, newLabel) =>
|
|
586
|
+
setCustomFieldValues((prev) => {
|
|
587
|
+
const { [oldLabel]: value, ...rest } = prev
|
|
588
|
+
return { ...rest, [newLabel]: value ?? '' }
|
|
589
|
+
})
|
|
590
|
+
}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
## 7) Field placement data flow
|
|
594
|
+
|
|
595
|
+
### Standard field placement (palette-based)
|
|
596
|
+
|
|
597
|
+
1. User toggles a field type in `FieldPalette`
|
|
436
598
|
2. `FieldOverlay` enters placing mode (`data-state='placing'`, crosshair cursor)
|
|
437
|
-
3.
|
|
438
|
-
4.
|
|
439
|
-
5. `useFieldPlacement.addField
|
|
440
|
-
6. `
|
|
441
|
-
7. `
|
|
599
|
+
3. User clicks on the overlay on the target page
|
|
600
|
+
4. Overlay computes `xPercent/yPercent` from click position relative to page
|
|
601
|
+
5. `onAddField` calls `useFieldPlacement.addField`, which appends a `FieldPlacement` with a unique `id`
|
|
602
|
+
6. Consumer resets `selectedFieldType` to `null`
|
|
603
|
+
7. `SignatureField` supports drag-to-move + corner resize
|
|
604
|
+
8. `modifyPdf` maps `xPercent/yPercent/widthPercent/heightPercent` to PDF points via `mapToPoints` per page
|
|
605
|
+
|
|
606
|
+
### Custom field placement
|
|
607
|
+
|
|
608
|
+
Steps 1–8 above apply, plus:
|
|
442
609
|
|
|
443
|
-
|
|
610
|
+
9. `SignatureField` immediately enters label-edit mode (no label yet)
|
|
611
|
+
10. User types a label and commits → `onUpdateField(id, { label })` fires
|
|
612
|
+
11. If committed via Tab or Enter, value-edit mode activates → `onUpdateCustomValue(label, value)` fires on blur
|
|
613
|
+
12. `CustomFieldsPanel` derives its displayed fields from `fields.filter(f => f.type === 'custom' && f.label)`
|
|
614
|
+
13. On rename: `onCustomFieldRenamed(oldLabel, newLabel)` → consumer migrates value key
|
|
615
|
+
14. At export, `modifyPdf` draws a white background over the field area and stamps `signer.customFields[field.label]`
|
|
616
|
+
|
|
617
|
+
## 8) Decision tree (agent-optimized)
|
|
444
618
|
|
|
445
619
|
```txt
|
|
446
620
|
IF desktop-first:
|
|
@@ -458,14 +632,21 @@ IF multi-step signing flow:
|
|
|
458
632
|
IF embedded in modal or constrained panel:
|
|
459
633
|
use PatternE_embeddedMinimal
|
|
460
634
|
|
|
635
|
+
IF document has freeform labeled fields:
|
|
636
|
+
use PatternF_customFields
|
|
637
|
+
|
|
461
638
|
IF documents are usually 1-2 pages:
|
|
462
639
|
default scroll mode is enough
|
|
463
640
|
```
|
|
464
641
|
|
|
465
|
-
##
|
|
642
|
+
## 9) Consumer responsibilities
|
|
466
643
|
|
|
467
644
|
- manage layout (sticky/fixed/sidebar/wizard)
|
|
468
645
|
- manage app-level validation and confirmation UX
|
|
469
646
|
- manage final download flow and success state
|
|
470
647
|
- choose mobile/desktop strategy (`scroll` vs `single`)
|
|
471
648
|
- style components via default `styles.css` or custom `[data-slot]` selectors
|
|
649
|
+
- own `customFieldValues: Record<string, string>` state and pass it into `SignerInfo.customFields` before calling `modifyPdf`
|
|
650
|
+
- handle `onUpdateCustomValue` to merge inline-edited values into `customFieldValues`
|
|
651
|
+
- handle `onCustomFieldRenamed` to migrate the value stored under the old label key to the new key
|
|
652
|
+
- render `CustomFieldsPanel` (or equivalent custom UI) to let signers fill custom field values and trigger placement mode
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ interface PdfPageNavigatorProps {
|
|
|
53
53
|
}
|
|
54
54
|
declare function PdfPageNavigator({ currentPageIndex, numPages, onPageChange, className }: PdfPageNavigatorProps): react_jsx_runtime.JSX.Element;
|
|
55
55
|
|
|
56
|
-
type FieldType = 'signature' | 'fullName' | 'title' | 'date';
|
|
56
|
+
type FieldType = 'signature' | 'fullName' | 'title' | 'date' | 'custom';
|
|
57
57
|
interface FieldPlacement {
|
|
58
58
|
id: string;
|
|
59
59
|
type: FieldType;
|
|
@@ -62,12 +62,13 @@ interface FieldPlacement {
|
|
|
62
62
|
yPercent: number;
|
|
63
63
|
widthPercent: number;
|
|
64
64
|
heightPercent: number;
|
|
65
|
-
|
|
65
|
+
label?: string;
|
|
66
66
|
}
|
|
67
67
|
interface SignerInfo {
|
|
68
68
|
firstName: string;
|
|
69
69
|
lastName: string;
|
|
70
70
|
title: string;
|
|
71
|
+
customFields?: Record<string, string>;
|
|
71
72
|
}
|
|
72
73
|
interface SignatureStyleTyped {
|
|
73
74
|
mode: 'typed';
|
|
@@ -98,6 +99,7 @@ interface SignatureFieldPreview {
|
|
|
98
99
|
fullName: string;
|
|
99
100
|
title: string;
|
|
100
101
|
dateText: string;
|
|
102
|
+
customFields?: Record<string, string>;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
interface FieldOverlayProps {
|
|
@@ -112,26 +114,31 @@ interface FieldOverlayProps {
|
|
|
112
114
|
}) => void;
|
|
113
115
|
onUpdateField: (fieldId: string, partial: Partial<FieldPlacement>) => void;
|
|
114
116
|
onRemoveField: (fieldId: string) => void;
|
|
117
|
+
onUpdateCustomValue?: (label: string, value: string) => void;
|
|
118
|
+
onCustomFieldRenamed?: (oldLabel: string, newLabel: string) => void;
|
|
115
119
|
preview: SignatureFieldPreview;
|
|
116
120
|
className?: string;
|
|
117
121
|
}
|
|
118
|
-
declare function FieldOverlay({ pageIndex, fields, selectedFieldType, onAddField, onUpdateField, onRemoveField, preview, className, }: FieldOverlayProps): react_jsx_runtime.JSX.Element;
|
|
122
|
+
declare function FieldOverlay({ pageIndex, fields, selectedFieldType, onAddField, onUpdateField, onRemoveField, onUpdateCustomValue, onCustomFieldRenamed, preview, className, }: FieldOverlayProps): react_jsx_runtime.JSX.Element;
|
|
119
123
|
|
|
120
124
|
interface SignatureFieldProps {
|
|
121
125
|
field: FieldPlacement;
|
|
122
126
|
onUpdateField: (fieldId: string, partial: Partial<FieldPlacement>) => void;
|
|
123
127
|
onRemoveField: (fieldId: string) => void;
|
|
124
128
|
preview: SignatureFieldPreview;
|
|
129
|
+
onUpdateCustomValue?: (label: string, value: string) => void;
|
|
130
|
+
onCustomFieldRenamed?: (oldLabel: string, newLabel: string) => void;
|
|
125
131
|
className?: string;
|
|
126
132
|
}
|
|
127
|
-
declare function SignatureField({ field, onUpdateField, onRemoveField, preview, className }: SignatureFieldProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
declare function SignatureField({ field, onUpdateField, onRemoveField, preview, onUpdateCustomValue, onCustomFieldRenamed, className, }: SignatureFieldProps): react_jsx_runtime.JSX.Element;
|
|
128
134
|
|
|
129
135
|
interface FieldPaletteProps {
|
|
130
136
|
selectedFieldType: FieldType | null;
|
|
131
137
|
onSelectFieldType: (fieldType: FieldType | null) => void;
|
|
138
|
+
fieldTypes?: FieldType[];
|
|
132
139
|
className?: string;
|
|
133
140
|
}
|
|
134
|
-
declare function FieldPalette({ selectedFieldType, onSelectFieldType, className }: FieldPaletteProps): react_jsx_runtime.JSX.Element;
|
|
141
|
+
declare function FieldPalette({ selectedFieldType, onSelectFieldType, fieldTypes, className }: FieldPaletteProps): react_jsx_runtime.JSX.Element;
|
|
135
142
|
|
|
136
143
|
interface SignerDetailsPanelProps {
|
|
137
144
|
signerInfo: SignerInfo;
|
|
@@ -168,6 +175,24 @@ interface SigningCompleteProps {
|
|
|
168
175
|
}
|
|
169
176
|
declare function SigningComplete({ signerName, fieldCount, signedAt, documentHash, downloadUrl, fileName, onReset, className, }: SigningCompleteProps): react_jsx_runtime.JSX.Element;
|
|
170
177
|
|
|
178
|
+
interface CustomFieldInputsProps {
|
|
179
|
+
labels: string[];
|
|
180
|
+
values: Record<string, string>;
|
|
181
|
+
onValuesChange: (nextValues: Record<string, string>) => void;
|
|
182
|
+
className?: string;
|
|
183
|
+
}
|
|
184
|
+
declare function CustomFieldInputs({ labels, values, onValuesChange, className }: CustomFieldInputsProps): react_jsx_runtime.JSX.Element | null;
|
|
185
|
+
|
|
186
|
+
interface CustomFieldsPanelProps {
|
|
187
|
+
fields: FieldPlacement[];
|
|
188
|
+
values: Record<string, string>;
|
|
189
|
+
onValuesChange: (values: Record<string, string>) => void;
|
|
190
|
+
isPlacingField: boolean;
|
|
191
|
+
onTogglePlacing: () => void;
|
|
192
|
+
className?: string;
|
|
193
|
+
}
|
|
194
|
+
declare function CustomFieldsPanel({ fields, values, onValuesChange, isPlacingField, onTogglePlacing, className, }: CustomFieldsPanelProps): react_jsx_runtime.JSX.Element;
|
|
195
|
+
|
|
171
196
|
type PdfInput = File | Blob | ArrayBuffer | Uint8Array | null;
|
|
172
197
|
declare function usePdfDocument(pdfInput: PdfInput): {
|
|
173
198
|
pdfData: ArrayBuffer | null;
|
|
@@ -209,9 +234,11 @@ interface AddFieldInput {
|
|
|
209
234
|
type: FieldType;
|
|
210
235
|
xPercent: number;
|
|
211
236
|
yPercent: number;
|
|
237
|
+
label?: string;
|
|
212
238
|
}
|
|
213
239
|
declare function useFieldPlacement(options?: UseFieldPlacementOptions): {
|
|
214
|
-
addField: ({ pageIndex, type, xPercent, yPercent }: AddFieldInput) => FieldPlacement;
|
|
240
|
+
addField: ({ pageIndex, type, xPercent, yPercent, label }: AddFieldInput) => FieldPlacement;
|
|
241
|
+
appendFields: (nextFields: FieldPlacement[]) => void;
|
|
215
242
|
updateField: (id: string, partial: Partial<FieldPlacement>) => void;
|
|
216
243
|
removeField: (id: string) => void;
|
|
217
244
|
clearFields: () => void;
|
|
@@ -267,7 +294,13 @@ declare const SLOTS: {
|
|
|
267
294
|
readonly signatureFieldPreviewText: "signature-field-preview-text";
|
|
268
295
|
readonly signatureFieldRemove: "signature-field-remove";
|
|
269
296
|
readonly signatureFieldResize: "signature-field-resize";
|
|
270
|
-
readonly
|
|
297
|
+
readonly signatureFieldLabelInput: "signature-field-label-input";
|
|
298
|
+
readonly signatureFieldValueInput: "signature-field-value-input";
|
|
299
|
+
readonly customFieldsPanel: "custom-fields-panel";
|
|
300
|
+
readonly customFieldsPanelHeading: "custom-fields-panel-heading";
|
|
301
|
+
readonly customFieldsPanelLabel: "custom-fields-panel-label";
|
|
302
|
+
readonly customFieldsPanelInput: "custom-fields-panel-input";
|
|
303
|
+
readonly customFieldsPanelAddButton: "custom-fields-panel-add-button";
|
|
271
304
|
readonly fieldPalette: "field-palette";
|
|
272
305
|
readonly fieldPaletteButton: "field-palette-button";
|
|
273
306
|
readonly signerPanel: "signer-panel";
|
|
@@ -304,4 +337,4 @@ declare const defaults: {
|
|
|
304
337
|
readonly DEFAULT_FIELD_HEIGHT_PERCENT: 5;
|
|
305
338
|
};
|
|
306
339
|
|
|
307
|
-
export { type ESigningConfig, FieldOverlay, FieldPalette, type FieldPlacement, type FieldType, type PdfPageDimensions, PdfPageNavigator, PdfViewer, SIGNATURE_FONTS, SLOTS, SignatureField, type SignatureFieldPreview, type SignatureFontWarning, SignaturePad, SignaturePreview, type SignatureStyle, SignerDetailsPanel, type SignerInfo, SigningComplete, type SigningResult, type UsePdfPageVisibilityOptions, type UsePdfPageVisibilityReturn, configure, defaults, loadSignatureFont, mapFromPoints, mapToPoints, modifyPdf, sha256, useFieldPlacement, usePdfDocument, usePdfPageVisibility, useSignatureRenderer };
|
|
340
|
+
export { CustomFieldInputs, CustomFieldsPanel, type ESigningConfig, FieldOverlay, FieldPalette, type FieldPlacement, type FieldType, type PdfPageDimensions, PdfPageNavigator, PdfViewer, SIGNATURE_FONTS, SLOTS, SignatureField, type SignatureFieldPreview, type SignatureFontWarning, SignaturePad, SignaturePreview, type SignatureStyle, SignerDetailsPanel, type SignerInfo, SigningComplete, type SigningResult, type UsePdfPageVisibilityOptions, type UsePdfPageVisibilityReturn, configure, defaults, loadSignatureFont, mapFromPoints, mapToPoints, modifyPdf, sha256, useFieldPlacement, usePdfDocument, usePdfPageVisibility, useSignatureRenderer };
|