File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import { useResolver } from './shared/hooks';
3939import { eventProps , isClassName , isFile , isRef } from './shared/propTypes' ;
4040
4141import type { PDFDocumentProxy } from 'pdfjs-dist' ;
42+ import type { allEvents } from 'make-event-props' ;
4243import type {
4344 ClassName ,
4445 ExternalLinkRel ,
@@ -73,7 +74,15 @@ type OnSourceError = OnError;
7374
7475type OnSourceSuccess = ( ) => void ;
7576
76- type EventProps = ReturnType < typeof makeEventProps > ;
77+ type AllEvents = ( typeof allEvents ) [ number ] ;
78+
79+ type EventHandler = ( event : unknown , ...args : unknown [ ] ) => void ;
80+
81+ type Props = Record < string , unknown > & {
82+ [ K in AllEvents ] ?: EventHandler ;
83+ } ;
84+
85+ type EventProps = ReturnType < typeof makeEventProps < Props , PDFDocumentProxy > > ;
7786
7887type DocumentProps = {
7988 children ?: React . ReactNode ;
Original file line number Diff line number Diff line change @@ -17,11 +17,20 @@ import { useResolver } from './shared/hooks';
1717import { eventProps , isClassName , isPdf , isRef } from './shared/propTypes' ;
1818
1919import type { PDFDocumentProxy } from 'pdfjs-dist' ;
20+ import type { allEvents } from 'make-event-props' ;
2021import type { OnItemClickArgs } from './shared/types' ;
2122
2223type PDFOutline = Awaited < ReturnType < PDFDocumentProxy [ 'getOutline' ] > > ;
2324
24- type EventProps = ReturnType < typeof makeEventProps > ;
25+ type AllEvents = ( typeof allEvents ) [ number ] ;
26+
27+ type EventHandler = ( event : unknown , ...args : unknown [ ] ) => void ;
28+
29+ type Props = Record < string , unknown > & {
30+ [ K in AllEvents ] ?: EventHandler ;
31+ } ;
32+
33+ type EventProps = ReturnType < typeof makeEventProps < Props , PDFOutline | null > > ;
2534
2635type OutlineProps = {
2736 className ?: string ;
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import {
3131} from './shared/propTypes' ;
3232
3333import type { PDFDocumentProxy , PDFPageProxy } from 'pdfjs-dist' ;
34+ import type { allEvents } from 'make-event-props' ;
3435import type {
3536 CustomTextRenderer ,
3637 NodeOrRenderer ,
@@ -46,12 +47,21 @@ import type {
4647 OnRenderSuccess ,
4748 OnRenderTextLayerError ,
4849 OnRenderTextLayerSuccess ,
50+ PageCallback ,
4951 RenderMode ,
5052} from './shared/types' ;
5153
5254const defaultScale = 1 ;
5355
54- type EventProps = ReturnType < typeof makeEventProps > ;
56+ type AllEvents = ( typeof allEvents ) [ number ] ;
57+
58+ type EventHandler = ( event : unknown , ...args : unknown [ ] ) => void ;
59+
60+ type Props = Record < string , unknown > & {
61+ [ K in AllEvents ] ?: EventHandler ;
62+ } ;
63+
64+ type EventProps = ReturnType < typeof makeEventProps < Props , PageCallback > > ;
5565
5666type PageProps = {
5767 canvasBackground ?: string ;
You can’t perform that action at this time.
0 commit comments