1- import React , { useEffect , useRef , useState } from 'react' ;
1+ import { useEffect , useRef , useState , type FC } from 'react' ;
22import SignaturePad from 'signature_pad' ;
33import type { FieldComponentProps } from '@superdoc-dev/esign' ;
44
@@ -17,12 +17,7 @@ const cropSVG = (svgText: string): string => {
1717 if ( bbox . width === 0 || bbox . height === 0 ) return svgText ;
1818
1919 const padding = 5 ;
20- const viewBox = [
21- bbox . x - padding ,
22- bbox . y - padding ,
23- bbox . width + padding * 2 ,
24- bbox . height + padding * 2 ,
25- ] . join ( ' ' ) ;
20+ const viewBox = [ bbox . x - padding , bbox . y - padding , bbox . width + padding * 2 , bbox . height + padding * 2 ] . join ( ' ' ) ;
2621 svgElement . setAttribute ( 'viewBox' , viewBox ) ;
2722 svgElement . setAttribute ( 'width' , String ( Math . ceil ( bbox . width + padding * 2 ) ) ) ;
2823 svgElement . setAttribute ( 'height' , String ( Math . ceil ( bbox . height + padding * 2 ) ) ) ;
@@ -54,7 +49,7 @@ const svgToPngDataUrl = (svgText: string): Promise<string> =>
5449 img . src = svgDataUrl ;
5550 } ) ;
5651
57- const CustomSignature : React . FC < FieldComponentProps > = ( { value, onChange, isDisabled, label } ) => {
52+ const CustomSignature : FC < FieldComponentProps > = ( { value, onChange, isDisabled, label } ) => {
5853 const [ mode , setMode ] = useState < 'type' | 'draw' > ( 'type' ) ;
5954 const canvasRef = useRef < HTMLCanvasElement > ( null ) ;
6055 const signaturePadRef = useRef < SignaturePad | null > ( null ) ;
@@ -164,12 +159,10 @@ const CustomSignature: React.FC<FieldComponentProps> = ({ value, onChange, isDis
164159
165160 return (
166161 < div style = { { display : 'flex' , flexDirection : 'column' , gap : '8px' } } >
167- { label && (
168- < label style = { { fontSize : '14px' , fontWeight : '600' , color : '#1f2937' } } > { label } </ label >
169- ) }
162+ { label && < label style = { { fontSize : '14px' , fontWeight : '600' , color : '#1f2937' } } > { label } </ label > }
170163 < div style = { { display : 'flex' , gap : '8px' , marginBottom : '4px' } } >
171164 < button
172- type = " button"
165+ type = ' button'
173166 onClick = { ( ) => switchMode ( 'type' ) }
174167 disabled = { isDisabled }
175168 style = { {
@@ -185,7 +178,7 @@ const CustomSignature: React.FC<FieldComponentProps> = ({ value, onChange, isDis
185178 Type
186179 </ button >
187180 < button
188- type = " button"
181+ type = ' button'
189182 onClick = { ( ) => switchMode ( 'draw' ) }
190183 disabled = { isDisabled }
191184 style = { {
@@ -203,11 +196,11 @@ const CustomSignature: React.FC<FieldComponentProps> = ({ value, onChange, isDis
203196 </ div >
204197 { mode === 'type' ? (
205198 < input
206- type = " text"
199+ type = ' text'
207200 value = { String ( value || '' ) }
208201 onChange = { ( e ) => onChange ( e . target . value ) }
209202 disabled = { isDisabled }
210- placeholder = " Type your full name"
203+ placeholder = ' Type your full name'
211204 style = { {
212205 fontFamily : 'cursive' ,
213206 fontSize : '20px' ,
@@ -234,7 +227,7 @@ const CustomSignature: React.FC<FieldComponentProps> = ({ value, onChange, isDis
234227 } }
235228 />
236229 < button
237- type = " button"
230+ type = ' button'
238231 onClick = { clearCanvas }
239232 disabled = { isDisabled }
240233 style = { {
0 commit comments