@@ -2,15 +2,18 @@ import React, { useEffect, useRef, forwardRef, useImperativeHandle } from 'react
22import { getStroke , type StrokeOptions } from 'perfect-freehand' ;
33import { getSvgPathFromStroke , getBoundingClientRect , getClinetXY , defaultOptions , defaultStyle } from './utils' ;
44
5+ export * from './utils' ;
6+
57export interface SignatureProps extends React . SVGProps < SVGSVGElement > {
68 prefixCls ?: string ;
79 options ?: StrokeOptions ;
10+ onPointer ?: ( points : number [ ] [ ] ) => void ;
811}
912
1013let points : number [ ] [ ] = [ ] ;
1114
1215const Signature = forwardRef < SVGSVGElement , SignatureProps > ( ( props , ref ) => {
13- const { className, prefixCls = 'w-signature' , style, options, ...others } = props ;
16+ const { className, prefixCls = 'w-signature' , style, onPointer , options, ...others } = props ;
1417 const cls = [ className , prefixCls ] . filter ( Boolean ) . join ( ' ' ) ;
1518 const $svg = useRef < SVGSVGElement > ( null ) ;
1619 const $path = useRef < SVGPathElement > ( ) ;
@@ -40,6 +43,7 @@ const Signature = forwardRef<SVGSVGElement, SignatureProps>((props, ref) => {
4043 } ;
4144
4245 const handlePointerUp = ( ) => {
46+ onPointer && onPointer ( points ) ;
4347 points = [ ] ;
4448 $path . current = undefined ;
4549 } ;
0 commit comments