|
1 | 1 | import * as React from 'react'; |
2 | 2 | import {default as tippyCore, Instance, Props, Plugin} from 'tippy.js'; |
3 | 3 |
|
4 | | -export interface TippyProps extends Omit<Partial<Props>, 'content'> { |
| 4 | +type KnownKeys<T> = { |
| 5 | + [K in keyof T]: string extends K ? never : number extends K ? never : K; |
| 6 | +} extends {[_ in keyof T]: infer U} |
| 7 | + ? U |
| 8 | + : never; |
| 9 | + |
| 10 | +export type KnownProps = Pick<Props, KnownKeys<Props>>; |
| 11 | + |
| 12 | +export interface TippyProps extends Omit<Partial<KnownProps>, 'content'> { |
5 | 13 | content: React.ReactChild | React.ReactChild[]; |
6 | 14 | children: React.ReactElement<any>; |
7 | 15 | visible?: boolean; |
8 | 16 | enabled?: boolean; |
9 | 17 | className?: string; |
10 | 18 | plugins?: Plugin[]; |
11 | 19 | singleton?: (instance: Instance) => void; |
| 20 | + [key: string]: any; |
12 | 21 | } |
13 | 22 |
|
14 | 23 | declare const Tippy: React.ForwardRefExoticComponent<TippyProps>; |
15 | 24 | export default Tippy; |
16 | 25 |
|
17 | 26 | export const tippy: typeof tippyCore; |
18 | 27 |
|
19 | | -export interface TippySingletonProps extends Partial<Props> { |
| 28 | +export interface TippySingletonProps extends Partial<KnownProps> { |
20 | 29 | children: Array<React.ReactElement<any>>; |
21 | 30 | className?: string; |
22 | 31 | plugins?: Plugin[]; |
| 32 | + [key: string]: any; |
23 | 33 | } |
24 | 34 |
|
25 | 35 | export const TippySingleton: React.FunctionComponent<TippySingletonProps>; |
26 | 36 |
|
27 | | -export type UseSingletonProps = Omit<TippySingletonProps, 'children'>; |
| 37 | +type KnownSingletonProps = Pick< |
| 38 | + TippySingletonProps, |
| 39 | + KnownKeys<TippySingletonProps> |
| 40 | +>; |
| 41 | + |
| 42 | +export interface UseSingletonProps |
| 43 | + extends Omit<KnownSingletonProps, 'children'> { |
| 44 | + [key: string]: any; |
| 45 | +} |
28 | 46 |
|
29 | 47 | export const useSingleton: ( |
30 | 48 | props?: UseSingletonProps, |
|
0 commit comments