clickwrap
Version:
Complete clickwrap solution with built-in document viewing. Track agreements, signatures, and consents.
104 lines (89 loc) • 2.66 kB
TypeScript
declare module 'clickwrap' {
export interface Requirements {
scrollThreshold?: number
signature?: boolean
consents?: string[]
}
export interface ConsentState {
[key: string]: boolean
}
export interface Interaction {
type: string
timestamp: string
data?: any
}
export interface ProgressState {
checks: {
scroll?: boolean
signature?: boolean
consents?: boolean
consentDetails?: { [key: string]: boolean }
}
isValid: boolean
state: State
}
export interface State {
scrollProgress: number
hasValidSignature: boolean
consentStates: ConsentState
isInitialized: boolean
startTime: Date
interactions: Interaction[]
}
export interface AgreementData {
timestamp: string
documentId?: string
duration: number
scrollProgress: string
signature?: string | null
signatureFormat?: string | null
consents: ConsentState
interactions: Interaction[]
metadata: any
action?: 'accepted' | 'declined'
}
export interface Progress {
completed: number
total: number
percentage: number
}
export interface Config {
// Document configuration
documentId?: string
documentElement?: HTMLElement
superdocInstance?: any
// UI Components
signaturePad?: any
clearButton?: HTMLElement
undoButton?: HTMLElement
consentElements?: NodeList | HTMLElement[]
acceptButton?: HTMLElement
declineButton?: HTMLElement
// Requirements
requirements?: Requirements
// Metadata
metadata?: any
// Callbacks
onScroll?: (progress: number) => void
onSignature?: (hasSignature: boolean) => void
onConsentChange?: (name: string, checked: boolean) => void
onProgress?: (progress: ProgressState) => void
onAccept?: (data: AgreementData) => void | Promise<void>
onDecline?: (data: AgreementData) => void | Promise<void>
onValidation?: (isValid: boolean, checks: any) => void
}
export default class Clickwrap {
constructor(config?: Config)
config: Config
state: State
init(): void
validate(): boolean
getData(): AgreementData
handleAccept(): Promise<AgreementData | false>
handleDecline(): Promise<AgreementData>
reset(): void
getProgress(): Progress
}
export { Clickwrap }
}
}