|
1 | 1 | // TypeScript Version: 3.0
|
2 | 2 |
|
3 |
| -declare module 'react-context-toolbox/forwardRef' { |
4 |
| - import * as React from 'react'; |
| 3 | +declare module 'react-context-toolbox' { |
| 4 | + import mapContextToProps from 'react-context-toolbox/mapContextToProps'; |
| 5 | + import forwardRef from 'react-context-toolbox/forwardRef'; |
5 | 6 |
|
6 |
| - interface ForwardRefOptions<TProps> { |
7 |
| - displayName?: string; |
8 |
| - propTypes?: React.ValidationMap<TProps>; |
9 |
| - defaultProps?: Partial<TProps>; |
10 |
| - allowFallback?: boolean; |
11 |
| - } |
12 |
| - |
13 |
| - function forwardRef<TRef, TProps>( |
14 |
| - renderFn: ( |
15 |
| - props: TProps & { children?: React.ReactNode }, |
16 |
| - ref: React.Ref<TRef> | null, |
17 |
| - ) => React.ReactElement<any> | null, |
18 |
| - options?: ForwardRefOptions<TProps>, |
19 |
| - ): React.ForwardRefExoticComponent< |
20 |
| - React.PropsWithRef<TProps> & React.RefAttributes<TRef> |
21 |
| - >; |
22 |
| - |
23 |
| - export default forwardRef; |
24 |
| -} |
25 |
| - |
26 |
| -declare module 'react-context-toolbox/mapContextToProps' { |
27 |
| - import * as React from 'react'; |
28 |
| - |
29 |
| - type ElementType = React.ComponentType<any> | keyof JSX.IntrinsicElements; |
30 |
| - |
31 |
| - type Omit<T, U> = Pick<T, Exclude<keyof T, keyof U>>; |
32 |
| - |
33 |
| - type GetProps<C> = C extends React.ComponentType<infer P> ? P : never; |
34 |
| - |
35 |
| - interface ContextInjectedComponent<TComponent, TInjectedProps, TExtraProps> |
36 |
| - extends React.ForwardRefExoticComponent< |
37 |
| - Omit<GetProps<TComponent>, TInjectedProps> & TExtraProps |
38 |
| - > {} |
39 |
| - |
40 |
| - // Single Context |
41 |
| - function mapContextToProps<TComponent, TContext, TContextProps, TOwnProps>( |
42 |
| - context: React.Context<TContext> | [React.Context<TContext>], |
43 |
| - mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps, |
44 |
| - Component: TComponent, |
45 |
| - ): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
46 |
| - function mapContextToProps<TContext, TContextProps, TOwnProps>( |
47 |
| - context: React.Context<TContext> | [React.Context<TContext>], |
48 |
| - mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps, |
49 |
| - ): <TComponent>( |
50 |
| - component: TComponent, |
51 |
| - ) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
52 |
| - |
53 |
| - // 2 Contexts |
54 |
| - function mapContextToProps< |
55 |
| - TComponent, |
56 |
| - TContext1, |
57 |
| - TContext2, |
58 |
| - TContextProps, |
59 |
| - TOwnProps |
60 |
| - >( |
61 |
| - context: [React.Context<TContext1>, React.Context<TContext2>], |
62 |
| - mapToProps: ( |
63 |
| - c1: TContext1, |
64 |
| - c2: TContext2, |
65 |
| - props: TOwnProps, |
66 |
| - ) => TContextProps, |
67 |
| - Component: TComponent, |
68 |
| - ): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
69 |
| - function mapContextToProps<TContext1, TContext2, TContextProps, TOwnProps>( |
70 |
| - context: [React.Context<TContext1>, React.Context<TContext2>], |
71 |
| - mapToProps: ( |
72 |
| - c1: TContext1, |
73 |
| - c2: TContext2, |
74 |
| - props: TOwnProps, |
75 |
| - ) => TContextProps, |
76 |
| - ): <TComponent>( |
77 |
| - component: TComponent, |
78 |
| - ) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
79 |
| - |
80 |
| - // 3 Contexts |
81 |
| - function mapContextToProps< |
82 |
| - TComponent, |
83 |
| - TContext1, |
84 |
| - TContext2, |
85 |
| - TContext3, |
86 |
| - TContextProps, |
87 |
| - TOwnProps |
88 |
| - >( |
89 |
| - context: [ |
90 |
| - React.Context<TContext1>, |
91 |
| - React.Context<TContext2>, |
92 |
| - React.Context<TContext3> |
93 |
| - ], |
94 |
| - mapToProps: ( |
95 |
| - c1: TContext1, |
96 |
| - c2: TContext2, |
97 |
| - c3: TContext3, |
98 |
| - props: TOwnProps, |
99 |
| - ) => TContextProps, |
100 |
| - Component: TComponent, |
101 |
| - ): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
102 |
| - function mapContextToProps< |
103 |
| - TContext1, |
104 |
| - TContext2, |
105 |
| - TContext3, |
106 |
| - TContextProps, |
107 |
| - TOwnProps |
108 |
| - >( |
109 |
| - context: [ |
110 |
| - React.Context<TContext1>, |
111 |
| - React.Context<TContext2>, |
112 |
| - React.Context<TContext3> |
113 |
| - ], |
114 |
| - mapToProps: ( |
115 |
| - c1: TContext1, |
116 |
| - c2: TContext2, |
117 |
| - c3: TContext3, |
118 |
| - props: TOwnProps, |
119 |
| - ) => TContextProps, |
120 |
| - ): <TComponent>( |
121 |
| - component: TComponent, |
122 |
| - ) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
123 |
| - |
124 |
| - // 4 Contexts |
125 |
| - function mapContextToProps< |
126 |
| - TComponent, |
127 |
| - TContext1, |
128 |
| - TContext2, |
129 |
| - TContext3, |
130 |
| - TContext4, |
131 |
| - TContextProps, |
132 |
| - TOwnProps |
133 |
| - >( |
134 |
| - context: [ |
135 |
| - React.Context<TContext1>, |
136 |
| - React.Context<TContext2>, |
137 |
| - React.Context<TContext3>, |
138 |
| - React.Context<TContext4> |
139 |
| - ], |
140 |
| - mapToProps: ( |
141 |
| - c1: TContext1, |
142 |
| - c2: TContext2, |
143 |
| - c3: TContext3, |
144 |
| - c4: TContext4, |
145 |
| - props: TOwnProps, |
146 |
| - ) => TContextProps, |
147 |
| - Component: TComponent, |
148 |
| - ): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
149 |
| - function mapContextToProps< |
150 |
| - TContext1, |
151 |
| - TContext2, |
152 |
| - TContext3, |
153 |
| - TContext4, |
154 |
| - TContextProps, |
155 |
| - TOwnProps |
156 |
| - >( |
157 |
| - context: [ |
158 |
| - React.Context<TContext1>, |
159 |
| - React.Context<TContext2>, |
160 |
| - React.Context<TContext3>, |
161 |
| - React.Context<TContext4> |
162 |
| - ], |
163 |
| - mapToProps: ( |
164 |
| - c1: TContext1, |
165 |
| - c2: TContext2, |
166 |
| - c3: TContext3, |
167 |
| - c4: TContext4, |
168 |
| - props: TOwnProps, |
169 |
| - ) => TContextProps, |
170 |
| - ): <TComponent>( |
171 |
| - component: TComponent, |
172 |
| - ) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>; |
173 |
| - |
174 |
| - export default mapContextToProps; |
| 7 | + export { mapContextToProps, forwardRef }; |
175 | 8 | }
|
0 commit comments