@rem.tools/signt-react-sdk v1.2.10

signt-react-sdk
React components library built for Signt platform from rem.tools
API
Table of Contents
Components
You must use SigntContextProvider as the parent for DocumentPreview and DocumentSignaturePad
SigntContextProvider
packages/signt-react/src/context/SigntContextProvider.tsx:45-55
Use this Provider as the parent of {DocumentSignaturePad} and [DocumentPreview]
Example
<SigntContextProvider
publicUrl='https://xxxx.com'
signerToken='XXXXX'
>
You must write all library components here...
<SigntContextProvider />Parameters
propsSigntContextProps Component properties
DocumentPreview
packages/signt-react/src/components/DocumentPreview.tsx:55-182
Component to render a document from a signer's token, you must wrap this component in order to control size, or use maxWidth and/or maxHeight props, it will resize relatively from parent node size.
Note: You MUST generate the token from a Signer.
Example
<SigntContextProvider
publicUrl='https://xxxx.com'
signerToken='XXXXX'
>
<div style={{ width: '100%', height: '100%' }}>
<DocumentPreview maxHeight={600} />
</div>
</SigntContextProvider>Parameters
propsDocumentPreviewProps Component properties
DocumentSignaturePad
packages/signt-react/src/components/DocumentSignaturePad.tsx:98-167
This components wraps functionality to handle signature pad
Example 1
<SigntContextProvider
publicUrl='https://xxxx.com'
signerToken='XXXXX'
>
<DocumentSignaturePad
onInitialize={() => console.log('DONE!')}
onComplete={() => console.log('COMPLETE!')}
onError={err => console.error(err)}
>
{({ canvasRef, clear, sendSignature, isEmpty }) => (
<>
<Canvas style={{ border: '1px solid black' }} width={400} height={150} canvasRef={canvasRef} />
<button onClick={clear}>Clear</button>
<button disabled={isEmpty} onClick={sendSignature()}>Send</button>
</>
)}
</DocumentSignaturePad>
</SigntContextProvider>Example 2 (With password's signer override)
<SigntContextProvider
publicUrl='https://xxxx.com'
signerToken='XXXXX'
>
<DocumentSignaturePad
onInitialize={() => console.log('DONE!')}
onComplete={() => console.log('COMPLETE!')}
onError={err => console.error(err)}
>
{({ canvasRef, clear, sendSignature }) => (
<>
<Canvas style={{ border: '1px solid black' }} width={400} height={150} canvasRef={canvasRef} />
<button onClick={clear}>Clear</button>
<button onClick={sendSignature('THIS IS A NEW PASSWORD')}>Send</button>
</>
)}
</DocumentSignaturePad>
</SigntContextProvider>Parameters
propsDocumentSignaturePadProps Component properties
Returns RenderChildrenProps
Canvas
packages/signt-react/src/components/Canvas.tsx:22-30
Wraps a canvas element properly to render and adjust over any screen size and DPI, it requires the canvasRef provided by DocumentSignaturePad.
Parameters
propsCanvasProps Component properties
Props Types
Types definitions for components
SigntContextProps
packages/signt-react/src/context/SigntContextProvider.tsx:11-15
Type: {signerToken: string, children: React.ReactNode, publicUrl: string}
Parameters
Properties
DocumentPreviewProps
packages/signt-react/src/components/DocumentPreview.tsx:26-33
Type: {onError: Function?, onLoad: Function?, errorComponent: ReactNode?, loadingComponent: ReactNode?, maxWidth: any?, maxHeight: any?}
Parameters
onErrorFunction? Callback in case of error (optional) (optional, defaultnull)onLoadFunction? Callback on initialized (optional) (optional, defaultnull)errorComponentReactNode? Component to render on PDF viewer error (optional) (optional, defaultnull)loadingComponentReactNode? Component to render on PDF viewer loading (optional) (optional, defaultnull)maxWidthany Max width size from viewer (for responsive purposes) (optional, defaultnull)maxHeightany Max height size from viewer (for responsive purposes) (optional, defaultnull)
Properties
onErrorFunction?onLoadFunction?errorComponentReactNode?loadingComponentReactNode?maxWidthany?maxHeightany?
DocumentSignaturePadProps
packages/signt-react/src/components/DocumentSignaturePad.tsx:31-39
Type: {backgroundColor: String?, penColor: String?, children: function (props: RenderChildrenProps): ReactNode, onError: Function?, onInitialize: function (engine: SignaturePad): void?, onComplete: Function?, destroyTokenOnSign: boolean?}
Parameters
backgroundColorString? Pad's Background color. Note: Be careful with this, this can change the background color generated, don't use if possible. (optional, defaultrgba(0,0,0,0))penColorString? Pad's trace color. (optional, defaultblack)childrenFunction Component body, this must be use as function like theDocumentSignaturePadexample.onErrorFunction? Callback if there's any error (optional, defaultnull)onInitializeFunction? Callback on component initialize, the argument contains aSignaturePadinstance. (optional, defaultnull)destroyTokenOnSignboolean? This destroy the signer token provided onSigntContextProvider(optional, defaultfalse)
Properties
backgroundColorString?penColorString?childrenfunction (props: RenderChildrenProps): ReactNodeonErrorFunction?onInitializefunction (engine: SignaturePad): void?onCompleteFunction?destroyTokenOnSignboolean?
RenderChildrenProps
packages/signt-react/src/components/DocumentSignaturePad.tsx:15-20
This properties are passed to the DocumentSignaturePad body function.
Type: {canvasRef: Ref<(HTMLCanvasElement | null)>, clear: function (): void, isEmpty: boolean, sendSignature: function (password: (String | null)): function (): void}
Parameters
canvasRef(Ref[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) | null) Must use this ref within an<canvas>element, otherwise will throw an Error.clearFunction Clears the signature pad.isEmptyboolean Checks if signature pad is empty, component will be re-rendered on changes.sendSignatureFunction This method sends signature to Signt platform.
Properties
canvasRefRef<(HTMLCanvasElement | null)>clearfunction (): voidisEmptybooleansendSignaturefunction (password: (String | null)): function (): void
CanvasProps
packages/signt-react/src/components/Canvas.tsx:10-15
Type: {canvasRef: Ref[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement), width: any, height: any, style: CSSProperties?}
Parameters
canvasRef(RefObject[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement) | null) Ref passed by DocumentSignaturePadwidthany Any acceptable width value for Reactheightany Any acceptable height value for ReactstyleCSSProperties? Style property passed like any other React Component
Properties
canvasRefRef[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement)widthanyheightanystyleCSSProperties?