@@ -2,15 +2,18 @@ import React, { useEffect, useRef, forwardRef, useImperativeHandle } from 'react
2
2
import { getStroke , type StrokeOptions } from 'perfect-freehand' ;
3
3
import { getSvgPathFromStroke , getBoundingClientRect , getClinetXY , defaultOptions , defaultStyle } from './utils' ;
4
4
5
+ export * from './utils' ;
6
+
5
7
export interface SignatureProps extends React . SVGProps < SVGSVGElement > {
6
8
prefixCls ?: string ;
7
9
options ?: StrokeOptions ;
10
+ onPointer ?: ( points : number [ ] [ ] ) => void ;
8
11
}
9
12
10
13
let points : number [ ] [ ] = [ ] ;
11
14
12
15
const 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 ;
14
17
const cls = [ className , prefixCls ] . filter ( Boolean ) . join ( ' ' ) ;
15
18
const $svg = useRef < SVGSVGElement > ( null ) ;
16
19
const $path = useRef < SVGPathElement > ( ) ;
@@ -40,6 +43,7 @@ const Signature = forwardRef<SVGSVGElement, SignatureProps>((props, ref) => {
40
43
} ;
41
44
42
45
const handlePointerUp = ( ) => {
46
+ onPointer && onPointer ( points ) ;
43
47
points = [ ] ;
44
48
$path . current = undefined ;
45
49
} ;
0 commit comments