Skip to main content
Complete eSign component API

Component Props

Required Props

eventId
string
required
Unique identifier for this signing session
document
object
required
Document configuration
onSubmit
function
required
Called when document is signed
(data: SubmitData) => void | Promise<void>

Optional Props

fields
object
Field configuration
download
object
Download button configuration
submit
object
Submit button configuration
onDownload
function
Handle download action
(data: DownloadData) => void | Promise<void>
onStateChange
function
Monitor state changes
(state: SigningState) => void
onFieldChange
function
Track field changes
(field: FieldChange) => void
onFieldsDiscovered
function
Called when document fields are found
(fields: FieldInfo[]) => void
isDisabled
boolean
Disable all interactions
className
string
CSS class for container
style
React.CSSProperties
Inline styles for container
documentHeight
string
Height of document viewer (default: '600px')

Types

SubmitData

Data passed to onSubmit:
interface SubmitData {
  eventId: string;           // Your session ID
  timestamp: string;         // ISO timestamp
  duration: number;          // Time spent in ms
  auditTrail: AuditEvent[];  // All events
  documentFields: DocumentField[];  // Injected values
  signerFields: SignerFieldValue[]; // User inputs
  isFullyCompleted: boolean; // All requirements met
}

DownloadData

Data passed to onDownload:
interface DownloadData {
  eventId: string;                   // Your session ID
  documentSource: string | File | Blob;  // Original .docx file
  fileName: string;                  // Suggested filename
}

DocumentField

Values injected into document:
interface DocumentField {
  id: string;         // Unique field ID
  value: FieldValue;  // The value
}

SignerField

Interactive field definition:
interface SignerField {
  id: string;                            // Required unique ID
  type: 'signature' | 'checkbox' | 'text';
  label?: string;                         // Display label
  validation?: {
    required?: boolean;
  };
  component?: React.ComponentType<FieldComponentProps>;
}

SigningState

Current state passed to onStateChange:
interface SigningState {
  scrolled: boolean;               // Has scrolled
  fields: Map<string, FieldValue>; // Current values
  isValid: boolean;                // Can submit
  isSubmitting: boolean;            // Currently submitting
}

AuditEvent

Timestamped interaction log:
interface AuditEvent {
  timestamp: string;
  type: 'ready' | 'scroll' | 'field_change' | 'submit';
  data?: Record<string, unknown>;
}

Ref Methods

Access via ref:
const ref = useRef();

// Get current state
const state = ref.current.getState();

// Get audit trail
const audit = ref.current.getAuditTrail();

// Reset everything
ref.current.reset();

return <SuperDocESign ref={ref} ... />

Available methods

  • getState() - Returns current SigningState
  • getAuditTrail() - Returns audit events array
  • reset() - Clear all state and start over

Field Components

Default Components

The component provides default implementations for all field types. You can import and extend them:
import { SignatureInput, CheckboxInput } from '@superdoc-dev/esign';

// Use directly
<SignatureInput 
  value={value}
  onChange={handleChange}
  isDisabled={false}
  label="Sign here"
/>

Custom Component Props

All custom field components receive:
interface FieldComponentProps {
  value: FieldValue;           // Current value
  onChange: (value: FieldValue) => void;
  isDisabled: boolean;         // Disabled state
  isValid?: boolean;           // Validation state
  label?: string;              // Field label
  error?: string;              // Error message
}

CSS Classes

Target these classes for styling:
  • .superdoc-esign-container - Main wrapper
  • .superdoc-esign-document - Document viewer area
  • .superdoc-esign-controls - Controls section
  • .superdoc-esign-fields - Field container
  • .superdoc-esign-actions - Button container
  • .superdoc-esign-btn - Default buttons

Import Types

All types are exported:
import type {
  SuperDocESignProps,
  SubmitData,
  DownloadData,
  SigningState,
  DocumentField,
  SignerField,
  FieldChange,
  AuditEvent,
  FieldComponentProps
} from '@superdoc-dev/esign';
I