@types/react 18.3.14 → 19.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- react v18.3/README.md → react/README.md +3 -3
- react/canary.d.ts +35 -0
- react/compiler-runtime.d.ts +4 -0
- react/experimental.d.ts +125 -0
- react/index.d.ts +4207 -0
- react v18.3/package.json → react/package.json +23 -3
- react/ts5.0/canary.d.ts +35 -0
- react/ts5.0/experimental.d.ts +125 -0
- react/ts5.0/index.d.ts +4194 -0
- react/ts5.0/v18/global.d.ts +160 -0
- react/ts5.0/v18/jsx-dev-runtime.d.ts +45 -0
- react/ts5.0/v18/jsx-runtime.d.ts +36 -0
- react/ts5.0/v18/ts5.0/global.d.ts +160 -0
- react/ts5.0/v18/ts5.0/jsx-dev-runtime.d.ts +44 -0
- react/ts5.0/v18/ts5.0/jsx-runtime.d.ts +35 -0
- {react v18.3 → react}/LICENSE +0 -0
- {react v18.3 → react}/global.d.ts +0 -0
- {react v18.3 → react}/jsx-dev-runtime.d.ts +0 -0
- {react v18.3 → react}/jsx-runtime.d.ts +0 -0
- {react v18.3 → react}/ts5.0/global.d.ts +0 -0
- {react v18.3 → react}/ts5.0/jsx-dev-runtime.d.ts +0 -0
- {react v18.3 → react}/ts5.0/jsx-runtime.d.ts +0 -0
- {react v18.3 → react/ts5.0/v18}/index.d.ts +0 -0
- {react v18.3 → react/ts5.0/v18}/ts5.0/index.d.ts +0 -0
react/ts5.0/index.d.ts
ADDED
@@ -0,0 +1,4194 @@
|
|
1
|
+
// NOTE: Users of the `experimental` builds of React should add a reference
|
2
|
+
// to 'react/experimental' in their project. See experimental.d.ts's top comment
|
3
|
+
// for reference and documentation on how exactly to do it.
|
4
|
+
|
5
|
+
/// <reference path="global.d.ts" />
|
6
|
+
|
7
|
+
import * as CSS from "csstype";
|
8
|
+
|
9
|
+
type NativeAnimationEvent = AnimationEvent;
|
10
|
+
type NativeClipboardEvent = ClipboardEvent;
|
11
|
+
type NativeCompositionEvent = CompositionEvent;
|
12
|
+
type NativeDragEvent = DragEvent;
|
13
|
+
type NativeFocusEvent = FocusEvent;
|
14
|
+
type NativeKeyboardEvent = KeyboardEvent;
|
15
|
+
type NativeMouseEvent = MouseEvent;
|
16
|
+
type NativeTouchEvent = TouchEvent;
|
17
|
+
type NativePointerEvent = PointerEvent;
|
18
|
+
type NativeToggleEvent = ToggleEvent;
|
19
|
+
type NativeTransitionEvent = TransitionEvent;
|
20
|
+
type NativeUIEvent = UIEvent;
|
21
|
+
type NativeWheelEvent = WheelEvent;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Used to represent DOM API's where users can either pass
|
25
|
+
* true or false as a boolean or as its equivalent strings.
|
26
|
+
*/
|
27
|
+
type Booleanish = boolean | "true" | "false";
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin MDN}
|
31
|
+
*/
|
32
|
+
type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
|
33
|
+
|
34
|
+
declare const UNDEFINED_VOID_ONLY: unique symbol;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @internal Use `Awaited<ReactNode>` instead
|
38
|
+
*/
|
39
|
+
// Helper type to enable `Awaited<ReactNode>`.
|
40
|
+
// Must be a copy of the non-thenables of `ReactNode`.
|
41
|
+
type AwaitedReactNode =
|
42
|
+
| React.ReactElement
|
43
|
+
| string
|
44
|
+
| number
|
45
|
+
| bigint
|
46
|
+
| Iterable<React.ReactNode>
|
47
|
+
| React.ReactPortal
|
48
|
+
| boolean
|
49
|
+
| null
|
50
|
+
| undefined
|
51
|
+
| React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
52
|
+
keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
53
|
+
];
|
54
|
+
|
55
|
+
/**
|
56
|
+
* The function returned from an effect passed to {@link React.useEffect useEffect},
|
57
|
+
* which can be used to clean up the effect when the component unmounts.
|
58
|
+
*
|
59
|
+
* @see {@link https://react.dev/reference/react/useEffect React Docs}
|
60
|
+
*/
|
61
|
+
type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };
|
62
|
+
type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
|
63
|
+
|
64
|
+
// eslint-disable-next-line @definitelytyped/export-just-namespace
|
65
|
+
export = React;
|
66
|
+
export as namespace React;
|
67
|
+
|
68
|
+
declare namespace React {
|
69
|
+
//
|
70
|
+
// React Elements
|
71
|
+
// ----------------------------------------------------------------------
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Used to retrieve the possible components which accept a given set of props.
|
75
|
+
*
|
76
|
+
* Can be passed no type parameters to get a union of all possible components
|
77
|
+
* and tags.
|
78
|
+
*
|
79
|
+
* Is a superset of {@link ComponentType}.
|
80
|
+
*
|
81
|
+
* @template P The props to match against. If not passed, defaults to any.
|
82
|
+
* @template Tag An optional tag to match against. If not passed, attempts to match against all possible tags.
|
83
|
+
*
|
84
|
+
* @example
|
85
|
+
*
|
86
|
+
* ```tsx
|
87
|
+
* // All components and tags (img, embed etc.)
|
88
|
+
* // which accept `src`
|
89
|
+
* type SrcComponents = ElementType<{ src: any }>;
|
90
|
+
* ```
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
*
|
94
|
+
* ```tsx
|
95
|
+
* // All components
|
96
|
+
* type AllComponents = ElementType;
|
97
|
+
* ```
|
98
|
+
*
|
99
|
+
* @example
|
100
|
+
*
|
101
|
+
* ```tsx
|
102
|
+
* // All custom components which match `src`, and tags which
|
103
|
+
* // match `src`, narrowed down to just `audio` and `embed`
|
104
|
+
* type SrcComponents = ElementType<{ src: any }, 'audio' | 'embed'>;
|
105
|
+
* ```
|
106
|
+
*/
|
107
|
+
type ElementType<P = any, Tag extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements> =
|
108
|
+
| { [K in Tag]: P extends JSX.IntrinsicElements[K] ? K : never }[Tag]
|
109
|
+
| ComponentType<P>;
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Represents any user-defined component, either as a function or a class.
|
113
|
+
*
|
114
|
+
* Similar to {@link JSXElementConstructor}, but with extra properties like
|
115
|
+
* {@link FunctionComponent.defaultProps defaultProps }.
|
116
|
+
*
|
117
|
+
* @template P The props the component accepts.
|
118
|
+
*
|
119
|
+
* @see {@link ComponentClass}
|
120
|
+
* @see {@link FunctionComponent}
|
121
|
+
*/
|
122
|
+
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Represents any user-defined component, either as a function or a class.
|
126
|
+
*
|
127
|
+
* Similar to {@link ComponentType}, but without extra properties like
|
128
|
+
* {@link FunctionComponent.defaultProps defaultProps }.
|
129
|
+
*
|
130
|
+
* @template P The props the component accepts.
|
131
|
+
*/
|
132
|
+
type JSXElementConstructor<P> =
|
133
|
+
| ((
|
134
|
+
props: P,
|
135
|
+
) => ReactElement<any, any> | null)
|
136
|
+
// constructor signature must match React.Component
|
137
|
+
| (new(props: P) => Component<any, any>);
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Created by {@link createRef}, or {@link useRef} when passed `null`.
|
141
|
+
*
|
142
|
+
* @template T The type of the ref's value.
|
143
|
+
*
|
144
|
+
* @example
|
145
|
+
*
|
146
|
+
* ```tsx
|
147
|
+
* const ref = createRef<HTMLDivElement>();
|
148
|
+
*
|
149
|
+
* ref.current = document.createElement('div'); // Error
|
150
|
+
* ```
|
151
|
+
*/
|
152
|
+
interface RefObject<T> {
|
153
|
+
/**
|
154
|
+
* The current value of the ref.
|
155
|
+
*/
|
156
|
+
current: T;
|
157
|
+
}
|
158
|
+
|
159
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
|
160
|
+
}
|
161
|
+
/**
|
162
|
+
* A callback fired whenever the ref's value changes.
|
163
|
+
*
|
164
|
+
* @template T The type of the ref's value.
|
165
|
+
*
|
166
|
+
* @see {@link https://react.dev/reference/react-dom/components/common#ref-callback React Docs}
|
167
|
+
*
|
168
|
+
* @example
|
169
|
+
*
|
170
|
+
* ```tsx
|
171
|
+
* <div ref={(node) => console.log(node)} />
|
172
|
+
* ```
|
173
|
+
*/
|
174
|
+
type RefCallback<T> = {
|
175
|
+
bivarianceHack(
|
176
|
+
instance: T | null,
|
177
|
+
):
|
178
|
+
| void
|
179
|
+
| (() => VoidOrUndefinedOnly)
|
180
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[
|
181
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES
|
182
|
+
];
|
183
|
+
}["bivarianceHack"];
|
184
|
+
|
185
|
+
/**
|
186
|
+
* A union type of all possible shapes for React refs.
|
187
|
+
*
|
188
|
+
* @see {@link RefCallback}
|
189
|
+
* @see {@link RefObject}
|
190
|
+
*/
|
191
|
+
|
192
|
+
type Ref<T> = RefCallback<T> | RefObject<T | null> | null;
|
193
|
+
/**
|
194
|
+
* @deprecated Use `Ref` instead. String refs are no longer supported.
|
195
|
+
* If you're typing a library with support for React versions with string refs, use `RefAttributes<T>['ref']` instead.
|
196
|
+
*/
|
197
|
+
type LegacyRef<T> = Ref<T>;
|
198
|
+
/**
|
199
|
+
* @deprecated Use `ComponentRef<T>` instead
|
200
|
+
*
|
201
|
+
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
202
|
+
*
|
203
|
+
* @template C The component type.
|
204
|
+
*
|
205
|
+
* @example
|
206
|
+
*
|
207
|
+
* ```tsx
|
208
|
+
* type MyComponentRef = React.ElementRef<typeof MyComponent>;
|
209
|
+
* ```
|
210
|
+
*
|
211
|
+
* @example
|
212
|
+
*
|
213
|
+
* ```tsx
|
214
|
+
* type DivRef = React.ElementRef<'div'>;
|
215
|
+
* ```
|
216
|
+
*/
|
217
|
+
type ElementRef<
|
218
|
+
C extends
|
219
|
+
| ForwardRefExoticComponent<any>
|
220
|
+
| { new(props: any): Component<any> }
|
221
|
+
| ((props: any) => ReactElement | null)
|
222
|
+
| keyof JSX.IntrinsicElements,
|
223
|
+
> = ComponentRef<C>;
|
224
|
+
|
225
|
+
type ComponentState = any;
|
226
|
+
|
227
|
+
/**
|
228
|
+
* A value which uniquely identifies a node among items in an array.
|
229
|
+
*
|
230
|
+
* @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}
|
231
|
+
*/
|
232
|
+
type Key = string | number | bigint;
|
233
|
+
|
234
|
+
/**
|
235
|
+
* @internal The props any component can receive.
|
236
|
+
* You don't have to add this type. All components automatically accept these props.
|
237
|
+
* ```tsx
|
238
|
+
* const Component = () => <div />;
|
239
|
+
* <Component key="one" />
|
240
|
+
* ```
|
241
|
+
*
|
242
|
+
* WARNING: The implementation of a component will never have access to these attributes.
|
243
|
+
* The following example would be incorrect usage because {@link Component} would never have access to `key`:
|
244
|
+
* ```tsx
|
245
|
+
* const Component = (props: React.Attributes) => props.key;
|
246
|
+
* ```
|
247
|
+
*/
|
248
|
+
interface Attributes {
|
249
|
+
key?: Key | null | undefined;
|
250
|
+
}
|
251
|
+
/**
|
252
|
+
* The props any component accepting refs can receive.
|
253
|
+
* Class components, built-in browser components (e.g. `div`) and forwardRef components can receive refs and automatically accept these props.
|
254
|
+
* ```tsx
|
255
|
+
* const Component = forwardRef(() => <div />);
|
256
|
+
* <Component ref={(current) => console.log(current)} />
|
257
|
+
* ```
|
258
|
+
*
|
259
|
+
* You only need this type if you manually author the types of props that need to be compatible with legacy refs.
|
260
|
+
* ```tsx
|
261
|
+
* interface Props extends React.RefAttributes<HTMLDivElement> {}
|
262
|
+
* declare const Component: React.FunctionComponent<Props>;
|
263
|
+
* ```
|
264
|
+
*
|
265
|
+
* Otherwise it's simpler to directly use {@link Ref} since you can safely use the
|
266
|
+
* props type to describe to props that a consumer can pass to the component
|
267
|
+
* as well as describing the props the implementation of a component "sees".
|
268
|
+
* {@link RefAttributes} is generally not safe to describe both consumer and seen props.
|
269
|
+
*
|
270
|
+
* ```tsx
|
271
|
+
* interface Props extends {
|
272
|
+
* ref?: React.Ref<HTMLDivElement> | undefined;
|
273
|
+
* }
|
274
|
+
* declare const Component: React.FunctionComponent<Props>;
|
275
|
+
* ```
|
276
|
+
*
|
277
|
+
* WARNING: The implementation of a component will not have access to the same type in versions of React supporting string refs.
|
278
|
+
* The following example would be incorrect usage because {@link Component} would never have access to a `ref` with type `string`
|
279
|
+
* ```tsx
|
280
|
+
* const Component = (props: React.RefAttributes) => props.ref;
|
281
|
+
* ```
|
282
|
+
*/
|
283
|
+
interface RefAttributes<T> extends Attributes {
|
284
|
+
/**
|
285
|
+
* Allows getting a ref to the component instance.
|
286
|
+
* Once the component unmounts, React will set `ref.current` to `null`
|
287
|
+
* (or call the ref with `null` if you passed a callback ref).
|
288
|
+
*
|
289
|
+
* @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
|
290
|
+
*/
|
291
|
+
ref?: Ref<T> | undefined;
|
292
|
+
}
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Represents the built-in attributes available to class components.
|
296
|
+
*/
|
297
|
+
interface ClassAttributes<T> extends RefAttributes<T> {
|
298
|
+
}
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Represents a JSX element.
|
302
|
+
*
|
303
|
+
* Where {@link ReactNode} represents everything that can be rendered, `ReactElement`
|
304
|
+
* only represents JSX.
|
305
|
+
*
|
306
|
+
* @template P The type of the props object
|
307
|
+
* @template T The type of the component or tag
|
308
|
+
*
|
309
|
+
* @example
|
310
|
+
*
|
311
|
+
* ```tsx
|
312
|
+
* const element: ReactElement = <div />;
|
313
|
+
* ```
|
314
|
+
*/
|
315
|
+
interface ReactElement<
|
316
|
+
P = unknown,
|
317
|
+
T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
|
318
|
+
> {
|
319
|
+
type: T;
|
320
|
+
props: P;
|
321
|
+
key: string | null;
|
322
|
+
}
|
323
|
+
|
324
|
+
/**
|
325
|
+
* @deprecated
|
326
|
+
*/
|
327
|
+
interface ReactComponentElement<
|
328
|
+
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
|
329
|
+
P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
|
330
|
+
> extends ReactElement<P, Exclude<T, number>> {}
|
331
|
+
|
332
|
+
/**
|
333
|
+
* @deprecated Use `ReactElement<P, React.FunctionComponent<P>>`
|
334
|
+
*/
|
335
|
+
interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
|
336
|
+
/**
|
337
|
+
* @deprecated Use `element.props.ref` instead.
|
338
|
+
*/
|
339
|
+
ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
|
340
|
+
}
|
341
|
+
|
342
|
+
/**
|
343
|
+
* @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
|
344
|
+
*/
|
345
|
+
type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
|
346
|
+
/**
|
347
|
+
* @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
|
348
|
+
*/
|
349
|
+
interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
|
350
|
+
/**
|
351
|
+
* @deprecated Use `element.props.ref` instead.
|
352
|
+
*/
|
353
|
+
ref?: Ref<T> | undefined;
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* @deprecated Use {@link ComponentElement} instead.
|
358
|
+
*/
|
359
|
+
type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
|
360
|
+
|
361
|
+
// string fallback for custom web-components
|
362
|
+
/**
|
363
|
+
* @deprecated Use `ReactElement<P, string>`
|
364
|
+
*/
|
365
|
+
interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
|
366
|
+
extends ReactElement<P, string>
|
367
|
+
{
|
368
|
+
/**
|
369
|
+
* @deprecated Use `element.props.ref` instead.
|
370
|
+
*/
|
371
|
+
ref: Ref<T>;
|
372
|
+
}
|
373
|
+
|
374
|
+
// ReactHTML for ReactHTMLElement
|
375
|
+
interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
|
376
|
+
|
377
|
+
interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
|
378
|
+
type: HTMLElementType;
|
379
|
+
}
|
380
|
+
|
381
|
+
// ReactSVG for ReactSVGElement
|
382
|
+
interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
|
383
|
+
type: SVGElementType;
|
384
|
+
}
|
385
|
+
|
386
|
+
interface ReactPortal extends ReactElement {
|
387
|
+
children: ReactNode;
|
388
|
+
}
|
389
|
+
|
390
|
+
/**
|
391
|
+
* For internal usage only.
|
392
|
+
* Different release channels declare additional types of ReactNode this particular release channel accepts.
|
393
|
+
* App or library types should never augment this interface.
|
394
|
+
*/
|
395
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {}
|
396
|
+
|
397
|
+
/**
|
398
|
+
* Represents all of the things React can render.
|
399
|
+
*
|
400
|
+
* Where {@link ReactElement} only represents JSX, `ReactNode` represents everything that can be rendered.
|
401
|
+
*
|
402
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/reactnode/ React TypeScript Cheatsheet}
|
403
|
+
*
|
404
|
+
* @example
|
405
|
+
*
|
406
|
+
* ```tsx
|
407
|
+
* // Typing children
|
408
|
+
* type Props = { children: ReactNode }
|
409
|
+
*
|
410
|
+
* const Component = ({ children }: Props) => <div>{children}</div>
|
411
|
+
*
|
412
|
+
* <Component>hello</Component>
|
413
|
+
* ```
|
414
|
+
*
|
415
|
+
* @example
|
416
|
+
*
|
417
|
+
* ```tsx
|
418
|
+
* // Typing a custom element
|
419
|
+
* type Props = { customElement: ReactNode }
|
420
|
+
*
|
421
|
+
* const Component = ({ customElement }: Props) => <div>{customElement}</div>
|
422
|
+
*
|
423
|
+
* <Component customElement={<div>hello</div>} />
|
424
|
+
* ```
|
425
|
+
*/
|
426
|
+
// non-thenables need to be kept in sync with AwaitedReactNode
|
427
|
+
type ReactNode =
|
428
|
+
| ReactElement
|
429
|
+
| string
|
430
|
+
| number
|
431
|
+
| bigint
|
432
|
+
| Iterable<ReactNode>
|
433
|
+
| ReactPortal
|
434
|
+
| boolean
|
435
|
+
| null
|
436
|
+
| undefined
|
437
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
|
438
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
|
439
|
+
]
|
440
|
+
| Promise<AwaitedReactNode>;
|
441
|
+
|
442
|
+
//
|
443
|
+
// Top Level API
|
444
|
+
// ----------------------------------------------------------------------
|
445
|
+
|
446
|
+
// DOM Elements
|
447
|
+
// TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
|
448
|
+
function createElement(
|
449
|
+
type: "input",
|
450
|
+
props?: InputHTMLAttributes<HTMLInputElement> & ClassAttributes<HTMLInputElement> | null,
|
451
|
+
...children: ReactNode[]
|
452
|
+
): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
453
|
+
function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
454
|
+
type: HTMLElementType,
|
455
|
+
props?: ClassAttributes<T> & P | null,
|
456
|
+
...children: ReactNode[]
|
457
|
+
): DetailedReactHTMLElement<P, T>;
|
458
|
+
function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
459
|
+
type: SVGElementType,
|
460
|
+
props?: ClassAttributes<T> & P | null,
|
461
|
+
...children: ReactNode[]
|
462
|
+
): ReactSVGElement;
|
463
|
+
function createElement<P extends DOMAttributes<T>, T extends Element>(
|
464
|
+
type: string,
|
465
|
+
props?: ClassAttributes<T> & P | null,
|
466
|
+
...children: ReactNode[]
|
467
|
+
): DOMElement<P, T>;
|
468
|
+
|
469
|
+
// Custom components
|
470
|
+
|
471
|
+
function createElement<P extends {}>(
|
472
|
+
type: FunctionComponent<P>,
|
473
|
+
props?: Attributes & P | null,
|
474
|
+
...children: ReactNode[]
|
475
|
+
): FunctionComponentElement<P>;
|
476
|
+
function createElement<P extends {}, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
|
477
|
+
type: ClassType<P, T, C>,
|
478
|
+
props?: ClassAttributes<T> & P | null,
|
479
|
+
...children: ReactNode[]
|
480
|
+
): CElement<P, T>;
|
481
|
+
function createElement<P extends {}>(
|
482
|
+
type: FunctionComponent<P> | ComponentClass<P> | string,
|
483
|
+
props?: Attributes & P | null,
|
484
|
+
...children: ReactNode[]
|
485
|
+
): ReactElement<P>;
|
486
|
+
|
487
|
+
// DOM Elements
|
488
|
+
// ReactHTMLElement
|
489
|
+
function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
490
|
+
element: DetailedReactHTMLElement<P, T>,
|
491
|
+
props?: P,
|
492
|
+
...children: ReactNode[]
|
493
|
+
): DetailedReactHTMLElement<P, T>;
|
494
|
+
// ReactHTMLElement, less specific
|
495
|
+
function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
|
496
|
+
element: ReactHTMLElement<T>,
|
497
|
+
props?: P,
|
498
|
+
...children: ReactNode[]
|
499
|
+
): ReactHTMLElement<T>;
|
500
|
+
// SVGElement
|
501
|
+
function cloneElement<P extends SVGAttributes<T>, T extends SVGElement>(
|
502
|
+
element: ReactSVGElement,
|
503
|
+
props?: P,
|
504
|
+
...children: ReactNode[]
|
505
|
+
): ReactSVGElement;
|
506
|
+
// DOM Element (has to be the last, because type checking stops at first overload that fits)
|
507
|
+
function cloneElement<P extends DOMAttributes<T>, T extends Element>(
|
508
|
+
element: DOMElement<P, T>,
|
509
|
+
props?: DOMAttributes<T> & P,
|
510
|
+
...children: ReactNode[]
|
511
|
+
): DOMElement<P, T>;
|
512
|
+
|
513
|
+
// Custom components
|
514
|
+
function cloneElement<P>(
|
515
|
+
element: FunctionComponentElement<P>,
|
516
|
+
props?: Partial<P> & Attributes,
|
517
|
+
...children: ReactNode[]
|
518
|
+
): FunctionComponentElement<P>;
|
519
|
+
function cloneElement<P, T extends Component<P, ComponentState>>(
|
520
|
+
element: CElement<P, T>,
|
521
|
+
props?: Partial<P> & ClassAttributes<T>,
|
522
|
+
...children: ReactNode[]
|
523
|
+
): CElement<P, T>;
|
524
|
+
function cloneElement<P>(
|
525
|
+
element: ReactElement<P>,
|
526
|
+
props?: Partial<P> & Attributes,
|
527
|
+
...children: ReactNode[]
|
528
|
+
): ReactElement<P>;
|
529
|
+
|
530
|
+
/**
|
531
|
+
* Describes the props accepted by a Context {@link Provider}.
|
532
|
+
*
|
533
|
+
* @template T The type of the value the context provides.
|
534
|
+
*/
|
535
|
+
interface ProviderProps<T> {
|
536
|
+
value: T;
|
537
|
+
children?: ReactNode | undefined;
|
538
|
+
}
|
539
|
+
|
540
|
+
/**
|
541
|
+
* Describes the props accepted by a Context {@link Consumer}.
|
542
|
+
*
|
543
|
+
* @template T The type of the value the context provides.
|
544
|
+
*/
|
545
|
+
interface ConsumerProps<T> {
|
546
|
+
children: (value: T) => ReactNode;
|
547
|
+
}
|
548
|
+
|
549
|
+
/**
|
550
|
+
* An object masquerading as a component. These are created by functions
|
551
|
+
* like {@link forwardRef}, {@link memo}, and {@link createContext}.
|
552
|
+
*
|
553
|
+
* In order to make TypeScript work, we pretend that they are normal
|
554
|
+
* components.
|
555
|
+
*
|
556
|
+
* But they are, in fact, not callable - instead, they are objects which
|
557
|
+
* are treated specially by the renderer.
|
558
|
+
*
|
559
|
+
* @template P The props the component accepts.
|
560
|
+
*/
|
561
|
+
interface ExoticComponent<P = {}> {
|
562
|
+
(props: P): ReactElement | null;
|
563
|
+
readonly $$typeof: symbol;
|
564
|
+
}
|
565
|
+
|
566
|
+
/**
|
567
|
+
* An {@link ExoticComponent} with a `displayName` property applied to it.
|
568
|
+
*
|
569
|
+
* @template P The props the component accepts.
|
570
|
+
*/
|
571
|
+
interface NamedExoticComponent<P = {}> extends ExoticComponent<P> {
|
572
|
+
/**
|
573
|
+
* Used in debugging messages. You might want to set it
|
574
|
+
* explicitly if you want to display a different name for
|
575
|
+
* debugging purposes.
|
576
|
+
*
|
577
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
|
578
|
+
*/
|
579
|
+
displayName?: string | undefined;
|
580
|
+
}
|
581
|
+
|
582
|
+
/**
|
583
|
+
* An {@link ExoticComponent} with a `propTypes` property applied to it.
|
584
|
+
*
|
585
|
+
* @template P The props the component accepts.
|
586
|
+
*/
|
587
|
+
interface ProviderExoticComponent<P> extends ExoticComponent<P> {
|
588
|
+
}
|
589
|
+
|
590
|
+
/**
|
591
|
+
* Used to retrieve the type of a context object from a {@link Context}.
|
592
|
+
*
|
593
|
+
* @template C The context object.
|
594
|
+
*
|
595
|
+
* @example
|
596
|
+
*
|
597
|
+
* ```tsx
|
598
|
+
* import { createContext } from 'react';
|
599
|
+
*
|
600
|
+
* const MyContext = createContext({ foo: 'bar' });
|
601
|
+
*
|
602
|
+
* type ContextType = ContextType<typeof MyContext>;
|
603
|
+
* // ContextType = { foo: string }
|
604
|
+
* ```
|
605
|
+
*/
|
606
|
+
type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
|
607
|
+
|
608
|
+
/**
|
609
|
+
* Wraps your components to specify the value of this context for all components inside.
|
610
|
+
*
|
611
|
+
* @see {@link https://react.dev/reference/react/createContext#provider React Docs}
|
612
|
+
*
|
613
|
+
* @example
|
614
|
+
*
|
615
|
+
* ```tsx
|
616
|
+
* import { createContext } from 'react';
|
617
|
+
*
|
618
|
+
* const ThemeContext = createContext('light');
|
619
|
+
*
|
620
|
+
* function App() {
|
621
|
+
* return (
|
622
|
+
* <ThemeContext.Provider value="dark">
|
623
|
+
* <Toolbar />
|
624
|
+
* </ThemeContext.Provider>
|
625
|
+
* );
|
626
|
+
* }
|
627
|
+
* ```
|
628
|
+
*/
|
629
|
+
type Provider<T> = ProviderExoticComponent<ProviderProps<T>>;
|
630
|
+
|
631
|
+
/**
|
632
|
+
* The old way to read context, before {@link useContext} existed.
|
633
|
+
*
|
634
|
+
* @see {@link https://react.dev/reference/react/createContext#consumer React Docs}
|
635
|
+
*
|
636
|
+
* @example
|
637
|
+
*
|
638
|
+
* ```tsx
|
639
|
+
* import { UserContext } from './user-context';
|
640
|
+
*
|
641
|
+
* function Avatar() {
|
642
|
+
* return (
|
643
|
+
* <UserContext.Consumer>
|
644
|
+
* {user => <img src={user.profileImage} alt={user.name} />}
|
645
|
+
* </UserContext.Consumer>
|
646
|
+
* );
|
647
|
+
* }
|
648
|
+
* ```
|
649
|
+
*/
|
650
|
+
type Consumer<T> = ExoticComponent<ConsumerProps<T>>;
|
651
|
+
|
652
|
+
/**
|
653
|
+
* Context lets components pass information deep down without explicitly
|
654
|
+
* passing props.
|
655
|
+
*
|
656
|
+
* Created from {@link createContext}
|
657
|
+
*
|
658
|
+
* @see {@link https://react.dev/learn/passing-data-deeply-with-context React Docs}
|
659
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
|
660
|
+
*
|
661
|
+
* @example
|
662
|
+
*
|
663
|
+
* ```tsx
|
664
|
+
* import { createContext } from 'react';
|
665
|
+
*
|
666
|
+
* const ThemeContext = createContext('light');
|
667
|
+
* ```
|
668
|
+
*/
|
669
|
+
interface Context<T> extends Provider<T> {
|
670
|
+
Provider: Provider<T>;
|
671
|
+
Consumer: Consumer<T>;
|
672
|
+
/**
|
673
|
+
* Used in debugging messages. You might want to set it
|
674
|
+
* explicitly if you want to display a different name for
|
675
|
+
* debugging purposes.
|
676
|
+
*
|
677
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
|
678
|
+
*/
|
679
|
+
displayName?: string | undefined;
|
680
|
+
}
|
681
|
+
|
682
|
+
/**
|
683
|
+
* Lets you create a {@link Context} that components can provide or read.
|
684
|
+
*
|
685
|
+
* @param defaultValue The value you want the context to have when there is no matching
|
686
|
+
* {@link Provider} in the tree above the component reading the context. This is meant
|
687
|
+
* as a "last resort" fallback.
|
688
|
+
*
|
689
|
+
* @see {@link https://react.dev/reference/react/createContext#reference React Docs}
|
690
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
|
691
|
+
*
|
692
|
+
* @example
|
693
|
+
*
|
694
|
+
* ```tsx
|
695
|
+
* import { createContext } from 'react';
|
696
|
+
*
|
697
|
+
* const ThemeContext = createContext('light');
|
698
|
+
* function App() {
|
699
|
+
* return (
|
700
|
+
* <ThemeContext value="dark">
|
701
|
+
* <Toolbar />
|
702
|
+
* </ThemeContext>
|
703
|
+
* );
|
704
|
+
* }
|
705
|
+
* ```
|
706
|
+
*/
|
707
|
+
function createContext<T>(
|
708
|
+
// If you thought this should be optional, see
|
709
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106
|
710
|
+
defaultValue: T,
|
711
|
+
): Context<T>;
|
712
|
+
|
713
|
+
function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
|
714
|
+
|
715
|
+
const Children: {
|
716
|
+
map<T, C>(
|
717
|
+
children: C | readonly C[],
|
718
|
+
fn: (child: C, index: number) => T,
|
719
|
+
): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
720
|
+
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
721
|
+
count(children: any): number;
|
722
|
+
only<C>(children: C): C extends any[] ? never : C;
|
723
|
+
toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
|
724
|
+
};
|
725
|
+
/**
|
726
|
+
* Lets you group elements without a wrapper node.
|
727
|
+
*
|
728
|
+
* @see {@link https://react.dev/reference/react/Fragment React Docs}
|
729
|
+
*
|
730
|
+
* @example
|
731
|
+
*
|
732
|
+
* ```tsx
|
733
|
+
* import { Fragment } from 'react';
|
734
|
+
*
|
735
|
+
* <Fragment>
|
736
|
+
* <td>Hello</td>
|
737
|
+
* <td>World</td>
|
738
|
+
* </Fragment>
|
739
|
+
* ```
|
740
|
+
*
|
741
|
+
* @example
|
742
|
+
*
|
743
|
+
* ```tsx
|
744
|
+
* // Using the <></> shorthand syntax:
|
745
|
+
*
|
746
|
+
* <>
|
747
|
+
* <td>Hello</td>
|
748
|
+
* <td>World</td>
|
749
|
+
* </>
|
750
|
+
* ```
|
751
|
+
*/
|
752
|
+
const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
|
753
|
+
|
754
|
+
/**
|
755
|
+
* Lets you find common bugs in your components early during development.
|
756
|
+
*
|
757
|
+
* @see {@link https://react.dev/reference/react/StrictMode React Docs}
|
758
|
+
*
|
759
|
+
* @example
|
760
|
+
*
|
761
|
+
* ```tsx
|
762
|
+
* import { StrictMode } from 'react';
|
763
|
+
*
|
764
|
+
* <StrictMode>
|
765
|
+
* <App />
|
766
|
+
* </StrictMode>
|
767
|
+
* ```
|
768
|
+
*/
|
769
|
+
const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;
|
770
|
+
|
771
|
+
/**
|
772
|
+
* The props accepted by {@link Suspense}.
|
773
|
+
*
|
774
|
+
* @see {@link https://react.dev/reference/react/Suspense React Docs}
|
775
|
+
*/
|
776
|
+
interface SuspenseProps {
|
777
|
+
children?: ReactNode | undefined;
|
778
|
+
|
779
|
+
/** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
|
780
|
+
fallback?: ReactNode;
|
781
|
+
|
782
|
+
/**
|
783
|
+
* A name for this Suspense boundary for instrumentation purposes.
|
784
|
+
* The name will help identify this boundary in React DevTools.
|
785
|
+
*/
|
786
|
+
name?: string | undefined;
|
787
|
+
}
|
788
|
+
|
789
|
+
/**
|
790
|
+
* Lets you display a fallback until its children have finished loading.
|
791
|
+
*
|
792
|
+
* @see {@link https://react.dev/reference/react/Suspense React Docs}
|
793
|
+
*
|
794
|
+
* @example
|
795
|
+
*
|
796
|
+
* ```tsx
|
797
|
+
* import { Suspense } from 'react';
|
798
|
+
*
|
799
|
+
* <Suspense fallback={<Loading />}>
|
800
|
+
* <ProfileDetails />
|
801
|
+
* </Suspense>
|
802
|
+
* ```
|
803
|
+
*/
|
804
|
+
const Suspense: ExoticComponent<SuspenseProps>;
|
805
|
+
const version: string;
|
806
|
+
|
807
|
+
/**
|
808
|
+
* The callback passed to {@link ProfilerProps.onRender}.
|
809
|
+
*
|
810
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
811
|
+
*/
|
812
|
+
type ProfilerOnRenderCallback = (
|
813
|
+
/**
|
814
|
+
* The string id prop of the {@link Profiler} tree that has just committed. This lets
|
815
|
+
* you identify which part of the tree was committed if you are using multiple
|
816
|
+
* profilers.
|
817
|
+
*
|
818
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
819
|
+
*/
|
820
|
+
id: string,
|
821
|
+
/**
|
822
|
+
* This lets you know whether the tree has just been mounted for the first time
|
823
|
+
* or re-rendered due to a change in props, state, or hooks.
|
824
|
+
*
|
825
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
826
|
+
*/
|
827
|
+
phase: "mount" | "update" | "nested-update",
|
828
|
+
/**
|
829
|
+
* The number of milliseconds spent rendering the {@link Profiler} and its descendants
|
830
|
+
* for the current update. This indicates how well the subtree makes use of
|
831
|
+
* memoization (e.g. {@link memo} and {@link useMemo}). Ideally this value should decrease
|
832
|
+
* significantly after the initial mount as many of the descendants will only need to
|
833
|
+
* re-render if their specific props change.
|
834
|
+
*
|
835
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
836
|
+
*/
|
837
|
+
actualDuration: number,
|
838
|
+
/**
|
839
|
+
* The number of milliseconds estimating how much time it would take to re-render the entire
|
840
|
+
* {@link Profiler} subtree without any optimizations. It is calculated by summing up the most
|
841
|
+
* recent render durations of each component in the tree. This value estimates a worst-case
|
842
|
+
* cost of rendering (e.g. the initial mount or a tree with no memoization). Compare
|
843
|
+
* {@link actualDuration} against it to see if memoization is working.
|
844
|
+
*
|
845
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
846
|
+
*/
|
847
|
+
baseDuration: number,
|
848
|
+
/**
|
849
|
+
* A numeric timestamp for when React began rendering the current update.
|
850
|
+
*
|
851
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
852
|
+
*/
|
853
|
+
startTime: number,
|
854
|
+
/**
|
855
|
+
* A numeric timestamp for when React committed the current update. This value is shared
|
856
|
+
* between all profilers in a commit, enabling them to be grouped if desirable.
|
857
|
+
*
|
858
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
859
|
+
*/
|
860
|
+
commitTime: number,
|
861
|
+
) => void;
|
862
|
+
|
863
|
+
/**
|
864
|
+
* The props accepted by {@link Profiler}.
|
865
|
+
*
|
866
|
+
* @see {@link https://react.dev/reference/react/Profiler React Docs}
|
867
|
+
*/
|
868
|
+
interface ProfilerProps {
|
869
|
+
children?: ReactNode | undefined;
|
870
|
+
id: string;
|
871
|
+
onRender: ProfilerOnRenderCallback;
|
872
|
+
}
|
873
|
+
|
874
|
+
/**
|
875
|
+
* Lets you measure rendering performance of a React tree programmatically.
|
876
|
+
*
|
877
|
+
* @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
|
878
|
+
*
|
879
|
+
* @example
|
880
|
+
*
|
881
|
+
* ```tsx
|
882
|
+
* <Profiler id="App" onRender={onRender}>
|
883
|
+
* <App />
|
884
|
+
* </Profiler>
|
885
|
+
* ```
|
886
|
+
*/
|
887
|
+
const Profiler: ExoticComponent<ProfilerProps>;
|
888
|
+
|
889
|
+
//
|
890
|
+
// Component API
|
891
|
+
// ----------------------------------------------------------------------
|
892
|
+
|
893
|
+
type ReactInstance = Component<any> | Element;
|
894
|
+
|
895
|
+
// Base component for plain JS classes
|
896
|
+
interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {}
|
897
|
+
class Component<P, S> {
|
898
|
+
/**
|
899
|
+
* If set, `this.context` will be set at runtime to the current value of the given Context.
|
900
|
+
*
|
901
|
+
* @example
|
902
|
+
*
|
903
|
+
* ```ts
|
904
|
+
* type MyContext = number
|
905
|
+
* const Ctx = React.createContext<MyContext>(0)
|
906
|
+
*
|
907
|
+
* class Foo extends React.Component {
|
908
|
+
* static contextType = Ctx
|
909
|
+
* context!: React.ContextType<typeof Ctx>
|
910
|
+
* render () {
|
911
|
+
* return <>My context's value: {this.context}</>;
|
912
|
+
* }
|
913
|
+
* }
|
914
|
+
* ```
|
915
|
+
*
|
916
|
+
* @see {@link https://react.dev/reference/react/Component#static-contexttype}
|
917
|
+
*/
|
918
|
+
static contextType?: Context<any> | undefined;
|
919
|
+
|
920
|
+
/**
|
921
|
+
* Ignored by React.
|
922
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
923
|
+
*/
|
924
|
+
static propTypes?: any;
|
925
|
+
|
926
|
+
/**
|
927
|
+
* If using the new style context, re-declare this in your class to be the
|
928
|
+
* `React.ContextType` of your `static contextType`.
|
929
|
+
* Should be used with type annotation or static contextType.
|
930
|
+
*
|
931
|
+
* @example
|
932
|
+
* ```ts
|
933
|
+
* static contextType = MyContext
|
934
|
+
* // For TS pre-3.7:
|
935
|
+
* context!: React.ContextType<typeof MyContext>
|
936
|
+
* // For TS 3.7 and above:
|
937
|
+
* declare context: React.ContextType<typeof MyContext>
|
938
|
+
* ```
|
939
|
+
*
|
940
|
+
* @see {@link https://react.dev/reference/react/Component#context React Docs}
|
941
|
+
*/
|
942
|
+
context: unknown;
|
943
|
+
|
944
|
+
// Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
|
945
|
+
constructor(props: P);
|
946
|
+
|
947
|
+
// We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
|
948
|
+
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
|
949
|
+
// Also, the ` | S` allows intellisense to not be dumbisense
|
950
|
+
setState<K extends keyof S>(
|
951
|
+
state: ((prevState: Readonly<S>, props: Readonly<P>) => Pick<S, K> | S | null) | (Pick<S, K> | S | null),
|
952
|
+
callback?: () => void,
|
953
|
+
): void;
|
954
|
+
|
955
|
+
forceUpdate(callback?: () => void): void;
|
956
|
+
render(): ReactNode;
|
957
|
+
|
958
|
+
readonly props: Readonly<P>;
|
959
|
+
state: Readonly<S>;
|
960
|
+
}
|
961
|
+
|
962
|
+
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
|
963
|
+
|
964
|
+
/**
|
965
|
+
* @deprecated Use `ClassicComponent` from `create-react-class`
|
966
|
+
*
|
967
|
+
* @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
|
968
|
+
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
969
|
+
*/
|
970
|
+
interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
|
971
|
+
replaceState(nextState: S, callback?: () => void): void;
|
972
|
+
isMounted(): boolean;
|
973
|
+
getInitialState?(): S;
|
974
|
+
}
|
975
|
+
|
976
|
+
//
|
977
|
+
// Class Interfaces
|
978
|
+
// ----------------------------------------------------------------------
|
979
|
+
|
980
|
+
/**
|
981
|
+
* Represents the type of a function component. Can optionally
|
982
|
+
* receive a type argument that represents the props the component
|
983
|
+
* receives.
|
984
|
+
*
|
985
|
+
* @template P The props the component accepts.
|
986
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}
|
987
|
+
* @alias for {@link FunctionComponent}
|
988
|
+
*
|
989
|
+
* @example
|
990
|
+
*
|
991
|
+
* ```tsx
|
992
|
+
* // With props:
|
993
|
+
* type Props = { name: string }
|
994
|
+
*
|
995
|
+
* const MyComponent: FC<Props> = (props) => {
|
996
|
+
* return <div>{props.name}</div>
|
997
|
+
* }
|
998
|
+
* ```
|
999
|
+
*
|
1000
|
+
* @example
|
1001
|
+
*
|
1002
|
+
* ```tsx
|
1003
|
+
* // Without props:
|
1004
|
+
* const MyComponentWithoutProps: FC = () => {
|
1005
|
+
* return <div>MyComponentWithoutProps</div>
|
1006
|
+
* }
|
1007
|
+
* ```
|
1008
|
+
*/
|
1009
|
+
type FC<P = {}> = FunctionComponent<P>;
|
1010
|
+
|
1011
|
+
/**
|
1012
|
+
* Represents the type of a function component. Can optionally
|
1013
|
+
* receive a type argument that represents the props the component
|
1014
|
+
* accepts.
|
1015
|
+
*
|
1016
|
+
* @template P The props the component accepts.
|
1017
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}
|
1018
|
+
*
|
1019
|
+
* @example
|
1020
|
+
*
|
1021
|
+
* ```tsx
|
1022
|
+
* // With props:
|
1023
|
+
* type Props = { name: string }
|
1024
|
+
*
|
1025
|
+
* const MyComponent: FunctionComponent<Props> = (props) => {
|
1026
|
+
* return <div>{props.name}</div>
|
1027
|
+
* }
|
1028
|
+
* ```
|
1029
|
+
*
|
1030
|
+
* @example
|
1031
|
+
*
|
1032
|
+
* ```tsx
|
1033
|
+
* // Without props:
|
1034
|
+
* const MyComponentWithoutProps: FunctionComponent = () => {
|
1035
|
+
* return <div>MyComponentWithoutProps</div>
|
1036
|
+
* }
|
1037
|
+
* ```
|
1038
|
+
*/
|
1039
|
+
interface FunctionComponent<P = {}> {
|
1040
|
+
(props: P): ReactElement<any, any> | null;
|
1041
|
+
/**
|
1042
|
+
* Ignored by React.
|
1043
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1044
|
+
*/
|
1045
|
+
propTypes?: any;
|
1046
|
+
/**
|
1047
|
+
* Used in debugging messages. You might want to set it
|
1048
|
+
* explicitly if you want to display a different name for
|
1049
|
+
* debugging purposes.
|
1050
|
+
*
|
1051
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
|
1052
|
+
*
|
1053
|
+
* @example
|
1054
|
+
*
|
1055
|
+
* ```tsx
|
1056
|
+
*
|
1057
|
+
* const MyComponent: FC = () => {
|
1058
|
+
* return <div>Hello!</div>
|
1059
|
+
* }
|
1060
|
+
*
|
1061
|
+
* MyComponent.displayName = 'MyAwesomeComponent'
|
1062
|
+
* ```
|
1063
|
+
*/
|
1064
|
+
displayName?: string | undefined;
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
/**
|
1068
|
+
* The type of the ref received by a {@link ForwardRefRenderFunction}.
|
1069
|
+
*
|
1070
|
+
* @see {@link ForwardRefRenderFunction}
|
1071
|
+
*/
|
1072
|
+
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
1073
|
+
|
1074
|
+
/**
|
1075
|
+
* The type of the function passed to {@link forwardRef}. This is considered different
|
1076
|
+
* to a normal {@link FunctionComponent} because it receives an additional argument,
|
1077
|
+
*
|
1078
|
+
* @param props Props passed to the component, if any.
|
1079
|
+
* @param ref A ref forwarded to the component of type {@link ForwardedRef}.
|
1080
|
+
*
|
1081
|
+
* @template T The type of the forwarded ref.
|
1082
|
+
* @template P The type of the props the component accepts.
|
1083
|
+
*
|
1084
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}
|
1085
|
+
* @see {@link forwardRef}
|
1086
|
+
*/
|
1087
|
+
interface ForwardRefRenderFunction<T, P = {}> {
|
1088
|
+
(props: P, ref: ForwardedRef<T>): ReactElement | null;
|
1089
|
+
/**
|
1090
|
+
* Used in debugging messages. You might want to set it
|
1091
|
+
* explicitly if you want to display a different name for
|
1092
|
+
* debugging purposes.
|
1093
|
+
*
|
1094
|
+
* Will show `ForwardRef(${Component.displayName || Component.name})`
|
1095
|
+
* in devtools by default, but can be given its own specific name.
|
1096
|
+
*
|
1097
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
|
1098
|
+
*/
|
1099
|
+
displayName?: string | undefined;
|
1100
|
+
/**
|
1101
|
+
* Ignored by React.
|
1102
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1103
|
+
*/
|
1104
|
+
propTypes?: any;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
/**
|
1108
|
+
* Represents a component class in React.
|
1109
|
+
*
|
1110
|
+
* @template P The props the component accepts.
|
1111
|
+
* @template S The internal state of the component.
|
1112
|
+
*/
|
1113
|
+
interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
|
1114
|
+
// constructor signature must match React.Component
|
1115
|
+
new(props: P): Component<P, S>;
|
1116
|
+
/**
|
1117
|
+
* Ignored by React.
|
1118
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1119
|
+
*/
|
1120
|
+
propTypes?: any;
|
1121
|
+
contextType?: Context<any> | undefined;
|
1122
|
+
defaultProps?: Partial<P> | undefined;
|
1123
|
+
/**
|
1124
|
+
* Used in debugging messages. You might want to set it
|
1125
|
+
* explicitly if you want to display a different name for
|
1126
|
+
* debugging purposes.
|
1127
|
+
*
|
1128
|
+
* @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
|
1129
|
+
*/
|
1130
|
+
displayName?: string | undefined;
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
/**
|
1134
|
+
* @deprecated Use `ClassicComponentClass` from `create-react-class`
|
1135
|
+
*
|
1136
|
+
* @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
|
1137
|
+
* @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
|
1138
|
+
*/
|
1139
|
+
interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
|
1140
|
+
new(props: P): ClassicComponent<P, ComponentState>;
|
1141
|
+
getDefaultProps?(): P;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
/**
|
1145
|
+
* Used in {@link createElement} and {@link createFactory} to represent
|
1146
|
+
* a class.
|
1147
|
+
*
|
1148
|
+
* An intersection type is used to infer multiple type parameters from
|
1149
|
+
* a single argument, which is useful for many top-level API defs.
|
1150
|
+
* See {@link https://github.com/Microsoft/TypeScript/issues/7234 this GitHub issue}
|
1151
|
+
* for more info.
|
1152
|
+
*/
|
1153
|
+
type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
|
1154
|
+
& C
|
1155
|
+
& (new(props: P) => T);
|
1156
|
+
|
1157
|
+
//
|
1158
|
+
// Component Specs and Lifecycle
|
1159
|
+
// ----------------------------------------------------------------------
|
1160
|
+
|
1161
|
+
// This should actually be something like `Lifecycle<P, S> | DeprecatedLifecycle<P, S>`,
|
1162
|
+
// as React will _not_ call the deprecated lifecycle methods if any of the new lifecycle
|
1163
|
+
// methods are present.
|
1164
|
+
interface ComponentLifecycle<P, S, SS = any> extends NewLifecycle<P, S, SS>, DeprecatedLifecycle<P, S> {
|
1165
|
+
/**
|
1166
|
+
* Called immediately after a component is mounted. Setting state here will trigger re-rendering.
|
1167
|
+
*/
|
1168
|
+
componentDidMount?(): void;
|
1169
|
+
/**
|
1170
|
+
* Called to determine whether the change in props and state should trigger a re-render.
|
1171
|
+
*
|
1172
|
+
* `Component` always returns true.
|
1173
|
+
* `PureComponent` implements a shallow comparison on props and state and returns true if any
|
1174
|
+
* props or states have changed.
|
1175
|
+
*
|
1176
|
+
* If false is returned, {@link Component.render}, `componentWillUpdate`
|
1177
|
+
* and `componentDidUpdate` will not be called.
|
1178
|
+
*/
|
1179
|
+
shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): boolean;
|
1180
|
+
/**
|
1181
|
+
* Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
|
1182
|
+
* cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
|
1183
|
+
*/
|
1184
|
+
componentWillUnmount?(): void;
|
1185
|
+
/**
|
1186
|
+
* Catches exceptions generated in descendant components. Unhandled exceptions will cause
|
1187
|
+
* the entire component tree to unmount.
|
1188
|
+
*/
|
1189
|
+
componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
// Unfortunately, we have no way of declaring that the component constructor must implement this
|
1193
|
+
interface StaticLifecycle<P, S> {
|
1194
|
+
getDerivedStateFromProps?: GetDerivedStateFromProps<P, S> | undefined;
|
1195
|
+
getDerivedStateFromError?: GetDerivedStateFromError<P, S> | undefined;
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
type GetDerivedStateFromProps<P, S> =
|
1199
|
+
/**
|
1200
|
+
* Returns an update to a component's state based on its new props and old state.
|
1201
|
+
*
|
1202
|
+
* Note: its presence prevents any of the deprecated lifecycle methods from being invoked
|
1203
|
+
*/
|
1204
|
+
(nextProps: Readonly<P>, prevState: S) => Partial<S> | null;
|
1205
|
+
|
1206
|
+
type GetDerivedStateFromError<P, S> =
|
1207
|
+
/**
|
1208
|
+
* This lifecycle is invoked after an error has been thrown by a descendant component.
|
1209
|
+
* It receives the error that was thrown as a parameter and should return a value to update state.
|
1210
|
+
*
|
1211
|
+
* Note: its presence prevents any of the deprecated lifecycle methods from being invoked
|
1212
|
+
*/
|
1213
|
+
(error: any) => Partial<S> | null;
|
1214
|
+
|
1215
|
+
// This should be "infer SS" but can't use it yet
|
1216
|
+
interface NewLifecycle<P, S, SS> {
|
1217
|
+
/**
|
1218
|
+
* Runs before React applies the result of {@link Component.render render} to the document, and
|
1219
|
+
* returns an object to be given to {@link componentDidUpdate}. Useful for saving
|
1220
|
+
* things such as scroll position before {@link Component.render render} causes changes to it.
|
1221
|
+
*
|
1222
|
+
* Note: the presence of this method prevents any of the deprecated
|
1223
|
+
* lifecycle events from running.
|
1224
|
+
*/
|
1225
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null;
|
1226
|
+
/**
|
1227
|
+
* Called immediately after updating occurs. Not called for the initial render.
|
1228
|
+
*
|
1229
|
+
* The snapshot is only present if {@link getSnapshotBeforeUpdate} is present and returns non-null.
|
1230
|
+
*/
|
1231
|
+
componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void;
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
interface DeprecatedLifecycle<P, S> {
|
1235
|
+
/**
|
1236
|
+
* Called immediately before mounting occurs, and before {@link Component.render}.
|
1237
|
+
* Avoid introducing any side-effects or subscriptions in this method.
|
1238
|
+
*
|
1239
|
+
* Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
|
1240
|
+
* or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
|
1241
|
+
* this from being invoked.
|
1242
|
+
*
|
1243
|
+
* @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead; will stop working in React 17
|
1244
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
|
1245
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1246
|
+
*/
|
1247
|
+
componentWillMount?(): void;
|
1248
|
+
/**
|
1249
|
+
* Called immediately before mounting occurs, and before {@link Component.render}.
|
1250
|
+
* Avoid introducing any side-effects or subscriptions in this method.
|
1251
|
+
*
|
1252
|
+
* This method will not stop working in React 17.
|
1253
|
+
*
|
1254
|
+
* Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
|
1255
|
+
* or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
|
1256
|
+
* this from being invoked.
|
1257
|
+
*
|
1258
|
+
* @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead
|
1259
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
|
1260
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1261
|
+
*/
|
1262
|
+
UNSAFE_componentWillMount?(): void;
|
1263
|
+
/**
|
1264
|
+
* Called when the component may be receiving new props.
|
1265
|
+
* React may call this even if props have not changed, so be sure to compare new and existing
|
1266
|
+
* props if you only want to handle changes.
|
1267
|
+
*
|
1268
|
+
* Calling {@link Component.setState} generally does not trigger this method.
|
1269
|
+
*
|
1270
|
+
* Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
|
1271
|
+
* or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
|
1272
|
+
* this from being invoked.
|
1273
|
+
*
|
1274
|
+
* @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead; will stop working in React 17
|
1275
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
|
1276
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1277
|
+
*/
|
1278
|
+
componentWillReceiveProps?(nextProps: Readonly<P>): void;
|
1279
|
+
/**
|
1280
|
+
* Called when the component may be receiving new props.
|
1281
|
+
* React may call this even if props have not changed, so be sure to compare new and existing
|
1282
|
+
* props if you only want to handle changes.
|
1283
|
+
*
|
1284
|
+
* Calling {@link Component.setState} generally does not trigger this method.
|
1285
|
+
*
|
1286
|
+
* This method will not stop working in React 17.
|
1287
|
+
*
|
1288
|
+
* Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
|
1289
|
+
* or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
|
1290
|
+
* this from being invoked.
|
1291
|
+
*
|
1292
|
+
* @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead
|
1293
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
|
1294
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1295
|
+
*/
|
1296
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>): void;
|
1297
|
+
/**
|
1298
|
+
* Called immediately before rendering when new props or state is received. Not called for the initial render.
|
1299
|
+
*
|
1300
|
+
* Note: You cannot call {@link Component.setState} here.
|
1301
|
+
*
|
1302
|
+
* Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
|
1303
|
+
* or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
|
1304
|
+
* this from being invoked.
|
1305
|
+
*
|
1306
|
+
* @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17
|
1307
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
|
1308
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1309
|
+
*/
|
1310
|
+
componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
|
1311
|
+
/**
|
1312
|
+
* Called immediately before rendering when new props or state is received. Not called for the initial render.
|
1313
|
+
*
|
1314
|
+
* Note: You cannot call {@link Component.setState} here.
|
1315
|
+
*
|
1316
|
+
* This method will not stop working in React 17.
|
1317
|
+
*
|
1318
|
+
* Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
|
1319
|
+
* or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
|
1320
|
+
* this from being invoked.
|
1321
|
+
*
|
1322
|
+
* @deprecated 16.3, use getSnapshotBeforeUpdate instead
|
1323
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
|
1324
|
+
* @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
|
1325
|
+
*/
|
1326
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
function createRef<T>(): RefObject<T | null>;
|
1330
|
+
|
1331
|
+
/**
|
1332
|
+
* The type of the component returned from {@link forwardRef}.
|
1333
|
+
*
|
1334
|
+
* @template P The props the component accepts, if any.
|
1335
|
+
*
|
1336
|
+
* @see {@link ExoticComponent}
|
1337
|
+
*/
|
1338
|
+
interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
|
1339
|
+
/**
|
1340
|
+
* Ignored by React.
|
1341
|
+
* @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
|
1342
|
+
*/
|
1343
|
+
propTypes?: any;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
/**
|
1347
|
+
* Lets your component expose a DOM node to a parent component
|
1348
|
+
* using a ref.
|
1349
|
+
*
|
1350
|
+
* @see {@link https://react.dev/reference/react/forwardRef React Docs}
|
1351
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}
|
1352
|
+
*
|
1353
|
+
* @param render See the {@link ForwardRefRenderFunction}.
|
1354
|
+
*
|
1355
|
+
* @template T The type of the DOM node.
|
1356
|
+
* @template P The props the component accepts, if any.
|
1357
|
+
*
|
1358
|
+
* @example
|
1359
|
+
*
|
1360
|
+
* ```tsx
|
1361
|
+
* interface Props {
|
1362
|
+
* children?: ReactNode;
|
1363
|
+
* type: "submit" | "button";
|
1364
|
+
* }
|
1365
|
+
*
|
1366
|
+
* export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
|
1367
|
+
* <button ref={ref} className="MyClassName" type={props.type}>
|
1368
|
+
* {props.children}
|
1369
|
+
* </button>
|
1370
|
+
* ));
|
1371
|
+
* ```
|
1372
|
+
*/
|
1373
|
+
function forwardRef<T, P = {}>(
|
1374
|
+
render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
|
1375
|
+
): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
1376
|
+
|
1377
|
+
/**
|
1378
|
+
* Omits the 'ref' attribute from the given props object.
|
1379
|
+
*
|
1380
|
+
* @template Props The props object type.
|
1381
|
+
*/
|
1382
|
+
type PropsWithoutRef<Props> =
|
1383
|
+
// Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
|
1384
|
+
// see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
|
1385
|
+
// https://github.com/Microsoft/TypeScript/issues/28339
|
1386
|
+
Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
|
1387
|
+
/**
|
1388
|
+
* Ensures that the props do not include string ref, which cannot be forwarded
|
1389
|
+
* @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
|
1390
|
+
*/
|
1391
|
+
type PropsWithRef<Props> = Props;
|
1392
|
+
|
1393
|
+
type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
|
1394
|
+
|
1395
|
+
/**
|
1396
|
+
* Used to retrieve the props a component accepts. Can either be passed a string,
|
1397
|
+
* indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React
|
1398
|
+
* component.
|
1399
|
+
*
|
1400
|
+
* It's usually better to use {@link ComponentPropsWithRef} or {@link ComponentPropsWithoutRef}
|
1401
|
+
* instead of this type, as they let you be explicit about whether or not to include
|
1402
|
+
* the `ref` prop.
|
1403
|
+
*
|
1404
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}
|
1405
|
+
*
|
1406
|
+
* @example
|
1407
|
+
*
|
1408
|
+
* ```tsx
|
1409
|
+
* // Retrieves the props an 'input' element accepts
|
1410
|
+
* type InputProps = React.ComponentProps<'input'>;
|
1411
|
+
* ```
|
1412
|
+
*
|
1413
|
+
* @example
|
1414
|
+
*
|
1415
|
+
* ```tsx
|
1416
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1417
|
+
*
|
1418
|
+
* // Retrieves the props 'MyComponent' accepts
|
1419
|
+
* type MyComponentProps = React.ComponentProps<typeof MyComponent>;
|
1420
|
+
* ```
|
1421
|
+
*/
|
1422
|
+
type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
|
1423
|
+
JSXElementConstructor<infer Props> ? Props
|
1424
|
+
: T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
|
1425
|
+
: {};
|
1426
|
+
|
1427
|
+
/**
|
1428
|
+
* Used to retrieve the props a component accepts with its ref. Can either be
|
1429
|
+
* passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the
|
1430
|
+
* type of a React component.
|
1431
|
+
*
|
1432
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}
|
1433
|
+
*
|
1434
|
+
* @example
|
1435
|
+
*
|
1436
|
+
* ```tsx
|
1437
|
+
* // Retrieves the props an 'input' element accepts
|
1438
|
+
* type InputProps = React.ComponentPropsWithRef<'input'>;
|
1439
|
+
* ```
|
1440
|
+
*
|
1441
|
+
* @example
|
1442
|
+
*
|
1443
|
+
* ```tsx
|
1444
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1445
|
+
*
|
1446
|
+
* // Retrieves the props 'MyComponent' accepts
|
1447
|
+
* type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
|
1448
|
+
* ```
|
1449
|
+
*/
|
1450
|
+
type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
|
1451
|
+
// If it's a class i.e. newable we're dealing with a class component
|
1452
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
1453
|
+
: Props
|
1454
|
+
: ComponentProps<T>;
|
1455
|
+
/**
|
1456
|
+
* Used to retrieve the props a custom component accepts with its ref.
|
1457
|
+
*
|
1458
|
+
* Unlike {@link ComponentPropsWithRef}, this only works with custom
|
1459
|
+
* components, i.e. components you define yourself. This is to improve
|
1460
|
+
* type-checking performance.
|
1461
|
+
*
|
1462
|
+
* @example
|
1463
|
+
*
|
1464
|
+
* ```tsx
|
1465
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1466
|
+
*
|
1467
|
+
* // Retrieves the props 'MyComponent' accepts
|
1468
|
+
* type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
|
1469
|
+
* ```
|
1470
|
+
*/
|
1471
|
+
type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
|
1472
|
+
// If it's a class i.e. newable we're dealing with a class component
|
1473
|
+
? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
|
1474
|
+
: Props
|
1475
|
+
: never;
|
1476
|
+
|
1477
|
+
/**
|
1478
|
+
* Used to retrieve the props a component accepts without its ref. Can either be
|
1479
|
+
* passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the
|
1480
|
+
* type of a React component.
|
1481
|
+
*
|
1482
|
+
* @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}
|
1483
|
+
*
|
1484
|
+
* @example
|
1485
|
+
*
|
1486
|
+
* ```tsx
|
1487
|
+
* // Retrieves the props an 'input' element accepts
|
1488
|
+
* type InputProps = React.ComponentPropsWithoutRef<'input'>;
|
1489
|
+
* ```
|
1490
|
+
*
|
1491
|
+
* @example
|
1492
|
+
*
|
1493
|
+
* ```tsx
|
1494
|
+
* const MyComponent = (props: { foo: number, bar: string }) => <div />;
|
1495
|
+
*
|
1496
|
+
* // Retrieves the props 'MyComponent' accepts
|
1497
|
+
* type MyComponentPropsWithoutRef = React.ComponentPropsWithoutRef<typeof MyComponent>;
|
1498
|
+
* ```
|
1499
|
+
*/
|
1500
|
+
type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
|
1501
|
+
|
1502
|
+
/**
|
1503
|
+
* Retrieves the type of the 'ref' prop for a given component type or tag name.
|
1504
|
+
*
|
1505
|
+
* @template C The component type.
|
1506
|
+
*
|
1507
|
+
* @example
|
1508
|
+
*
|
1509
|
+
* ```tsx
|
1510
|
+
* type MyComponentRef = React.ElementRef<typeof MyComponent>;
|
1511
|
+
* ```
|
1512
|
+
*
|
1513
|
+
* @example
|
1514
|
+
*
|
1515
|
+
* ```tsx
|
1516
|
+
* type DivRef = React.ElementRef<'div'>;
|
1517
|
+
* ```
|
1518
|
+
*/
|
1519
|
+
type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
|
1520
|
+
: never;
|
1521
|
+
|
1522
|
+
// will show `Memo(${Component.displayName || Component.name})` in devtools by default,
|
1523
|
+
// but can be given its own specific name
|
1524
|
+
type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<CustomComponentPropsWithRef<T>> & {
|
1525
|
+
readonly type: T;
|
1526
|
+
};
|
1527
|
+
|
1528
|
+
/**
|
1529
|
+
* Lets you skip re-rendering a component when its props are unchanged.
|
1530
|
+
*
|
1531
|
+
* @see {@link https://react.dev/reference/react/memo React Docs}
|
1532
|
+
*
|
1533
|
+
* @param Component The component to memoize.
|
1534
|
+
* @param propsAreEqual A function that will be used to determine if the props have changed.
|
1535
|
+
*
|
1536
|
+
* @example
|
1537
|
+
*
|
1538
|
+
* ```tsx
|
1539
|
+
* import { memo } from 'react';
|
1540
|
+
*
|
1541
|
+
* const SomeComponent = memo(function SomeComponent(props: { foo: string }) {
|
1542
|
+
* // ...
|
1543
|
+
* });
|
1544
|
+
* ```
|
1545
|
+
*/
|
1546
|
+
function memo<P extends object>(
|
1547
|
+
Component: FunctionComponent<P>,
|
1548
|
+
propsAreEqual?: (prevProps: Readonly<P>, nextProps: Readonly<P>) => boolean,
|
1549
|
+
): NamedExoticComponent<P>;
|
1550
|
+
function memo<T extends ComponentType<any>>(
|
1551
|
+
Component: T,
|
1552
|
+
propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
|
1553
|
+
): MemoExoticComponent<T>;
|
1554
|
+
|
1555
|
+
interface LazyExoticComponent<T extends ComponentType<any>>
|
1556
|
+
extends ExoticComponent<CustomComponentPropsWithRef<T>>
|
1557
|
+
{
|
1558
|
+
readonly _result: T;
|
1559
|
+
}
|
1560
|
+
|
1561
|
+
/**
|
1562
|
+
* Lets you defer loading a component’s code until it is rendered for the first time.
|
1563
|
+
*
|
1564
|
+
* @see {@link https://react.dev/reference/react/lazy React Docs}
|
1565
|
+
*
|
1566
|
+
* @param load A function that returns a `Promise` or another thenable (a `Promise`-like object with a
|
1567
|
+
* then method). React will not call `load` until the first time you attempt to render the returned
|
1568
|
+
* component. After React first calls load, it will wait for it to resolve, and then render the
|
1569
|
+
* resolved value’s `.default` as a React component. Both the returned `Promise` and the `Promise`’s
|
1570
|
+
* resolved value will be cached, so React will not call load more than once. If the `Promise` rejects,
|
1571
|
+
* React will throw the rejection reason for the nearest Error Boundary to handle.
|
1572
|
+
*
|
1573
|
+
* @example
|
1574
|
+
*
|
1575
|
+
* ```tsx
|
1576
|
+
* import { lazy } from 'react';
|
1577
|
+
*
|
1578
|
+
* const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
|
1579
|
+
* ```
|
1580
|
+
*/
|
1581
|
+
function lazy<T extends ComponentType<any>>(
|
1582
|
+
load: () => Promise<{ default: T }>,
|
1583
|
+
): LazyExoticComponent<T>;
|
1584
|
+
|
1585
|
+
//
|
1586
|
+
// React Hooks
|
1587
|
+
// ----------------------------------------------------------------------
|
1588
|
+
|
1589
|
+
/**
|
1590
|
+
* The instruction passed to a {@link Dispatch} function in {@link useState}
|
1591
|
+
* to tell React what the next value of the {@link useState} should be.
|
1592
|
+
*
|
1593
|
+
* Often found wrapped in {@link Dispatch}.
|
1594
|
+
*
|
1595
|
+
* @template S The type of the state.
|
1596
|
+
*
|
1597
|
+
* @example
|
1598
|
+
*
|
1599
|
+
* ```tsx
|
1600
|
+
* // This return type correctly represents the type of
|
1601
|
+
* // `setCount` in the example below.
|
1602
|
+
* const useCustomState = (): Dispatch<SetStateAction<number>> => {
|
1603
|
+
* const [count, setCount] = useState(0);
|
1604
|
+
*
|
1605
|
+
* return setCount;
|
1606
|
+
* }
|
1607
|
+
* ```
|
1608
|
+
*/
|
1609
|
+
type SetStateAction<S> = S | ((prevState: S) => S);
|
1610
|
+
|
1611
|
+
/**
|
1612
|
+
* A function that can be used to update the state of a {@link useState}
|
1613
|
+
* or {@link useReducer} hook.
|
1614
|
+
*/
|
1615
|
+
type Dispatch<A> = (value: A) => void;
|
1616
|
+
/**
|
1617
|
+
* A {@link Dispatch} function can sometimes be called without any arguments.
|
1618
|
+
*/
|
1619
|
+
type DispatchWithoutAction = () => void;
|
1620
|
+
// Limit the reducer to accept only 0 or 1 action arguments
|
1621
|
+
// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
|
1622
|
+
type AnyActionArg = [] | [any];
|
1623
|
+
// Get the dispatch type from the reducer arguments (captures optional action argument correctly)
|
1624
|
+
type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
|
1625
|
+
// Unlike redux, the actions _can_ be anything
|
1626
|
+
type Reducer<S, A> = (prevState: S, action: A) => S;
|
1627
|
+
// If useReducer accepts a reducer without action, dispatch may be called without any parameters.
|
1628
|
+
type ReducerWithoutAction<S> = (prevState: S) => S;
|
1629
|
+
// types used to try and prevent the compiler from reducing S
|
1630
|
+
// to a supertype common with the second argument to useReducer()
|
1631
|
+
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
|
1632
|
+
type DependencyList = readonly unknown[];
|
1633
|
+
|
1634
|
+
// NOTE: callbacks are _only_ allowed to return either void, or a destructor.
|
1635
|
+
type EffectCallback = () => void | Destructor;
|
1636
|
+
|
1637
|
+
/**
|
1638
|
+
* @deprecated Use `RefObject` instead.
|
1639
|
+
*/
|
1640
|
+
interface MutableRefObject<T> {
|
1641
|
+
current: T;
|
1642
|
+
}
|
1643
|
+
|
1644
|
+
// This will technically work if you give a Consumer<T> or Provider<T> but it's deprecated and warns
|
1645
|
+
/**
|
1646
|
+
* Accepts a context object (the value returned from `React.createContext`) and returns the current
|
1647
|
+
* context value, as given by the nearest context provider for the given context.
|
1648
|
+
*
|
1649
|
+
* @version 16.8.0
|
1650
|
+
* @see {@link https://react.dev/reference/react/useContext}
|
1651
|
+
*/
|
1652
|
+
function useContext<T>(context: Context<T> /*, (not public API) observedBits?: number|boolean */): T;
|
1653
|
+
/**
|
1654
|
+
* Returns a stateful value, and a function to update it.
|
1655
|
+
*
|
1656
|
+
* @version 16.8.0
|
1657
|
+
* @see {@link https://react.dev/reference/react/useState}
|
1658
|
+
*/
|
1659
|
+
function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
|
1660
|
+
// convenience overload when first argument is omitted
|
1661
|
+
/**
|
1662
|
+
* Returns a stateful value, and a function to update it.
|
1663
|
+
*
|
1664
|
+
* @version 16.8.0
|
1665
|
+
* @see {@link https://react.dev/reference/react/useState}
|
1666
|
+
*/
|
1667
|
+
function useState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
|
1668
|
+
/**
|
1669
|
+
* An alternative to `useState`.
|
1670
|
+
*
|
1671
|
+
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1672
|
+
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1673
|
+
* updates because you can pass `dispatch` down instead of callbacks.
|
1674
|
+
*
|
1675
|
+
* @version 16.8.0
|
1676
|
+
* @see {@link https://react.dev/reference/react/useReducer}
|
1677
|
+
*/
|
1678
|
+
function useReducer<S, A extends AnyActionArg>(
|
1679
|
+
reducer: (prevState: S, ...args: A) => S,
|
1680
|
+
initialState: S,
|
1681
|
+
): [S, ActionDispatch<A>];
|
1682
|
+
/**
|
1683
|
+
* An alternative to `useState`.
|
1684
|
+
*
|
1685
|
+
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1686
|
+
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1687
|
+
* updates because you can pass `dispatch` down instead of callbacks.
|
1688
|
+
*
|
1689
|
+
* @version 16.8.0
|
1690
|
+
* @see {@link https://react.dev/reference/react/useReducer}
|
1691
|
+
*/
|
1692
|
+
function useReducer<S, A extends AnyActionArg>(
|
1693
|
+
reducer: (prevState: S, ...args: A) => S,
|
1694
|
+
initialState: S,
|
1695
|
+
): [S, ActionDispatch<A>];
|
1696
|
+
/**
|
1697
|
+
* An alternative to `useState`.
|
1698
|
+
*
|
1699
|
+
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
1700
|
+
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
1701
|
+
* updates because you can pass `dispatch` down instead of callbacks.
|
1702
|
+
*
|
1703
|
+
* @version 16.8.0
|
1704
|
+
* @see {@link https://react.dev/reference/react/useReducer}
|
1705
|
+
*/
|
1706
|
+
function useReducer<S, I, A extends AnyActionArg>(
|
1707
|
+
reducer: (prevState: S, ...args: A) => S,
|
1708
|
+
initialArg: I,
|
1709
|
+
init: (i: I) => S,
|
1710
|
+
): [S, ActionDispatch<A>];
|
1711
|
+
/**
|
1712
|
+
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
1713
|
+
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
1714
|
+
*
|
1715
|
+
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
1716
|
+
* value around similar to how you’d use instance fields in classes.
|
1717
|
+
*
|
1718
|
+
* @version 16.8.0
|
1719
|
+
* @see {@link https://react.dev/reference/react/useRef}
|
1720
|
+
*/
|
1721
|
+
function useRef<T>(initialValue: T): RefObject<T>;
|
1722
|
+
// convenience overload for refs given as a ref prop as they typically start with a null value
|
1723
|
+
/**
|
1724
|
+
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
1725
|
+
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
1726
|
+
*
|
1727
|
+
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
1728
|
+
* value around similar to how you’d use instance fields in classes.
|
1729
|
+
*
|
1730
|
+
* @version 16.8.0
|
1731
|
+
* @see {@link https://react.dev/reference/react/useRef}
|
1732
|
+
*/
|
1733
|
+
function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
1734
|
+
// convenience overload for undefined initialValue
|
1735
|
+
/**
|
1736
|
+
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
1737
|
+
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
1738
|
+
*
|
1739
|
+
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
1740
|
+
* value around similar to how you’d use instance fields in classes.
|
1741
|
+
*
|
1742
|
+
* @version 16.8.0
|
1743
|
+
* @see {@link https://react.dev/reference/react/useRef}
|
1744
|
+
*/
|
1745
|
+
function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
1746
|
+
/**
|
1747
|
+
* The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
|
1748
|
+
* Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
|
1749
|
+
* `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint.
|
1750
|
+
*
|
1751
|
+
* Prefer the standard `useEffect` when possible to avoid blocking visual updates.
|
1752
|
+
*
|
1753
|
+
* If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as
|
1754
|
+
* `componentDidMount` and `componentDidUpdate`.
|
1755
|
+
*
|
1756
|
+
* @version 16.8.0
|
1757
|
+
* @see {@link https://react.dev/reference/react/useLayoutEffect}
|
1758
|
+
*/
|
1759
|
+
function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;
|
1760
|
+
/**
|
1761
|
+
* Accepts a function that contains imperative, possibly effectful code.
|
1762
|
+
*
|
1763
|
+
* @param effect Imperative function that can return a cleanup function
|
1764
|
+
* @param deps If present, effect will only activate if the values in the list change.
|
1765
|
+
*
|
1766
|
+
* @version 16.8.0
|
1767
|
+
* @see {@link https://react.dev/reference/react/useEffect}
|
1768
|
+
*/
|
1769
|
+
function useEffect(effect: EffectCallback, deps?: DependencyList): void;
|
1770
|
+
// NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref<T>
|
1771
|
+
/**
|
1772
|
+
* `useImperativeHandle` customizes the instance value that is exposed to parent components when using
|
1773
|
+
* `ref`. As always, imperative code using refs should be avoided in most cases.
|
1774
|
+
*
|
1775
|
+
* `useImperativeHandle` should be used with `React.forwardRef`.
|
1776
|
+
*
|
1777
|
+
* @version 16.8.0
|
1778
|
+
* @see {@link https://react.dev/reference/react/useImperativeHandle}
|
1779
|
+
*/
|
1780
|
+
function useImperativeHandle<T, R extends T>(ref: Ref<T> | undefined, init: () => R, deps?: DependencyList): void;
|
1781
|
+
// I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key
|
1782
|
+
// useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y.
|
1783
|
+
/**
|
1784
|
+
* `useCallback` will return a memoized version of the callback that only changes if one of the `inputs`
|
1785
|
+
* has changed.
|
1786
|
+
*
|
1787
|
+
* @version 16.8.0
|
1788
|
+
* @see {@link https://react.dev/reference/react/useCallback}
|
1789
|
+
*/
|
1790
|
+
// A specific function type would not trigger implicit any.
|
1791
|
+
// See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
|
1792
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
1793
|
+
function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
|
1794
|
+
/**
|
1795
|
+
* `useMemo` will only recompute the memoized value when one of the `deps` has changed.
|
1796
|
+
*
|
1797
|
+
* @version 16.8.0
|
1798
|
+
* @see {@link https://react.dev/reference/react/useMemo}
|
1799
|
+
*/
|
1800
|
+
// allow undefined, but don't make it optional as that is very likely a mistake
|
1801
|
+
function useMemo<T>(factory: () => T, deps: DependencyList): T;
|
1802
|
+
/**
|
1803
|
+
* `useDebugValue` can be used to display a label for custom hooks in React DevTools.
|
1804
|
+
*
|
1805
|
+
* NOTE: We don’t recommend adding debug values to every custom hook.
|
1806
|
+
* It’s most valuable for custom hooks that are part of shared libraries.
|
1807
|
+
*
|
1808
|
+
* @version 16.8.0
|
1809
|
+
* @see {@link https://react.dev/reference/react/useDebugValue}
|
1810
|
+
*/
|
1811
|
+
// the name of the custom hook is itself derived from the function name at runtime:
|
1812
|
+
// it's just the function name without the "use" prefix.
|
1813
|
+
function useDebugValue<T>(value: T, format?: (value: T) => any): void;
|
1814
|
+
|
1815
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
|
1816
|
+
// strange definition to allow vscode to show documentation on the invocation
|
1817
|
+
export interface TransitionStartFunction {
|
1818
|
+
/**
|
1819
|
+
* State updates caused inside the callback are allowed to be deferred.
|
1820
|
+
*
|
1821
|
+
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
1822
|
+
*
|
1823
|
+
* @param callback A function which causes state updates that can be deferred.
|
1824
|
+
*/
|
1825
|
+
(callback: TransitionFunction): void;
|
1826
|
+
}
|
1827
|
+
|
1828
|
+
/**
|
1829
|
+
* Returns a deferred version of the value that may “lag behind” it.
|
1830
|
+
*
|
1831
|
+
* This is commonly used to keep the interface responsive when you have something that renders immediately
|
1832
|
+
* based on user input and something that needs to wait for a data fetch.
|
1833
|
+
*
|
1834
|
+
* A good example of this is a text input.
|
1835
|
+
*
|
1836
|
+
* @param value The value that is going to be deferred
|
1837
|
+
* @param initialValue A value to use during the initial render of a component. If this option is omitted, `useDeferredValue` will not defer during the initial render, because there’s no previous version of `value` that it can render instead.
|
1838
|
+
*
|
1839
|
+
* @see {@link https://react.dev/reference/react/useDeferredValue}
|
1840
|
+
*/
|
1841
|
+
export function useDeferredValue<T>(value: T, initialValue?: T): T;
|
1842
|
+
|
1843
|
+
/**
|
1844
|
+
* Allows components to avoid undesirable loading states by waiting for content to load
|
1845
|
+
* before transitioning to the next screen. It also allows components to defer slower,
|
1846
|
+
* data fetching updates until subsequent renders so that more crucial updates can be
|
1847
|
+
* rendered immediately.
|
1848
|
+
*
|
1849
|
+
* The `useTransition` hook returns two values in an array.
|
1850
|
+
*
|
1851
|
+
* The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish.
|
1852
|
+
* The second is a function that takes a callback. We can use it to tell React which state we want to defer.
|
1853
|
+
*
|
1854
|
+
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
1855
|
+
*
|
1856
|
+
* @see {@link https://react.dev/reference/react/useTransition}
|
1857
|
+
*/
|
1858
|
+
export function useTransition(): [boolean, TransitionStartFunction];
|
1859
|
+
|
1860
|
+
/**
|
1861
|
+
* Similar to `useTransition` but allows uses where hooks are not available.
|
1862
|
+
*
|
1863
|
+
* @param callback A function which causes state updates that can be deferred.
|
1864
|
+
*/
|
1865
|
+
export function startTransition(scope: TransitionFunction): void;
|
1866
|
+
export function startTransition(scope: TransitionFunction): void;
|
1867
|
+
|
1868
|
+
/**
|
1869
|
+
* Wrap any code rendering and triggering updates to your components into `act()` calls.
|
1870
|
+
*
|
1871
|
+
* Ensures that the behavior in your tests matches what happens in the browser
|
1872
|
+
* more closely by executing pending `useEffect`s before returning. This also
|
1873
|
+
* reduces the amount of re-renders done.
|
1874
|
+
*
|
1875
|
+
* @param callback A synchronous, void callback that will execute as a single, complete React commit.
|
1876
|
+
*
|
1877
|
+
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
1878
|
+
*/
|
1879
|
+
// NOTES
|
1880
|
+
// - the order of these signatures matters - typescript will check the signatures in source order.
|
1881
|
+
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
|
1882
|
+
// `strictNullChecks: false`.
|
1883
|
+
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
|
1884
|
+
// While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
|
1885
|
+
export function act(callback: () => VoidOrUndefinedOnly): void;
|
1886
|
+
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
|
1887
|
+
|
1888
|
+
export function useId(): string;
|
1889
|
+
|
1890
|
+
/**
|
1891
|
+
* @param effect Imperative function that can return a cleanup function
|
1892
|
+
* @param deps If present, effect will only activate if the values in the list change.
|
1893
|
+
*
|
1894
|
+
* @see {@link https://github.com/facebook/react/pull/21913}
|
1895
|
+
*/
|
1896
|
+
export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void;
|
1897
|
+
|
1898
|
+
/**
|
1899
|
+
* @param subscribe
|
1900
|
+
* @param getSnapshot
|
1901
|
+
*
|
1902
|
+
* @see {@link https://github.com/reactwg/react-18/discussions/86}
|
1903
|
+
*/
|
1904
|
+
// keep in sync with `useSyncExternalStore` from `use-sync-external-store`
|
1905
|
+
export function useSyncExternalStore<Snapshot>(
|
1906
|
+
subscribe: (onStoreChange: () => void) => () => void,
|
1907
|
+
getSnapshot: () => Snapshot,
|
1908
|
+
getServerSnapshot?: () => Snapshot,
|
1909
|
+
): Snapshot;
|
1910
|
+
|
1911
|
+
export function useOptimistic<State>(
|
1912
|
+
passthrough: State,
|
1913
|
+
): [State, (action: State | ((pendingState: State) => State)) => void];
|
1914
|
+
export function useOptimistic<State, Action>(
|
1915
|
+
passthrough: State,
|
1916
|
+
reducer: (state: State, action: Action) => State,
|
1917
|
+
): [State, (action: Action) => void];
|
1918
|
+
|
1919
|
+
export type Usable<T> = PromiseLike<T> | Context<T>;
|
1920
|
+
|
1921
|
+
export function use<T>(usable: Usable<T>): T;
|
1922
|
+
|
1923
|
+
export function useActionState<State>(
|
1924
|
+
action: (state: Awaited<State>) => State | Promise<State>,
|
1925
|
+
initialState: Awaited<State>,
|
1926
|
+
permalink?: string,
|
1927
|
+
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
1928
|
+
export function useActionState<State, Payload>(
|
1929
|
+
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
1930
|
+
initialState: Awaited<State>,
|
1931
|
+
permalink?: string,
|
1932
|
+
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
1933
|
+
|
1934
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
1935
|
+
export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
1936
|
+
|
1937
|
+
//
|
1938
|
+
// Event System
|
1939
|
+
// ----------------------------------------------------------------------
|
1940
|
+
// TODO: change any to unknown when moving to TS v3
|
1941
|
+
interface BaseSyntheticEvent<E = object, C = any, T = any> {
|
1942
|
+
nativeEvent: E;
|
1943
|
+
currentTarget: C;
|
1944
|
+
target: T;
|
1945
|
+
bubbles: boolean;
|
1946
|
+
cancelable: boolean;
|
1947
|
+
defaultPrevented: boolean;
|
1948
|
+
eventPhase: number;
|
1949
|
+
isTrusted: boolean;
|
1950
|
+
preventDefault(): void;
|
1951
|
+
isDefaultPrevented(): boolean;
|
1952
|
+
stopPropagation(): void;
|
1953
|
+
isPropagationStopped(): boolean;
|
1954
|
+
persist(): void;
|
1955
|
+
timeStamp: number;
|
1956
|
+
type: string;
|
1957
|
+
}
|
1958
|
+
|
1959
|
+
/**
|
1960
|
+
* currentTarget - a reference to the element on which the event listener is registered.
|
1961
|
+
*
|
1962
|
+
* target - a reference to the element from which the event was originally dispatched.
|
1963
|
+
* This might be a child element to the element on which the event listener is registered.
|
1964
|
+
* If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
|
1965
|
+
*/
|
1966
|
+
interface SyntheticEvent<T = Element, E = Event> extends BaseSyntheticEvent<E, EventTarget & T, EventTarget> {}
|
1967
|
+
|
1968
|
+
interface ClipboardEvent<T = Element> extends SyntheticEvent<T, NativeClipboardEvent> {
|
1969
|
+
clipboardData: DataTransfer;
|
1970
|
+
}
|
1971
|
+
|
1972
|
+
interface CompositionEvent<T = Element> extends SyntheticEvent<T, NativeCompositionEvent> {
|
1973
|
+
data: string;
|
1974
|
+
}
|
1975
|
+
|
1976
|
+
interface DragEvent<T = Element> extends MouseEvent<T, NativeDragEvent> {
|
1977
|
+
dataTransfer: DataTransfer;
|
1978
|
+
}
|
1979
|
+
|
1980
|
+
interface PointerEvent<T = Element> extends MouseEvent<T, NativePointerEvent> {
|
1981
|
+
pointerId: number;
|
1982
|
+
pressure: number;
|
1983
|
+
tangentialPressure: number;
|
1984
|
+
tiltX: number;
|
1985
|
+
tiltY: number;
|
1986
|
+
twist: number;
|
1987
|
+
width: number;
|
1988
|
+
height: number;
|
1989
|
+
pointerType: "mouse" | "pen" | "touch";
|
1990
|
+
isPrimary: boolean;
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
interface FocusEvent<Target = Element, RelatedTarget = Element> extends SyntheticEvent<Target, NativeFocusEvent> {
|
1994
|
+
relatedTarget: (EventTarget & RelatedTarget) | null;
|
1995
|
+
target: EventTarget & Target;
|
1996
|
+
}
|
1997
|
+
|
1998
|
+
interface FormEvent<T = Element> extends SyntheticEvent<T> {
|
1999
|
+
}
|
2000
|
+
|
2001
|
+
interface InvalidEvent<T = Element> extends SyntheticEvent<T> {
|
2002
|
+
target: EventTarget & T;
|
2003
|
+
}
|
2004
|
+
|
2005
|
+
interface ChangeEvent<T = Element> extends SyntheticEvent<T> {
|
2006
|
+
target: EventTarget & T;
|
2007
|
+
}
|
2008
|
+
|
2009
|
+
export type ModifierKey =
|
2010
|
+
| "Alt"
|
2011
|
+
| "AltGraph"
|
2012
|
+
| "CapsLock"
|
2013
|
+
| "Control"
|
2014
|
+
| "Fn"
|
2015
|
+
| "FnLock"
|
2016
|
+
| "Hyper"
|
2017
|
+
| "Meta"
|
2018
|
+
| "NumLock"
|
2019
|
+
| "ScrollLock"
|
2020
|
+
| "Shift"
|
2021
|
+
| "Super"
|
2022
|
+
| "Symbol"
|
2023
|
+
| "SymbolLock";
|
2024
|
+
|
2025
|
+
interface KeyboardEvent<T = Element> extends UIEvent<T, NativeKeyboardEvent> {
|
2026
|
+
altKey: boolean;
|
2027
|
+
/** @deprecated */
|
2028
|
+
charCode: number;
|
2029
|
+
ctrlKey: boolean;
|
2030
|
+
code: string;
|
2031
|
+
/**
|
2032
|
+
* See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method.
|
2033
|
+
*/
|
2034
|
+
getModifierState(key: ModifierKey): boolean;
|
2035
|
+
/**
|
2036
|
+
* See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values
|
2037
|
+
*/
|
2038
|
+
key: string;
|
2039
|
+
/** @deprecated */
|
2040
|
+
keyCode: number;
|
2041
|
+
locale: string;
|
2042
|
+
location: number;
|
2043
|
+
metaKey: boolean;
|
2044
|
+
repeat: boolean;
|
2045
|
+
shiftKey: boolean;
|
2046
|
+
/** @deprecated */
|
2047
|
+
which: number;
|
2048
|
+
}
|
2049
|
+
|
2050
|
+
interface MouseEvent<T = Element, E = NativeMouseEvent> extends UIEvent<T, E> {
|
2051
|
+
altKey: boolean;
|
2052
|
+
button: number;
|
2053
|
+
buttons: number;
|
2054
|
+
clientX: number;
|
2055
|
+
clientY: number;
|
2056
|
+
ctrlKey: boolean;
|
2057
|
+
/**
|
2058
|
+
* See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method.
|
2059
|
+
*/
|
2060
|
+
getModifierState(key: ModifierKey): boolean;
|
2061
|
+
metaKey: boolean;
|
2062
|
+
movementX: number;
|
2063
|
+
movementY: number;
|
2064
|
+
pageX: number;
|
2065
|
+
pageY: number;
|
2066
|
+
relatedTarget: EventTarget | null;
|
2067
|
+
screenX: number;
|
2068
|
+
screenY: number;
|
2069
|
+
shiftKey: boolean;
|
2070
|
+
}
|
2071
|
+
|
2072
|
+
interface TouchEvent<T = Element> extends UIEvent<T, NativeTouchEvent> {
|
2073
|
+
altKey: boolean;
|
2074
|
+
changedTouches: TouchList;
|
2075
|
+
ctrlKey: boolean;
|
2076
|
+
/**
|
2077
|
+
* See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method.
|
2078
|
+
*/
|
2079
|
+
getModifierState(key: ModifierKey): boolean;
|
2080
|
+
metaKey: boolean;
|
2081
|
+
shiftKey: boolean;
|
2082
|
+
targetTouches: TouchList;
|
2083
|
+
touches: TouchList;
|
2084
|
+
}
|
2085
|
+
|
2086
|
+
interface UIEvent<T = Element, E = NativeUIEvent> extends SyntheticEvent<T, E> {
|
2087
|
+
detail: number;
|
2088
|
+
view: AbstractView;
|
2089
|
+
}
|
2090
|
+
|
2091
|
+
interface WheelEvent<T = Element> extends MouseEvent<T, NativeWheelEvent> {
|
2092
|
+
deltaMode: number;
|
2093
|
+
deltaX: number;
|
2094
|
+
deltaY: number;
|
2095
|
+
deltaZ: number;
|
2096
|
+
}
|
2097
|
+
|
2098
|
+
interface AnimationEvent<T = Element> extends SyntheticEvent<T, NativeAnimationEvent> {
|
2099
|
+
animationName: string;
|
2100
|
+
elapsedTime: number;
|
2101
|
+
pseudoElement: string;
|
2102
|
+
}
|
2103
|
+
|
2104
|
+
interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
|
2105
|
+
oldState: "closed" | "open";
|
2106
|
+
newState: "closed" | "open";
|
2107
|
+
}
|
2108
|
+
|
2109
|
+
interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
|
2110
|
+
elapsedTime: number;
|
2111
|
+
propertyName: string;
|
2112
|
+
pseudoElement: string;
|
2113
|
+
}
|
2114
|
+
|
2115
|
+
//
|
2116
|
+
// Event Handler Types
|
2117
|
+
// ----------------------------------------------------------------------
|
2118
|
+
|
2119
|
+
type EventHandler<E extends SyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"];
|
2120
|
+
|
2121
|
+
type ReactEventHandler<T = Element> = EventHandler<SyntheticEvent<T>>;
|
2122
|
+
|
2123
|
+
type ClipboardEventHandler<T = Element> = EventHandler<ClipboardEvent<T>>;
|
2124
|
+
type CompositionEventHandler<T = Element> = EventHandler<CompositionEvent<T>>;
|
2125
|
+
type DragEventHandler<T = Element> = EventHandler<DragEvent<T>>;
|
2126
|
+
type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
|
2127
|
+
type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
|
2128
|
+
type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
|
2129
|
+
type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
|
2130
|
+
type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
|
2131
|
+
type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
|
2132
|
+
type PointerEventHandler<T = Element> = EventHandler<PointerEvent<T>>;
|
2133
|
+
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
|
2134
|
+
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
|
2135
|
+
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
|
2136
|
+
type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
|
2137
|
+
type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
|
2138
|
+
|
2139
|
+
//
|
2140
|
+
// Props / DOM Attributes
|
2141
|
+
// ----------------------------------------------------------------------
|
2142
|
+
|
2143
|
+
interface HTMLProps<T> extends AllHTMLAttributes<T>, ClassAttributes<T> {
|
2144
|
+
}
|
2145
|
+
|
2146
|
+
type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = ClassAttributes<T> & E;
|
2147
|
+
|
2148
|
+
interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
|
2149
|
+
}
|
2150
|
+
|
2151
|
+
interface SVGLineElementAttributes<T> extends SVGProps<T> {}
|
2152
|
+
interface SVGTextElementAttributes<T> extends SVGProps<T> {}
|
2153
|
+
|
2154
|
+
interface DOMAttributes<T> {
|
2155
|
+
children?: ReactNode | undefined;
|
2156
|
+
dangerouslySetInnerHTML?: {
|
2157
|
+
// Should be InnerHTML['innerHTML'].
|
2158
|
+
// But unfortunately we're mixing renderer-specific type declarations.
|
2159
|
+
__html: string | TrustedHTML;
|
2160
|
+
} | undefined;
|
2161
|
+
|
2162
|
+
// Clipboard Events
|
2163
|
+
onCopy?: ClipboardEventHandler<T> | undefined;
|
2164
|
+
onCopyCapture?: ClipboardEventHandler<T> | undefined;
|
2165
|
+
onCut?: ClipboardEventHandler<T> | undefined;
|
2166
|
+
onCutCapture?: ClipboardEventHandler<T> | undefined;
|
2167
|
+
onPaste?: ClipboardEventHandler<T> | undefined;
|
2168
|
+
onPasteCapture?: ClipboardEventHandler<T> | undefined;
|
2169
|
+
|
2170
|
+
// Composition Events
|
2171
|
+
onCompositionEnd?: CompositionEventHandler<T> | undefined;
|
2172
|
+
onCompositionEndCapture?: CompositionEventHandler<T> | undefined;
|
2173
|
+
onCompositionStart?: CompositionEventHandler<T> | undefined;
|
2174
|
+
onCompositionStartCapture?: CompositionEventHandler<T> | undefined;
|
2175
|
+
onCompositionUpdate?: CompositionEventHandler<T> | undefined;
|
2176
|
+
onCompositionUpdateCapture?: CompositionEventHandler<T> | undefined;
|
2177
|
+
|
2178
|
+
// Focus Events
|
2179
|
+
onFocus?: FocusEventHandler<T> | undefined;
|
2180
|
+
onFocusCapture?: FocusEventHandler<T> | undefined;
|
2181
|
+
onBlur?: FocusEventHandler<T> | undefined;
|
2182
|
+
onBlurCapture?: FocusEventHandler<T> | undefined;
|
2183
|
+
|
2184
|
+
// Form Events
|
2185
|
+
onChange?: FormEventHandler<T> | undefined;
|
2186
|
+
onChangeCapture?: FormEventHandler<T> | undefined;
|
2187
|
+
onBeforeInput?: FormEventHandler<T> | undefined;
|
2188
|
+
onBeforeInputCapture?: FormEventHandler<T> | undefined;
|
2189
|
+
onInput?: FormEventHandler<T> | undefined;
|
2190
|
+
onInputCapture?: FormEventHandler<T> | undefined;
|
2191
|
+
onReset?: FormEventHandler<T> | undefined;
|
2192
|
+
onResetCapture?: FormEventHandler<T> | undefined;
|
2193
|
+
onSubmit?: FormEventHandler<T> | undefined;
|
2194
|
+
onSubmitCapture?: FormEventHandler<T> | undefined;
|
2195
|
+
onInvalid?: FormEventHandler<T> | undefined;
|
2196
|
+
onInvalidCapture?: FormEventHandler<T> | undefined;
|
2197
|
+
|
2198
|
+
// Image Events
|
2199
|
+
onLoad?: ReactEventHandler<T> | undefined;
|
2200
|
+
onLoadCapture?: ReactEventHandler<T> | undefined;
|
2201
|
+
onError?: ReactEventHandler<T> | undefined; // also a Media Event
|
2202
|
+
onErrorCapture?: ReactEventHandler<T> | undefined; // also a Media Event
|
2203
|
+
|
2204
|
+
// Keyboard Events
|
2205
|
+
onKeyDown?: KeyboardEventHandler<T> | undefined;
|
2206
|
+
onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
|
2207
|
+
/** @deprecated Use `onKeyUp` or `onKeyDown` instead */
|
2208
|
+
onKeyPress?: KeyboardEventHandler<T> | undefined;
|
2209
|
+
/** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
|
2210
|
+
onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
|
2211
|
+
onKeyUp?: KeyboardEventHandler<T> | undefined;
|
2212
|
+
onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
|
2213
|
+
|
2214
|
+
// Media Events
|
2215
|
+
onAbort?: ReactEventHandler<T> | undefined;
|
2216
|
+
onAbortCapture?: ReactEventHandler<T> | undefined;
|
2217
|
+
onCanPlay?: ReactEventHandler<T> | undefined;
|
2218
|
+
onCanPlayCapture?: ReactEventHandler<T> | undefined;
|
2219
|
+
onCanPlayThrough?: ReactEventHandler<T> | undefined;
|
2220
|
+
onCanPlayThroughCapture?: ReactEventHandler<T> | undefined;
|
2221
|
+
onDurationChange?: ReactEventHandler<T> | undefined;
|
2222
|
+
onDurationChangeCapture?: ReactEventHandler<T> | undefined;
|
2223
|
+
onEmptied?: ReactEventHandler<T> | undefined;
|
2224
|
+
onEmptiedCapture?: ReactEventHandler<T> | undefined;
|
2225
|
+
onEncrypted?: ReactEventHandler<T> | undefined;
|
2226
|
+
onEncryptedCapture?: ReactEventHandler<T> | undefined;
|
2227
|
+
onEnded?: ReactEventHandler<T> | undefined;
|
2228
|
+
onEndedCapture?: ReactEventHandler<T> | undefined;
|
2229
|
+
onLoadedData?: ReactEventHandler<T> | undefined;
|
2230
|
+
onLoadedDataCapture?: ReactEventHandler<T> | undefined;
|
2231
|
+
onLoadedMetadata?: ReactEventHandler<T> | undefined;
|
2232
|
+
onLoadedMetadataCapture?: ReactEventHandler<T> | undefined;
|
2233
|
+
onLoadStart?: ReactEventHandler<T> | undefined;
|
2234
|
+
onLoadStartCapture?: ReactEventHandler<T> | undefined;
|
2235
|
+
onPause?: ReactEventHandler<T> | undefined;
|
2236
|
+
onPauseCapture?: ReactEventHandler<T> | undefined;
|
2237
|
+
onPlay?: ReactEventHandler<T> | undefined;
|
2238
|
+
onPlayCapture?: ReactEventHandler<T> | undefined;
|
2239
|
+
onPlaying?: ReactEventHandler<T> | undefined;
|
2240
|
+
onPlayingCapture?: ReactEventHandler<T> | undefined;
|
2241
|
+
onProgress?: ReactEventHandler<T> | undefined;
|
2242
|
+
onProgressCapture?: ReactEventHandler<T> | undefined;
|
2243
|
+
onRateChange?: ReactEventHandler<T> | undefined;
|
2244
|
+
onRateChangeCapture?: ReactEventHandler<T> | undefined;
|
2245
|
+
onResize?: ReactEventHandler<T> | undefined;
|
2246
|
+
onResizeCapture?: ReactEventHandler<T> | undefined;
|
2247
|
+
onSeeked?: ReactEventHandler<T> | undefined;
|
2248
|
+
onSeekedCapture?: ReactEventHandler<T> | undefined;
|
2249
|
+
onSeeking?: ReactEventHandler<T> | undefined;
|
2250
|
+
onSeekingCapture?: ReactEventHandler<T> | undefined;
|
2251
|
+
onStalled?: ReactEventHandler<T> | undefined;
|
2252
|
+
onStalledCapture?: ReactEventHandler<T> | undefined;
|
2253
|
+
onSuspend?: ReactEventHandler<T> | undefined;
|
2254
|
+
onSuspendCapture?: ReactEventHandler<T> | undefined;
|
2255
|
+
onTimeUpdate?: ReactEventHandler<T> | undefined;
|
2256
|
+
onTimeUpdateCapture?: ReactEventHandler<T> | undefined;
|
2257
|
+
onVolumeChange?: ReactEventHandler<T> | undefined;
|
2258
|
+
onVolumeChangeCapture?: ReactEventHandler<T> | undefined;
|
2259
|
+
onWaiting?: ReactEventHandler<T> | undefined;
|
2260
|
+
onWaitingCapture?: ReactEventHandler<T> | undefined;
|
2261
|
+
|
2262
|
+
// MouseEvents
|
2263
|
+
onAuxClick?: MouseEventHandler<T> | undefined;
|
2264
|
+
onAuxClickCapture?: MouseEventHandler<T> | undefined;
|
2265
|
+
onClick?: MouseEventHandler<T> | undefined;
|
2266
|
+
onClickCapture?: MouseEventHandler<T> | undefined;
|
2267
|
+
onContextMenu?: MouseEventHandler<T> | undefined;
|
2268
|
+
onContextMenuCapture?: MouseEventHandler<T> | undefined;
|
2269
|
+
onDoubleClick?: MouseEventHandler<T> | undefined;
|
2270
|
+
onDoubleClickCapture?: MouseEventHandler<T> | undefined;
|
2271
|
+
onDrag?: DragEventHandler<T> | undefined;
|
2272
|
+
onDragCapture?: DragEventHandler<T> | undefined;
|
2273
|
+
onDragEnd?: DragEventHandler<T> | undefined;
|
2274
|
+
onDragEndCapture?: DragEventHandler<T> | undefined;
|
2275
|
+
onDragEnter?: DragEventHandler<T> | undefined;
|
2276
|
+
onDragEnterCapture?: DragEventHandler<T> | undefined;
|
2277
|
+
onDragExit?: DragEventHandler<T> | undefined;
|
2278
|
+
onDragExitCapture?: DragEventHandler<T> | undefined;
|
2279
|
+
onDragLeave?: DragEventHandler<T> | undefined;
|
2280
|
+
onDragLeaveCapture?: DragEventHandler<T> | undefined;
|
2281
|
+
onDragOver?: DragEventHandler<T> | undefined;
|
2282
|
+
onDragOverCapture?: DragEventHandler<T> | undefined;
|
2283
|
+
onDragStart?: DragEventHandler<T> | undefined;
|
2284
|
+
onDragStartCapture?: DragEventHandler<T> | undefined;
|
2285
|
+
onDrop?: DragEventHandler<T> | undefined;
|
2286
|
+
onDropCapture?: DragEventHandler<T> | undefined;
|
2287
|
+
onMouseDown?: MouseEventHandler<T> | undefined;
|
2288
|
+
onMouseDownCapture?: MouseEventHandler<T> | undefined;
|
2289
|
+
onMouseEnter?: MouseEventHandler<T> | undefined;
|
2290
|
+
onMouseLeave?: MouseEventHandler<T> | undefined;
|
2291
|
+
onMouseMove?: MouseEventHandler<T> | undefined;
|
2292
|
+
onMouseMoveCapture?: MouseEventHandler<T> | undefined;
|
2293
|
+
onMouseOut?: MouseEventHandler<T> | undefined;
|
2294
|
+
onMouseOutCapture?: MouseEventHandler<T> | undefined;
|
2295
|
+
onMouseOver?: MouseEventHandler<T> | undefined;
|
2296
|
+
onMouseOverCapture?: MouseEventHandler<T> | undefined;
|
2297
|
+
onMouseUp?: MouseEventHandler<T> | undefined;
|
2298
|
+
onMouseUpCapture?: MouseEventHandler<T> | undefined;
|
2299
|
+
|
2300
|
+
// Selection Events
|
2301
|
+
onSelect?: ReactEventHandler<T> | undefined;
|
2302
|
+
onSelectCapture?: ReactEventHandler<T> | undefined;
|
2303
|
+
|
2304
|
+
// Touch Events
|
2305
|
+
onTouchCancel?: TouchEventHandler<T> | undefined;
|
2306
|
+
onTouchCancelCapture?: TouchEventHandler<T> | undefined;
|
2307
|
+
onTouchEnd?: TouchEventHandler<T> | undefined;
|
2308
|
+
onTouchEndCapture?: TouchEventHandler<T> | undefined;
|
2309
|
+
onTouchMove?: TouchEventHandler<T> | undefined;
|
2310
|
+
onTouchMoveCapture?: TouchEventHandler<T> | undefined;
|
2311
|
+
onTouchStart?: TouchEventHandler<T> | undefined;
|
2312
|
+
onTouchStartCapture?: TouchEventHandler<T> | undefined;
|
2313
|
+
|
2314
|
+
// Pointer Events
|
2315
|
+
onPointerDown?: PointerEventHandler<T> | undefined;
|
2316
|
+
onPointerDownCapture?: PointerEventHandler<T> | undefined;
|
2317
|
+
onPointerMove?: PointerEventHandler<T> | undefined;
|
2318
|
+
onPointerMoveCapture?: PointerEventHandler<T> | undefined;
|
2319
|
+
onPointerUp?: PointerEventHandler<T> | undefined;
|
2320
|
+
onPointerUpCapture?: PointerEventHandler<T> | undefined;
|
2321
|
+
onPointerCancel?: PointerEventHandler<T> | undefined;
|
2322
|
+
onPointerCancelCapture?: PointerEventHandler<T> | undefined;
|
2323
|
+
onPointerEnter?: PointerEventHandler<T> | undefined;
|
2324
|
+
onPointerLeave?: PointerEventHandler<T> | undefined;
|
2325
|
+
onPointerOver?: PointerEventHandler<T> | undefined;
|
2326
|
+
onPointerOverCapture?: PointerEventHandler<T> | undefined;
|
2327
|
+
onPointerOut?: PointerEventHandler<T> | undefined;
|
2328
|
+
onPointerOutCapture?: PointerEventHandler<T> | undefined;
|
2329
|
+
onGotPointerCapture?: PointerEventHandler<T> | undefined;
|
2330
|
+
onGotPointerCaptureCapture?: PointerEventHandler<T> | undefined;
|
2331
|
+
onLostPointerCapture?: PointerEventHandler<T> | undefined;
|
2332
|
+
onLostPointerCaptureCapture?: PointerEventHandler<T> | undefined;
|
2333
|
+
|
2334
|
+
// UI Events
|
2335
|
+
onScroll?: UIEventHandler<T> | undefined;
|
2336
|
+
onScrollCapture?: UIEventHandler<T> | undefined;
|
2337
|
+
|
2338
|
+
// Wheel Events
|
2339
|
+
onWheel?: WheelEventHandler<T> | undefined;
|
2340
|
+
onWheelCapture?: WheelEventHandler<T> | undefined;
|
2341
|
+
|
2342
|
+
// Animation Events
|
2343
|
+
onAnimationStart?: AnimationEventHandler<T> | undefined;
|
2344
|
+
onAnimationStartCapture?: AnimationEventHandler<T> | undefined;
|
2345
|
+
onAnimationEnd?: AnimationEventHandler<T> | undefined;
|
2346
|
+
onAnimationEndCapture?: AnimationEventHandler<T> | undefined;
|
2347
|
+
onAnimationIteration?: AnimationEventHandler<T> | undefined;
|
2348
|
+
onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
|
2349
|
+
|
2350
|
+
// Toggle Events
|
2351
|
+
onToggle?: ToggleEventHandler<T> | undefined;
|
2352
|
+
onBeforeToggle?: ToggleEventHandler<T> | undefined;
|
2353
|
+
|
2354
|
+
// Transition Events
|
2355
|
+
onTransitionCancel?: TransitionEventHandler<T> | undefined;
|
2356
|
+
onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
|
2357
|
+
onTransitionEnd?: TransitionEventHandler<T> | undefined;
|
2358
|
+
onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
|
2359
|
+
onTransitionRun?: TransitionEventHandler<T> | undefined;
|
2360
|
+
onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
|
2361
|
+
onTransitionStart?: TransitionEventHandler<T> | undefined;
|
2362
|
+
onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
|
2363
|
+
}
|
2364
|
+
|
2365
|
+
export interface CSSProperties extends CSS.Properties<string | number> {
|
2366
|
+
/**
|
2367
|
+
* The index signature was removed to enable closed typing for style
|
2368
|
+
* using CSSType. You're able to use type assertion or module augmentation
|
2369
|
+
* to add properties or an index signature of your own.
|
2370
|
+
*
|
2371
|
+
* For examples and more information, visit:
|
2372
|
+
* https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
|
2373
|
+
*/
|
2374
|
+
}
|
2375
|
+
|
2376
|
+
// All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
|
2377
|
+
interface AriaAttributes {
|
2378
|
+
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
|
2379
|
+
"aria-activedescendant"?: string | undefined;
|
2380
|
+
/** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */
|
2381
|
+
"aria-atomic"?: Booleanish | undefined;
|
2382
|
+
/**
|
2383
|
+
* Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
|
2384
|
+
* presented if they are made.
|
2385
|
+
*/
|
2386
|
+
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
|
2387
|
+
/** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */
|
2388
|
+
/**
|
2389
|
+
* Defines a string value that labels the current element, which is intended to be converted into Braille.
|
2390
|
+
* @see aria-label.
|
2391
|
+
*/
|
2392
|
+
"aria-braillelabel"?: string | undefined;
|
2393
|
+
/**
|
2394
|
+
* Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
|
2395
|
+
* @see aria-roledescription.
|
2396
|
+
*/
|
2397
|
+
"aria-brailleroledescription"?: string | undefined;
|
2398
|
+
"aria-busy"?: Booleanish | undefined;
|
2399
|
+
/**
|
2400
|
+
* Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
|
2401
|
+
* @see aria-pressed @see aria-selected.
|
2402
|
+
*/
|
2403
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
2404
|
+
/**
|
2405
|
+
* Defines the total number of columns in a table, grid, or treegrid.
|
2406
|
+
* @see aria-colindex.
|
2407
|
+
*/
|
2408
|
+
"aria-colcount"?: number | undefined;
|
2409
|
+
/**
|
2410
|
+
* Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
|
2411
|
+
* @see aria-colcount @see aria-colspan.
|
2412
|
+
*/
|
2413
|
+
"aria-colindex"?: number | undefined;
|
2414
|
+
/**
|
2415
|
+
* Defines a human readable text alternative of aria-colindex.
|
2416
|
+
* @see aria-rowindextext.
|
2417
|
+
*/
|
2418
|
+
"aria-colindextext"?: string | undefined;
|
2419
|
+
/**
|
2420
|
+
* Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
|
2421
|
+
* @see aria-colindex @see aria-rowspan.
|
2422
|
+
*/
|
2423
|
+
"aria-colspan"?: number | undefined;
|
2424
|
+
/**
|
2425
|
+
* Identifies the element (or elements) whose contents or presence are controlled by the current element.
|
2426
|
+
* @see aria-owns.
|
2427
|
+
*/
|
2428
|
+
"aria-controls"?: string | undefined;
|
2429
|
+
/** Indicates the element that represents the current item within a container or set of related elements. */
|
2430
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
2431
|
+
/**
|
2432
|
+
* Identifies the element (or elements) that describes the object.
|
2433
|
+
* @see aria-labelledby
|
2434
|
+
*/
|
2435
|
+
"aria-describedby"?: string | undefined;
|
2436
|
+
/**
|
2437
|
+
* Defines a string value that describes or annotates the current element.
|
2438
|
+
* @see related aria-describedby.
|
2439
|
+
*/
|
2440
|
+
"aria-description"?: string | undefined;
|
2441
|
+
/**
|
2442
|
+
* Identifies the element that provides a detailed, extended description for the object.
|
2443
|
+
* @see aria-describedby.
|
2444
|
+
*/
|
2445
|
+
"aria-details"?: string | undefined;
|
2446
|
+
/**
|
2447
|
+
* Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
|
2448
|
+
* @see aria-hidden @see aria-readonly.
|
2449
|
+
*/
|
2450
|
+
"aria-disabled"?: Booleanish | undefined;
|
2451
|
+
/**
|
2452
|
+
* Indicates what functions can be performed when a dragged object is released on the drop target.
|
2453
|
+
* @deprecated in ARIA 1.1
|
2454
|
+
*/
|
2455
|
+
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
|
2456
|
+
/**
|
2457
|
+
* Identifies the element that provides an error message for the object.
|
2458
|
+
* @see aria-invalid @see aria-describedby.
|
2459
|
+
*/
|
2460
|
+
"aria-errormessage"?: string | undefined;
|
2461
|
+
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
|
2462
|
+
"aria-expanded"?: Booleanish | undefined;
|
2463
|
+
/**
|
2464
|
+
* Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
|
2465
|
+
* allows assistive technology to override the general default of reading in document source order.
|
2466
|
+
*/
|
2467
|
+
"aria-flowto"?: string | undefined;
|
2468
|
+
/**
|
2469
|
+
* Indicates an element's "grabbed" state in a drag-and-drop operation.
|
2470
|
+
* @deprecated in ARIA 1.1
|
2471
|
+
*/
|
2472
|
+
"aria-grabbed"?: Booleanish | undefined;
|
2473
|
+
/** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
|
2474
|
+
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
|
2475
|
+
/**
|
2476
|
+
* Indicates whether the element is exposed to an accessibility API.
|
2477
|
+
* @see aria-disabled.
|
2478
|
+
*/
|
2479
|
+
"aria-hidden"?: Booleanish | undefined;
|
2480
|
+
/**
|
2481
|
+
* Indicates the entered value does not conform to the format expected by the application.
|
2482
|
+
* @see aria-errormessage.
|
2483
|
+
*/
|
2484
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
2485
|
+
/** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
|
2486
|
+
"aria-keyshortcuts"?: string | undefined;
|
2487
|
+
/**
|
2488
|
+
* Defines a string value that labels the current element.
|
2489
|
+
* @see aria-labelledby.
|
2490
|
+
*/
|
2491
|
+
"aria-label"?: string | undefined;
|
2492
|
+
/**
|
2493
|
+
* Identifies the element (or elements) that labels the current element.
|
2494
|
+
* @see aria-describedby.
|
2495
|
+
*/
|
2496
|
+
"aria-labelledby"?: string | undefined;
|
2497
|
+
/** Defines the hierarchical level of an element within a structure. */
|
2498
|
+
"aria-level"?: number | undefined;
|
2499
|
+
/** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */
|
2500
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
2501
|
+
/** Indicates whether an element is modal when displayed. */
|
2502
|
+
"aria-modal"?: Booleanish | undefined;
|
2503
|
+
/** Indicates whether a text box accepts multiple lines of input or only a single line. */
|
2504
|
+
"aria-multiline"?: Booleanish | undefined;
|
2505
|
+
/** Indicates that the user may select more than one item from the current selectable descendants. */
|
2506
|
+
"aria-multiselectable"?: Booleanish | undefined;
|
2507
|
+
/** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
|
2508
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
2509
|
+
/**
|
2510
|
+
* Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
|
2511
|
+
* between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
|
2512
|
+
* @see aria-controls.
|
2513
|
+
*/
|
2514
|
+
"aria-owns"?: string | undefined;
|
2515
|
+
/**
|
2516
|
+
* Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
|
2517
|
+
* A hint could be a sample value or a brief description of the expected format.
|
2518
|
+
*/
|
2519
|
+
"aria-placeholder"?: string | undefined;
|
2520
|
+
/**
|
2521
|
+
* Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
|
2522
|
+
* @see aria-setsize.
|
2523
|
+
*/
|
2524
|
+
"aria-posinset"?: number | undefined;
|
2525
|
+
/**
|
2526
|
+
* Indicates the current "pressed" state of toggle buttons.
|
2527
|
+
* @see aria-checked @see aria-selected.
|
2528
|
+
*/
|
2529
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
2530
|
+
/**
|
2531
|
+
* Indicates that the element is not editable, but is otherwise operable.
|
2532
|
+
* @see aria-disabled.
|
2533
|
+
*/
|
2534
|
+
"aria-readonly"?: Booleanish | undefined;
|
2535
|
+
/**
|
2536
|
+
* Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
|
2537
|
+
* @see aria-atomic.
|
2538
|
+
*/
|
2539
|
+
"aria-relevant"?:
|
2540
|
+
| "additions"
|
2541
|
+
| "additions removals"
|
2542
|
+
| "additions text"
|
2543
|
+
| "all"
|
2544
|
+
| "removals"
|
2545
|
+
| "removals additions"
|
2546
|
+
| "removals text"
|
2547
|
+
| "text"
|
2548
|
+
| "text additions"
|
2549
|
+
| "text removals"
|
2550
|
+
| undefined;
|
2551
|
+
/** Indicates that user input is required on the element before a form may be submitted. */
|
2552
|
+
"aria-required"?: Booleanish | undefined;
|
2553
|
+
/** Defines a human-readable, author-localized description for the role of an element. */
|
2554
|
+
"aria-roledescription"?: string | undefined;
|
2555
|
+
/**
|
2556
|
+
* Defines the total number of rows in a table, grid, or treegrid.
|
2557
|
+
* @see aria-rowindex.
|
2558
|
+
*/
|
2559
|
+
"aria-rowcount"?: number | undefined;
|
2560
|
+
/**
|
2561
|
+
* Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
|
2562
|
+
* @see aria-rowcount @see aria-rowspan.
|
2563
|
+
*/
|
2564
|
+
"aria-rowindex"?: number | undefined;
|
2565
|
+
/**
|
2566
|
+
* Defines a human readable text alternative of aria-rowindex.
|
2567
|
+
* @see aria-colindextext.
|
2568
|
+
*/
|
2569
|
+
"aria-rowindextext"?: string | undefined;
|
2570
|
+
/**
|
2571
|
+
* Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
|
2572
|
+
* @see aria-rowindex @see aria-colspan.
|
2573
|
+
*/
|
2574
|
+
"aria-rowspan"?: number | undefined;
|
2575
|
+
/**
|
2576
|
+
* Indicates the current "selected" state of various widgets.
|
2577
|
+
* @see aria-checked @see aria-pressed.
|
2578
|
+
*/
|
2579
|
+
"aria-selected"?: Booleanish | undefined;
|
2580
|
+
/**
|
2581
|
+
* Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
|
2582
|
+
* @see aria-posinset.
|
2583
|
+
*/
|
2584
|
+
"aria-setsize"?: number | undefined;
|
2585
|
+
/** Indicates if items in a table or grid are sorted in ascending or descending order. */
|
2586
|
+
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
2587
|
+
/** Defines the maximum allowed value for a range widget. */
|
2588
|
+
"aria-valuemax"?: number | undefined;
|
2589
|
+
/** Defines the minimum allowed value for a range widget. */
|
2590
|
+
"aria-valuemin"?: number | undefined;
|
2591
|
+
/**
|
2592
|
+
* Defines the current value for a range widget.
|
2593
|
+
* @see aria-valuetext.
|
2594
|
+
*/
|
2595
|
+
"aria-valuenow"?: number | undefined;
|
2596
|
+
/** Defines the human readable text alternative of aria-valuenow for a range widget. */
|
2597
|
+
"aria-valuetext"?: string | undefined;
|
2598
|
+
}
|
2599
|
+
|
2600
|
+
// All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
|
2601
|
+
type AriaRole =
|
2602
|
+
| "alert"
|
2603
|
+
| "alertdialog"
|
2604
|
+
| "application"
|
2605
|
+
| "article"
|
2606
|
+
| "banner"
|
2607
|
+
| "button"
|
2608
|
+
| "cell"
|
2609
|
+
| "checkbox"
|
2610
|
+
| "columnheader"
|
2611
|
+
| "combobox"
|
2612
|
+
| "complementary"
|
2613
|
+
| "contentinfo"
|
2614
|
+
| "definition"
|
2615
|
+
| "dialog"
|
2616
|
+
| "directory"
|
2617
|
+
| "document"
|
2618
|
+
| "feed"
|
2619
|
+
| "figure"
|
2620
|
+
| "form"
|
2621
|
+
| "grid"
|
2622
|
+
| "gridcell"
|
2623
|
+
| "group"
|
2624
|
+
| "heading"
|
2625
|
+
| "img"
|
2626
|
+
| "link"
|
2627
|
+
| "list"
|
2628
|
+
| "listbox"
|
2629
|
+
| "listitem"
|
2630
|
+
| "log"
|
2631
|
+
| "main"
|
2632
|
+
| "marquee"
|
2633
|
+
| "math"
|
2634
|
+
| "menu"
|
2635
|
+
| "menubar"
|
2636
|
+
| "menuitem"
|
2637
|
+
| "menuitemcheckbox"
|
2638
|
+
| "menuitemradio"
|
2639
|
+
| "navigation"
|
2640
|
+
| "none"
|
2641
|
+
| "note"
|
2642
|
+
| "option"
|
2643
|
+
| "presentation"
|
2644
|
+
| "progressbar"
|
2645
|
+
| "radio"
|
2646
|
+
| "radiogroup"
|
2647
|
+
| "region"
|
2648
|
+
| "row"
|
2649
|
+
| "rowgroup"
|
2650
|
+
| "rowheader"
|
2651
|
+
| "scrollbar"
|
2652
|
+
| "search"
|
2653
|
+
| "searchbox"
|
2654
|
+
| "separator"
|
2655
|
+
| "slider"
|
2656
|
+
| "spinbutton"
|
2657
|
+
| "status"
|
2658
|
+
| "switch"
|
2659
|
+
| "tab"
|
2660
|
+
| "table"
|
2661
|
+
| "tablist"
|
2662
|
+
| "tabpanel"
|
2663
|
+
| "term"
|
2664
|
+
| "textbox"
|
2665
|
+
| "timer"
|
2666
|
+
| "toolbar"
|
2667
|
+
| "tooltip"
|
2668
|
+
| "tree"
|
2669
|
+
| "treegrid"
|
2670
|
+
| "treeitem"
|
2671
|
+
| (string & {});
|
2672
|
+
|
2673
|
+
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
2674
|
+
// React-specific Attributes
|
2675
|
+
defaultChecked?: boolean | undefined;
|
2676
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
2677
|
+
suppressContentEditableWarning?: boolean | undefined;
|
2678
|
+
suppressHydrationWarning?: boolean | undefined;
|
2679
|
+
|
2680
|
+
// Standard HTML Attributes
|
2681
|
+
accessKey?: string | undefined;
|
2682
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
|
2683
|
+
autoFocus?: boolean | undefined;
|
2684
|
+
className?: string | undefined;
|
2685
|
+
contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
|
2686
|
+
contextMenu?: string | undefined;
|
2687
|
+
dir?: string | undefined;
|
2688
|
+
draggable?: Booleanish | undefined;
|
2689
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
2690
|
+
hidden?: boolean | undefined;
|
2691
|
+
id?: string | undefined;
|
2692
|
+
lang?: string | undefined;
|
2693
|
+
nonce?: string | undefined;
|
2694
|
+
slot?: string | undefined;
|
2695
|
+
spellCheck?: Booleanish | undefined;
|
2696
|
+
style?: CSSProperties | undefined;
|
2697
|
+
tabIndex?: number | undefined;
|
2698
|
+
title?: string | undefined;
|
2699
|
+
translate?: "yes" | "no" | undefined;
|
2700
|
+
|
2701
|
+
// Unknown
|
2702
|
+
radioGroup?: string | undefined; // <command>, <menuitem>
|
2703
|
+
|
2704
|
+
// WAI-ARIA
|
2705
|
+
role?: AriaRole | undefined;
|
2706
|
+
|
2707
|
+
// RDFa Attributes
|
2708
|
+
about?: string | undefined;
|
2709
|
+
content?: string | undefined;
|
2710
|
+
datatype?: string | undefined;
|
2711
|
+
inlist?: any;
|
2712
|
+
prefix?: string | undefined;
|
2713
|
+
property?: string | undefined;
|
2714
|
+
rel?: string | undefined;
|
2715
|
+
resource?: string | undefined;
|
2716
|
+
rev?: string | undefined;
|
2717
|
+
typeof?: string | undefined;
|
2718
|
+
vocab?: string | undefined;
|
2719
|
+
|
2720
|
+
// Non-standard Attributes
|
2721
|
+
autoCorrect?: string | undefined;
|
2722
|
+
autoSave?: string | undefined;
|
2723
|
+
color?: string | undefined;
|
2724
|
+
itemProp?: string | undefined;
|
2725
|
+
itemScope?: boolean | undefined;
|
2726
|
+
itemType?: string | undefined;
|
2727
|
+
itemID?: string | undefined;
|
2728
|
+
itemRef?: string | undefined;
|
2729
|
+
results?: number | undefined;
|
2730
|
+
security?: string | undefined;
|
2731
|
+
unselectable?: "on" | "off" | undefined;
|
2732
|
+
|
2733
|
+
// Popover API
|
2734
|
+
popover?: "" | "auto" | "manual" | undefined;
|
2735
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
|
2736
|
+
popoverTarget?: string | undefined;
|
2737
|
+
|
2738
|
+
// Living Standard
|
2739
|
+
/**
|
2740
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
|
2741
|
+
*/
|
2742
|
+
inert?: boolean | undefined;
|
2743
|
+
/**
|
2744
|
+
* Hints at the type of data that might be entered by the user while editing the element or its contents
|
2745
|
+
* @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
|
2746
|
+
*/
|
2747
|
+
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
|
2748
|
+
/**
|
2749
|
+
* Specify that a standard HTML element should behave like a defined custom built-in element
|
2750
|
+
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
|
2751
|
+
*/
|
2752
|
+
is?: string | undefined;
|
2753
|
+
}
|
2754
|
+
|
2755
|
+
/**
|
2756
|
+
* For internal usage only.
|
2757
|
+
* Different release channels declare additional types of ReactNode this particular release channel accepts.
|
2758
|
+
* App or library types should never augment this interface.
|
2759
|
+
*/
|
2760
|
+
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {}
|
2761
|
+
|
2762
|
+
interface AllHTMLAttributes<T> extends HTMLAttributes<T> {
|
2763
|
+
// Standard HTML Attributes
|
2764
|
+
accept?: string | undefined;
|
2765
|
+
acceptCharset?: string | undefined;
|
2766
|
+
action?:
|
2767
|
+
| string
|
2768
|
+
| undefined
|
2769
|
+
| ((formData: FormData) => void | Promise<void>)
|
2770
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
2771
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
2772
|
+
];
|
2773
|
+
allowFullScreen?: boolean | undefined;
|
2774
|
+
allowTransparency?: boolean | undefined;
|
2775
|
+
alt?: string | undefined;
|
2776
|
+
as?: string | undefined;
|
2777
|
+
async?: boolean | undefined;
|
2778
|
+
autoComplete?: string | undefined;
|
2779
|
+
autoPlay?: boolean | undefined;
|
2780
|
+
capture?: boolean | "user" | "environment" | undefined;
|
2781
|
+
cellPadding?: number | string | undefined;
|
2782
|
+
cellSpacing?: number | string | undefined;
|
2783
|
+
charSet?: string | undefined;
|
2784
|
+
challenge?: string | undefined;
|
2785
|
+
checked?: boolean | undefined;
|
2786
|
+
cite?: string | undefined;
|
2787
|
+
classID?: string | undefined;
|
2788
|
+
cols?: number | undefined;
|
2789
|
+
colSpan?: number | undefined;
|
2790
|
+
controls?: boolean | undefined;
|
2791
|
+
coords?: string | undefined;
|
2792
|
+
crossOrigin?: CrossOrigin;
|
2793
|
+
data?: string | undefined;
|
2794
|
+
dateTime?: string | undefined;
|
2795
|
+
default?: boolean | undefined;
|
2796
|
+
defer?: boolean | undefined;
|
2797
|
+
disabled?: boolean | undefined;
|
2798
|
+
download?: any;
|
2799
|
+
encType?: string | undefined;
|
2800
|
+
form?: string | undefined;
|
2801
|
+
formAction?:
|
2802
|
+
| string
|
2803
|
+
| undefined
|
2804
|
+
| ((formData: FormData) => void | Promise<void>)
|
2805
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
2806
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
2807
|
+
];
|
2808
|
+
formEncType?: string | undefined;
|
2809
|
+
formMethod?: string | undefined;
|
2810
|
+
formNoValidate?: boolean | undefined;
|
2811
|
+
formTarget?: string | undefined;
|
2812
|
+
frameBorder?: number | string | undefined;
|
2813
|
+
headers?: string | undefined;
|
2814
|
+
height?: number | string | undefined;
|
2815
|
+
high?: number | undefined;
|
2816
|
+
href?: string | undefined;
|
2817
|
+
hrefLang?: string | undefined;
|
2818
|
+
htmlFor?: string | undefined;
|
2819
|
+
httpEquiv?: string | undefined;
|
2820
|
+
integrity?: string | undefined;
|
2821
|
+
keyParams?: string | undefined;
|
2822
|
+
keyType?: string | undefined;
|
2823
|
+
kind?: string | undefined;
|
2824
|
+
label?: string | undefined;
|
2825
|
+
list?: string | undefined;
|
2826
|
+
loop?: boolean | undefined;
|
2827
|
+
low?: number | undefined;
|
2828
|
+
manifest?: string | undefined;
|
2829
|
+
marginHeight?: number | undefined;
|
2830
|
+
marginWidth?: number | undefined;
|
2831
|
+
max?: number | string | undefined;
|
2832
|
+
maxLength?: number | undefined;
|
2833
|
+
media?: string | undefined;
|
2834
|
+
mediaGroup?: string | undefined;
|
2835
|
+
method?: string | undefined;
|
2836
|
+
min?: number | string | undefined;
|
2837
|
+
minLength?: number | undefined;
|
2838
|
+
multiple?: boolean | undefined;
|
2839
|
+
muted?: boolean | undefined;
|
2840
|
+
name?: string | undefined;
|
2841
|
+
noValidate?: boolean | undefined;
|
2842
|
+
open?: boolean | undefined;
|
2843
|
+
optimum?: number | undefined;
|
2844
|
+
pattern?: string | undefined;
|
2845
|
+
placeholder?: string | undefined;
|
2846
|
+
playsInline?: boolean | undefined;
|
2847
|
+
poster?: string | undefined;
|
2848
|
+
preload?: string | undefined;
|
2849
|
+
readOnly?: boolean | undefined;
|
2850
|
+
required?: boolean | undefined;
|
2851
|
+
reversed?: boolean | undefined;
|
2852
|
+
rows?: number | undefined;
|
2853
|
+
rowSpan?: number | undefined;
|
2854
|
+
sandbox?: string | undefined;
|
2855
|
+
scope?: string | undefined;
|
2856
|
+
scoped?: boolean | undefined;
|
2857
|
+
scrolling?: string | undefined;
|
2858
|
+
seamless?: boolean | undefined;
|
2859
|
+
selected?: boolean | undefined;
|
2860
|
+
shape?: string | undefined;
|
2861
|
+
size?: number | undefined;
|
2862
|
+
sizes?: string | undefined;
|
2863
|
+
span?: number | undefined;
|
2864
|
+
src?: string | undefined;
|
2865
|
+
srcDoc?: string | undefined;
|
2866
|
+
srcLang?: string | undefined;
|
2867
|
+
srcSet?: string | undefined;
|
2868
|
+
start?: number | undefined;
|
2869
|
+
step?: number | string | undefined;
|
2870
|
+
summary?: string | undefined;
|
2871
|
+
target?: string | undefined;
|
2872
|
+
type?: string | undefined;
|
2873
|
+
useMap?: string | undefined;
|
2874
|
+
value?: string | readonly string[] | number | undefined;
|
2875
|
+
width?: number | string | undefined;
|
2876
|
+
wmode?: string | undefined;
|
2877
|
+
wrap?: string | undefined;
|
2878
|
+
}
|
2879
|
+
|
2880
|
+
type HTMLAttributeReferrerPolicy =
|
2881
|
+
| ""
|
2882
|
+
| "no-referrer"
|
2883
|
+
| "no-referrer-when-downgrade"
|
2884
|
+
| "origin"
|
2885
|
+
| "origin-when-cross-origin"
|
2886
|
+
| "same-origin"
|
2887
|
+
| "strict-origin"
|
2888
|
+
| "strict-origin-when-cross-origin"
|
2889
|
+
| "unsafe-url";
|
2890
|
+
|
2891
|
+
type HTMLAttributeAnchorTarget =
|
2892
|
+
| "_self"
|
2893
|
+
| "_blank"
|
2894
|
+
| "_parent"
|
2895
|
+
| "_top"
|
2896
|
+
| (string & {});
|
2897
|
+
|
2898
|
+
interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
|
2899
|
+
download?: any;
|
2900
|
+
href?: string | undefined;
|
2901
|
+
hrefLang?: string | undefined;
|
2902
|
+
media?: string | undefined;
|
2903
|
+
ping?: string | undefined;
|
2904
|
+
target?: HTMLAttributeAnchorTarget | undefined;
|
2905
|
+
type?: string | undefined;
|
2906
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
2907
|
+
}
|
2908
|
+
|
2909
|
+
interface AudioHTMLAttributes<T> extends MediaHTMLAttributes<T> {}
|
2910
|
+
|
2911
|
+
interface AreaHTMLAttributes<T> extends HTMLAttributes<T> {
|
2912
|
+
alt?: string | undefined;
|
2913
|
+
coords?: string | undefined;
|
2914
|
+
download?: any;
|
2915
|
+
href?: string | undefined;
|
2916
|
+
hrefLang?: string | undefined;
|
2917
|
+
media?: string | undefined;
|
2918
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
2919
|
+
shape?: string | undefined;
|
2920
|
+
target?: string | undefined;
|
2921
|
+
}
|
2922
|
+
|
2923
|
+
interface BaseHTMLAttributes<T> extends HTMLAttributes<T> {
|
2924
|
+
href?: string | undefined;
|
2925
|
+
target?: string | undefined;
|
2926
|
+
}
|
2927
|
+
|
2928
|
+
interface BlockquoteHTMLAttributes<T> extends HTMLAttributes<T> {
|
2929
|
+
cite?: string | undefined;
|
2930
|
+
}
|
2931
|
+
|
2932
|
+
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
|
2933
|
+
disabled?: boolean | undefined;
|
2934
|
+
form?: string | undefined;
|
2935
|
+
formAction?:
|
2936
|
+
| string
|
2937
|
+
| ((formData: FormData) => void | Promise<void>)
|
2938
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
2939
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
2940
|
+
]
|
2941
|
+
| undefined;
|
2942
|
+
formEncType?: string | undefined;
|
2943
|
+
formMethod?: string | undefined;
|
2944
|
+
formNoValidate?: boolean | undefined;
|
2945
|
+
formTarget?: string | undefined;
|
2946
|
+
name?: string | undefined;
|
2947
|
+
type?: "submit" | "reset" | "button" | undefined;
|
2948
|
+
value?: string | readonly string[] | number | undefined;
|
2949
|
+
}
|
2950
|
+
|
2951
|
+
interface CanvasHTMLAttributes<T> extends HTMLAttributes<T> {
|
2952
|
+
height?: number | string | undefined;
|
2953
|
+
width?: number | string | undefined;
|
2954
|
+
}
|
2955
|
+
|
2956
|
+
interface ColHTMLAttributes<T> extends HTMLAttributes<T> {
|
2957
|
+
span?: number | undefined;
|
2958
|
+
width?: number | string | undefined;
|
2959
|
+
}
|
2960
|
+
|
2961
|
+
interface ColgroupHTMLAttributes<T> extends HTMLAttributes<T> {
|
2962
|
+
span?: number | undefined;
|
2963
|
+
}
|
2964
|
+
|
2965
|
+
interface DataHTMLAttributes<T> extends HTMLAttributes<T> {
|
2966
|
+
value?: string | readonly string[] | number | undefined;
|
2967
|
+
}
|
2968
|
+
|
2969
|
+
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
2970
|
+
open?: boolean | undefined;
|
2971
|
+
name?: string | undefined;
|
2972
|
+
}
|
2973
|
+
|
2974
|
+
interface DelHTMLAttributes<T> extends HTMLAttributes<T> {
|
2975
|
+
cite?: string | undefined;
|
2976
|
+
dateTime?: string | undefined;
|
2977
|
+
}
|
2978
|
+
|
2979
|
+
interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
|
2980
|
+
onCancel?: ReactEventHandler<T> | undefined;
|
2981
|
+
onClose?: ReactEventHandler<T> | undefined;
|
2982
|
+
open?: boolean | undefined;
|
2983
|
+
}
|
2984
|
+
|
2985
|
+
interface EmbedHTMLAttributes<T> extends HTMLAttributes<T> {
|
2986
|
+
height?: number | string | undefined;
|
2987
|
+
src?: string | undefined;
|
2988
|
+
type?: string | undefined;
|
2989
|
+
width?: number | string | undefined;
|
2990
|
+
}
|
2991
|
+
|
2992
|
+
interface FieldsetHTMLAttributes<T> extends HTMLAttributes<T> {
|
2993
|
+
disabled?: boolean | undefined;
|
2994
|
+
form?: string | undefined;
|
2995
|
+
name?: string | undefined;
|
2996
|
+
}
|
2997
|
+
|
2998
|
+
interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
|
2999
|
+
acceptCharset?: string | undefined;
|
3000
|
+
action?:
|
3001
|
+
| string
|
3002
|
+
| undefined
|
3003
|
+
| ((formData: FormData) => void | Promise<void>)
|
3004
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3005
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3006
|
+
];
|
3007
|
+
autoComplete?: string | undefined;
|
3008
|
+
encType?: string | undefined;
|
3009
|
+
method?: string | undefined;
|
3010
|
+
name?: string | undefined;
|
3011
|
+
noValidate?: boolean | undefined;
|
3012
|
+
target?: string | undefined;
|
3013
|
+
}
|
3014
|
+
|
3015
|
+
interface HtmlHTMLAttributes<T> extends HTMLAttributes<T> {
|
3016
|
+
manifest?: string | undefined;
|
3017
|
+
}
|
3018
|
+
|
3019
|
+
interface IframeHTMLAttributes<T> extends HTMLAttributes<T> {
|
3020
|
+
allow?: string | undefined;
|
3021
|
+
allowFullScreen?: boolean | undefined;
|
3022
|
+
allowTransparency?: boolean | undefined;
|
3023
|
+
/** @deprecated */
|
3024
|
+
frameBorder?: number | string | undefined;
|
3025
|
+
height?: number | string | undefined;
|
3026
|
+
loading?: "eager" | "lazy" | undefined;
|
3027
|
+
/** @deprecated */
|
3028
|
+
marginHeight?: number | undefined;
|
3029
|
+
/** @deprecated */
|
3030
|
+
marginWidth?: number | undefined;
|
3031
|
+
name?: string | undefined;
|
3032
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
3033
|
+
sandbox?: string | undefined;
|
3034
|
+
/** @deprecated */
|
3035
|
+
scrolling?: string | undefined;
|
3036
|
+
seamless?: boolean | undefined;
|
3037
|
+
src?: string | undefined;
|
3038
|
+
srcDoc?: string | undefined;
|
3039
|
+
width?: number | string | undefined;
|
3040
|
+
}
|
3041
|
+
|
3042
|
+
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
3043
|
+
alt?: string | undefined;
|
3044
|
+
crossOrigin?: CrossOrigin;
|
3045
|
+
decoding?: "async" | "auto" | "sync" | undefined;
|
3046
|
+
fetchPriority?: "high" | "low" | "auto";
|
3047
|
+
height?: number | string | undefined;
|
3048
|
+
loading?: "eager" | "lazy" | undefined;
|
3049
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
3050
|
+
sizes?: string | undefined;
|
3051
|
+
src?: string | undefined;
|
3052
|
+
srcSet?: string | undefined;
|
3053
|
+
useMap?: string | undefined;
|
3054
|
+
width?: number | string | undefined;
|
3055
|
+
}
|
3056
|
+
|
3057
|
+
interface InsHTMLAttributes<T> extends HTMLAttributes<T> {
|
3058
|
+
cite?: string | undefined;
|
3059
|
+
dateTime?: string | undefined;
|
3060
|
+
}
|
3061
|
+
|
3062
|
+
type HTMLInputTypeAttribute =
|
3063
|
+
| "button"
|
3064
|
+
| "checkbox"
|
3065
|
+
| "color"
|
3066
|
+
| "date"
|
3067
|
+
| "datetime-local"
|
3068
|
+
| "email"
|
3069
|
+
| "file"
|
3070
|
+
| "hidden"
|
3071
|
+
| "image"
|
3072
|
+
| "month"
|
3073
|
+
| "number"
|
3074
|
+
| "password"
|
3075
|
+
| "radio"
|
3076
|
+
| "range"
|
3077
|
+
| "reset"
|
3078
|
+
| "search"
|
3079
|
+
| "submit"
|
3080
|
+
| "tel"
|
3081
|
+
| "text"
|
3082
|
+
| "time"
|
3083
|
+
| "url"
|
3084
|
+
| "week"
|
3085
|
+
| (string & {});
|
3086
|
+
|
3087
|
+
type AutoFillAddressKind = "billing" | "shipping";
|
3088
|
+
type AutoFillBase = "" | "off" | "on";
|
3089
|
+
type AutoFillContactField =
|
3090
|
+
| "email"
|
3091
|
+
| "tel"
|
3092
|
+
| "tel-area-code"
|
3093
|
+
| "tel-country-code"
|
3094
|
+
| "tel-extension"
|
3095
|
+
| "tel-local"
|
3096
|
+
| "tel-local-prefix"
|
3097
|
+
| "tel-local-suffix"
|
3098
|
+
| "tel-national";
|
3099
|
+
type AutoFillContactKind = "home" | "mobile" | "work";
|
3100
|
+
type AutoFillCredentialField = "webauthn";
|
3101
|
+
type AutoFillNormalField =
|
3102
|
+
| "additional-name"
|
3103
|
+
| "address-level1"
|
3104
|
+
| "address-level2"
|
3105
|
+
| "address-level3"
|
3106
|
+
| "address-level4"
|
3107
|
+
| "address-line1"
|
3108
|
+
| "address-line2"
|
3109
|
+
| "address-line3"
|
3110
|
+
| "bday-day"
|
3111
|
+
| "bday-month"
|
3112
|
+
| "bday-year"
|
3113
|
+
| "cc-csc"
|
3114
|
+
| "cc-exp"
|
3115
|
+
| "cc-exp-month"
|
3116
|
+
| "cc-exp-year"
|
3117
|
+
| "cc-family-name"
|
3118
|
+
| "cc-given-name"
|
3119
|
+
| "cc-name"
|
3120
|
+
| "cc-number"
|
3121
|
+
| "cc-type"
|
3122
|
+
| "country"
|
3123
|
+
| "country-name"
|
3124
|
+
| "current-password"
|
3125
|
+
| "family-name"
|
3126
|
+
| "given-name"
|
3127
|
+
| "honorific-prefix"
|
3128
|
+
| "honorific-suffix"
|
3129
|
+
| "name"
|
3130
|
+
| "new-password"
|
3131
|
+
| "one-time-code"
|
3132
|
+
| "organization"
|
3133
|
+
| "postal-code"
|
3134
|
+
| "street-address"
|
3135
|
+
| "transaction-amount"
|
3136
|
+
| "transaction-currency"
|
3137
|
+
| "username";
|
3138
|
+
type OptionalPrefixToken<T extends string> = `${T} ` | "";
|
3139
|
+
type OptionalPostfixToken<T extends string> = ` ${T}` | "";
|
3140
|
+
type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`;
|
3141
|
+
type AutoFillSection = `section-${string}`;
|
3142
|
+
type AutoFill =
|
3143
|
+
| AutoFillBase
|
3144
|
+
| `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<
|
3145
|
+
AutoFillAddressKind
|
3146
|
+
>}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`;
|
3147
|
+
type HTMLInputAutoCompleteAttribute = AutoFill | (string & {});
|
3148
|
+
|
3149
|
+
interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
|
3150
|
+
accept?: string | undefined;
|
3151
|
+
alt?: string | undefined;
|
3152
|
+
autoComplete?: HTMLInputAutoCompleteAttribute | undefined;
|
3153
|
+
capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
|
3154
|
+
checked?: boolean | undefined;
|
3155
|
+
disabled?: boolean | undefined;
|
3156
|
+
form?: string | undefined;
|
3157
|
+
formAction?:
|
3158
|
+
| string
|
3159
|
+
| ((formData: FormData) => void | Promise<void>)
|
3160
|
+
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
|
3161
|
+
keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
|
3162
|
+
]
|
3163
|
+
| undefined;
|
3164
|
+
formEncType?: string | undefined;
|
3165
|
+
formMethod?: string | undefined;
|
3166
|
+
formNoValidate?: boolean | undefined;
|
3167
|
+
formTarget?: string | undefined;
|
3168
|
+
height?: number | string | undefined;
|
3169
|
+
list?: string | undefined;
|
3170
|
+
max?: number | string | undefined;
|
3171
|
+
maxLength?: number | undefined;
|
3172
|
+
min?: number | string | undefined;
|
3173
|
+
minLength?: number | undefined;
|
3174
|
+
multiple?: boolean | undefined;
|
3175
|
+
name?: string | undefined;
|
3176
|
+
pattern?: string | undefined;
|
3177
|
+
placeholder?: string | undefined;
|
3178
|
+
readOnly?: boolean | undefined;
|
3179
|
+
required?: boolean | undefined;
|
3180
|
+
size?: number | undefined;
|
3181
|
+
src?: string | undefined;
|
3182
|
+
step?: number | string | undefined;
|
3183
|
+
type?: HTMLInputTypeAttribute | undefined;
|
3184
|
+
value?: string | readonly string[] | number | undefined;
|
3185
|
+
width?: number | string | undefined;
|
3186
|
+
|
3187
|
+
onChange?: ChangeEventHandler<T> | undefined;
|
3188
|
+
}
|
3189
|
+
|
3190
|
+
interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
|
3191
|
+
challenge?: string | undefined;
|
3192
|
+
disabled?: boolean | undefined;
|
3193
|
+
form?: string | undefined;
|
3194
|
+
keyType?: string | undefined;
|
3195
|
+
keyParams?: string | undefined;
|
3196
|
+
name?: string | undefined;
|
3197
|
+
}
|
3198
|
+
|
3199
|
+
interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
|
3200
|
+
form?: string | undefined;
|
3201
|
+
htmlFor?: string | undefined;
|
3202
|
+
}
|
3203
|
+
|
3204
|
+
interface LiHTMLAttributes<T> extends HTMLAttributes<T> {
|
3205
|
+
value?: string | readonly string[] | number | undefined;
|
3206
|
+
}
|
3207
|
+
|
3208
|
+
interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
|
3209
|
+
as?: string | undefined;
|
3210
|
+
crossOrigin?: CrossOrigin;
|
3211
|
+
fetchPriority?: "high" | "low" | "auto";
|
3212
|
+
href?: string | undefined;
|
3213
|
+
hrefLang?: string | undefined;
|
3214
|
+
integrity?: string | undefined;
|
3215
|
+
media?: string | undefined;
|
3216
|
+
imageSrcSet?: string | undefined;
|
3217
|
+
imageSizes?: string | undefined;
|
3218
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
3219
|
+
sizes?: string | undefined;
|
3220
|
+
type?: string | undefined;
|
3221
|
+
charSet?: string | undefined;
|
3222
|
+
|
3223
|
+
// React props
|
3224
|
+
precedence?: string | undefined;
|
3225
|
+
}
|
3226
|
+
|
3227
|
+
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
3228
|
+
name?: string | undefined;
|
3229
|
+
}
|
3230
|
+
|
3231
|
+
interface MenuHTMLAttributes<T> extends HTMLAttributes<T> {
|
3232
|
+
type?: string | undefined;
|
3233
|
+
}
|
3234
|
+
|
3235
|
+
interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
|
3236
|
+
autoPlay?: boolean | undefined;
|
3237
|
+
controls?: boolean | undefined;
|
3238
|
+
controlsList?: string | undefined;
|
3239
|
+
crossOrigin?: CrossOrigin;
|
3240
|
+
loop?: boolean | undefined;
|
3241
|
+
mediaGroup?: string | undefined;
|
3242
|
+
muted?: boolean | undefined;
|
3243
|
+
playsInline?: boolean | undefined;
|
3244
|
+
preload?: string | undefined;
|
3245
|
+
src?: string | undefined;
|
3246
|
+
}
|
3247
|
+
|
3248
|
+
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
3249
|
+
charSet?: string | undefined;
|
3250
|
+
content?: string | undefined;
|
3251
|
+
httpEquiv?: string | undefined;
|
3252
|
+
media?: string | undefined;
|
3253
|
+
name?: string | undefined;
|
3254
|
+
}
|
3255
|
+
|
3256
|
+
interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
|
3257
|
+
form?: string | undefined;
|
3258
|
+
high?: number | undefined;
|
3259
|
+
low?: number | undefined;
|
3260
|
+
max?: number | string | undefined;
|
3261
|
+
min?: number | string | undefined;
|
3262
|
+
optimum?: number | undefined;
|
3263
|
+
value?: string | readonly string[] | number | undefined;
|
3264
|
+
}
|
3265
|
+
|
3266
|
+
interface QuoteHTMLAttributes<T> extends HTMLAttributes<T> {
|
3267
|
+
cite?: string | undefined;
|
3268
|
+
}
|
3269
|
+
|
3270
|
+
interface ObjectHTMLAttributes<T> extends HTMLAttributes<T> {
|
3271
|
+
classID?: string | undefined;
|
3272
|
+
data?: string | undefined;
|
3273
|
+
form?: string | undefined;
|
3274
|
+
height?: number | string | undefined;
|
3275
|
+
name?: string | undefined;
|
3276
|
+
type?: string | undefined;
|
3277
|
+
useMap?: string | undefined;
|
3278
|
+
width?: number | string | undefined;
|
3279
|
+
wmode?: string | undefined;
|
3280
|
+
}
|
3281
|
+
|
3282
|
+
interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
|
3283
|
+
reversed?: boolean | undefined;
|
3284
|
+
start?: number | undefined;
|
3285
|
+
type?: "1" | "a" | "A" | "i" | "I" | undefined;
|
3286
|
+
}
|
3287
|
+
|
3288
|
+
interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
|
3289
|
+
disabled?: boolean | undefined;
|
3290
|
+
label?: string | undefined;
|
3291
|
+
}
|
3292
|
+
|
3293
|
+
interface OptionHTMLAttributes<T> extends HTMLAttributes<T> {
|
3294
|
+
disabled?: boolean | undefined;
|
3295
|
+
label?: string | undefined;
|
3296
|
+
selected?: boolean | undefined;
|
3297
|
+
value?: string | readonly string[] | number | undefined;
|
3298
|
+
}
|
3299
|
+
|
3300
|
+
interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
|
3301
|
+
form?: string | undefined;
|
3302
|
+
htmlFor?: string | undefined;
|
3303
|
+
name?: string | undefined;
|
3304
|
+
}
|
3305
|
+
|
3306
|
+
interface ParamHTMLAttributes<T> extends HTMLAttributes<T> {
|
3307
|
+
name?: string | undefined;
|
3308
|
+
value?: string | readonly string[] | number | undefined;
|
3309
|
+
}
|
3310
|
+
|
3311
|
+
interface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {
|
3312
|
+
max?: number | string | undefined;
|
3313
|
+
value?: string | readonly string[] | number | undefined;
|
3314
|
+
}
|
3315
|
+
|
3316
|
+
interface SlotHTMLAttributes<T> extends HTMLAttributes<T> {
|
3317
|
+
name?: string | undefined;
|
3318
|
+
}
|
3319
|
+
|
3320
|
+
interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
|
3321
|
+
async?: boolean | undefined;
|
3322
|
+
/** @deprecated */
|
3323
|
+
charSet?: string | undefined;
|
3324
|
+
crossOrigin?: CrossOrigin;
|
3325
|
+
defer?: boolean | undefined;
|
3326
|
+
integrity?: string | undefined;
|
3327
|
+
noModule?: boolean | undefined;
|
3328
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
3329
|
+
src?: string | undefined;
|
3330
|
+
type?: string | undefined;
|
3331
|
+
}
|
3332
|
+
|
3333
|
+
interface SelectHTMLAttributes<T> extends HTMLAttributes<T> {
|
3334
|
+
autoComplete?: string | undefined;
|
3335
|
+
disabled?: boolean | undefined;
|
3336
|
+
form?: string | undefined;
|
3337
|
+
multiple?: boolean | undefined;
|
3338
|
+
name?: string | undefined;
|
3339
|
+
required?: boolean | undefined;
|
3340
|
+
size?: number | undefined;
|
3341
|
+
value?: string | readonly string[] | number | undefined;
|
3342
|
+
onChange?: ChangeEventHandler<T> | undefined;
|
3343
|
+
}
|
3344
|
+
|
3345
|
+
interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
|
3346
|
+
height?: number | string | undefined;
|
3347
|
+
media?: string | undefined;
|
3348
|
+
sizes?: string | undefined;
|
3349
|
+
src?: string | undefined;
|
3350
|
+
srcSet?: string | undefined;
|
3351
|
+
type?: string | undefined;
|
3352
|
+
width?: number | string | undefined;
|
3353
|
+
}
|
3354
|
+
|
3355
|
+
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
|
3356
|
+
media?: string | undefined;
|
3357
|
+
scoped?: boolean | undefined;
|
3358
|
+
type?: string | undefined;
|
3359
|
+
|
3360
|
+
// React props
|
3361
|
+
href?: string | undefined;
|
3362
|
+
precedence?: string | undefined;
|
3363
|
+
}
|
3364
|
+
|
3365
|
+
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
3366
|
+
align?: "left" | "center" | "right" | undefined;
|
3367
|
+
bgcolor?: string | undefined;
|
3368
|
+
border?: number | undefined;
|
3369
|
+
cellPadding?: number | string | undefined;
|
3370
|
+
cellSpacing?: number | string | undefined;
|
3371
|
+
frame?: boolean | undefined;
|
3372
|
+
rules?: "none" | "groups" | "rows" | "columns" | "all" | undefined;
|
3373
|
+
summary?: string | undefined;
|
3374
|
+
width?: number | string | undefined;
|
3375
|
+
}
|
3376
|
+
|
3377
|
+
interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
|
3378
|
+
autoComplete?: string | undefined;
|
3379
|
+
cols?: number | undefined;
|
3380
|
+
dirName?: string | undefined;
|
3381
|
+
disabled?: boolean | undefined;
|
3382
|
+
form?: string | undefined;
|
3383
|
+
maxLength?: number | undefined;
|
3384
|
+
minLength?: number | undefined;
|
3385
|
+
name?: string | undefined;
|
3386
|
+
placeholder?: string | undefined;
|
3387
|
+
readOnly?: boolean | undefined;
|
3388
|
+
required?: boolean | undefined;
|
3389
|
+
rows?: number | undefined;
|
3390
|
+
value?: string | readonly string[] | number | undefined;
|
3391
|
+
wrap?: string | undefined;
|
3392
|
+
|
3393
|
+
onChange?: ChangeEventHandler<T> | undefined;
|
3394
|
+
}
|
3395
|
+
|
3396
|
+
interface TdHTMLAttributes<T> extends HTMLAttributes<T> {
|
3397
|
+
align?: "left" | "center" | "right" | "justify" | "char" | undefined;
|
3398
|
+
colSpan?: number | undefined;
|
3399
|
+
headers?: string | undefined;
|
3400
|
+
rowSpan?: number | undefined;
|
3401
|
+
scope?: string | undefined;
|
3402
|
+
abbr?: string | undefined;
|
3403
|
+
height?: number | string | undefined;
|
3404
|
+
width?: number | string | undefined;
|
3405
|
+
valign?: "top" | "middle" | "bottom" | "baseline" | undefined;
|
3406
|
+
}
|
3407
|
+
|
3408
|
+
interface ThHTMLAttributes<T> extends HTMLAttributes<T> {
|
3409
|
+
align?: "left" | "center" | "right" | "justify" | "char" | undefined;
|
3410
|
+
colSpan?: number | undefined;
|
3411
|
+
headers?: string | undefined;
|
3412
|
+
rowSpan?: number | undefined;
|
3413
|
+
scope?: string | undefined;
|
3414
|
+
abbr?: string | undefined;
|
3415
|
+
}
|
3416
|
+
|
3417
|
+
interface TimeHTMLAttributes<T> extends HTMLAttributes<T> {
|
3418
|
+
dateTime?: string | undefined;
|
3419
|
+
}
|
3420
|
+
|
3421
|
+
interface TrackHTMLAttributes<T> extends HTMLAttributes<T> {
|
3422
|
+
default?: boolean | undefined;
|
3423
|
+
kind?: string | undefined;
|
3424
|
+
label?: string | undefined;
|
3425
|
+
src?: string | undefined;
|
3426
|
+
srcLang?: string | undefined;
|
3427
|
+
}
|
3428
|
+
|
3429
|
+
interface VideoHTMLAttributes<T> extends MediaHTMLAttributes<T> {
|
3430
|
+
height?: number | string | undefined;
|
3431
|
+
playsInline?: boolean | undefined;
|
3432
|
+
poster?: string | undefined;
|
3433
|
+
width?: number | string | undefined;
|
3434
|
+
disablePictureInPicture?: boolean | undefined;
|
3435
|
+
disableRemotePlayback?: boolean | undefined;
|
3436
|
+
}
|
3437
|
+
|
3438
|
+
// this list is "complete" in that it contains every SVG attribute
|
3439
|
+
// that React supports, but the types can be improved.
|
3440
|
+
// Full list here: https://facebook.github.io/react/docs/dom-elements.html
|
3441
|
+
//
|
3442
|
+
// The three broad type categories are (in order of restrictiveness):
|
3443
|
+
// - "number | string"
|
3444
|
+
// - "string"
|
3445
|
+
// - union of string literals
|
3446
|
+
interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
3447
|
+
// React-specific Attributes
|
3448
|
+
suppressHydrationWarning?: boolean | undefined;
|
3449
|
+
|
3450
|
+
// Attributes which also defined in HTMLAttributes
|
3451
|
+
// See comment in SVGDOMPropertyConfig.js
|
3452
|
+
className?: string | undefined;
|
3453
|
+
color?: string | undefined;
|
3454
|
+
height?: number | string | undefined;
|
3455
|
+
id?: string | undefined;
|
3456
|
+
lang?: string | undefined;
|
3457
|
+
max?: number | string | undefined;
|
3458
|
+
media?: string | undefined;
|
3459
|
+
method?: string | undefined;
|
3460
|
+
min?: number | string | undefined;
|
3461
|
+
name?: string | undefined;
|
3462
|
+
style?: CSSProperties | undefined;
|
3463
|
+
target?: string | undefined;
|
3464
|
+
type?: string | undefined;
|
3465
|
+
width?: number | string | undefined;
|
3466
|
+
|
3467
|
+
// Other HTML properties supported by SVG elements in browsers
|
3468
|
+
role?: AriaRole | undefined;
|
3469
|
+
tabIndex?: number | undefined;
|
3470
|
+
crossOrigin?: CrossOrigin;
|
3471
|
+
|
3472
|
+
// SVG Specific attributes
|
3473
|
+
accentHeight?: number | string | undefined;
|
3474
|
+
accumulate?: "none" | "sum" | undefined;
|
3475
|
+
additive?: "replace" | "sum" | undefined;
|
3476
|
+
alignmentBaseline?:
|
3477
|
+
| "auto"
|
3478
|
+
| "baseline"
|
3479
|
+
| "before-edge"
|
3480
|
+
| "text-before-edge"
|
3481
|
+
| "middle"
|
3482
|
+
| "central"
|
3483
|
+
| "after-edge"
|
3484
|
+
| "text-after-edge"
|
3485
|
+
| "ideographic"
|
3486
|
+
| "alphabetic"
|
3487
|
+
| "hanging"
|
3488
|
+
| "mathematical"
|
3489
|
+
| "inherit"
|
3490
|
+
| undefined;
|
3491
|
+
allowReorder?: "no" | "yes" | undefined;
|
3492
|
+
alphabetic?: number | string | undefined;
|
3493
|
+
amplitude?: number | string | undefined;
|
3494
|
+
arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
|
3495
|
+
ascent?: number | string | undefined;
|
3496
|
+
attributeName?: string | undefined;
|
3497
|
+
attributeType?: string | undefined;
|
3498
|
+
autoReverse?: Booleanish | undefined;
|
3499
|
+
azimuth?: number | string | undefined;
|
3500
|
+
baseFrequency?: number | string | undefined;
|
3501
|
+
baselineShift?: number | string | undefined;
|
3502
|
+
baseProfile?: number | string | undefined;
|
3503
|
+
bbox?: number | string | undefined;
|
3504
|
+
begin?: number | string | undefined;
|
3505
|
+
bias?: number | string | undefined;
|
3506
|
+
by?: number | string | undefined;
|
3507
|
+
calcMode?: number | string | undefined;
|
3508
|
+
capHeight?: number | string | undefined;
|
3509
|
+
clip?: number | string | undefined;
|
3510
|
+
clipPath?: string | undefined;
|
3511
|
+
clipPathUnits?: number | string | undefined;
|
3512
|
+
clipRule?: number | string | undefined;
|
3513
|
+
colorInterpolation?: number | string | undefined;
|
3514
|
+
colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
|
3515
|
+
colorProfile?: number | string | undefined;
|
3516
|
+
colorRendering?: number | string | undefined;
|
3517
|
+
contentScriptType?: number | string | undefined;
|
3518
|
+
contentStyleType?: number | string | undefined;
|
3519
|
+
cursor?: number | string | undefined;
|
3520
|
+
cx?: number | string | undefined;
|
3521
|
+
cy?: number | string | undefined;
|
3522
|
+
d?: string | undefined;
|
3523
|
+
decelerate?: number | string | undefined;
|
3524
|
+
descent?: number | string | undefined;
|
3525
|
+
diffuseConstant?: number | string | undefined;
|
3526
|
+
direction?: number | string | undefined;
|
3527
|
+
display?: number | string | undefined;
|
3528
|
+
divisor?: number | string | undefined;
|
3529
|
+
dominantBaseline?: number | string | undefined;
|
3530
|
+
dur?: number | string | undefined;
|
3531
|
+
dx?: number | string | undefined;
|
3532
|
+
dy?: number | string | undefined;
|
3533
|
+
edgeMode?: number | string | undefined;
|
3534
|
+
elevation?: number | string | undefined;
|
3535
|
+
enableBackground?: number | string | undefined;
|
3536
|
+
end?: number | string | undefined;
|
3537
|
+
exponent?: number | string | undefined;
|
3538
|
+
externalResourcesRequired?: Booleanish | undefined;
|
3539
|
+
fill?: string | undefined;
|
3540
|
+
fillOpacity?: number | string | undefined;
|
3541
|
+
fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
|
3542
|
+
filter?: string | undefined;
|
3543
|
+
filterRes?: number | string | undefined;
|
3544
|
+
filterUnits?: number | string | undefined;
|
3545
|
+
floodColor?: number | string | undefined;
|
3546
|
+
floodOpacity?: number | string | undefined;
|
3547
|
+
focusable?: Booleanish | "auto" | undefined;
|
3548
|
+
fontFamily?: string | undefined;
|
3549
|
+
fontSize?: number | string | undefined;
|
3550
|
+
fontSizeAdjust?: number | string | undefined;
|
3551
|
+
fontStretch?: number | string | undefined;
|
3552
|
+
fontStyle?: number | string | undefined;
|
3553
|
+
fontVariant?: number | string | undefined;
|
3554
|
+
fontWeight?: number | string | undefined;
|
3555
|
+
format?: number | string | undefined;
|
3556
|
+
fr?: number | string | undefined;
|
3557
|
+
from?: number | string | undefined;
|
3558
|
+
fx?: number | string | undefined;
|
3559
|
+
fy?: number | string | undefined;
|
3560
|
+
g1?: number | string | undefined;
|
3561
|
+
g2?: number | string | undefined;
|
3562
|
+
glyphName?: number | string | undefined;
|
3563
|
+
glyphOrientationHorizontal?: number | string | undefined;
|
3564
|
+
glyphOrientationVertical?: number | string | undefined;
|
3565
|
+
glyphRef?: number | string | undefined;
|
3566
|
+
gradientTransform?: string | undefined;
|
3567
|
+
gradientUnits?: string | undefined;
|
3568
|
+
hanging?: number | string | undefined;
|
3569
|
+
horizAdvX?: number | string | undefined;
|
3570
|
+
horizOriginX?: number | string | undefined;
|
3571
|
+
href?: string | undefined;
|
3572
|
+
ideographic?: number | string | undefined;
|
3573
|
+
imageRendering?: number | string | undefined;
|
3574
|
+
in2?: number | string | undefined;
|
3575
|
+
in?: string | undefined;
|
3576
|
+
intercept?: number | string | undefined;
|
3577
|
+
k1?: number | string | undefined;
|
3578
|
+
k2?: number | string | undefined;
|
3579
|
+
k3?: number | string | undefined;
|
3580
|
+
k4?: number | string | undefined;
|
3581
|
+
k?: number | string | undefined;
|
3582
|
+
kernelMatrix?: number | string | undefined;
|
3583
|
+
kernelUnitLength?: number | string | undefined;
|
3584
|
+
kerning?: number | string | undefined;
|
3585
|
+
keyPoints?: number | string | undefined;
|
3586
|
+
keySplines?: number | string | undefined;
|
3587
|
+
keyTimes?: number | string | undefined;
|
3588
|
+
lengthAdjust?: number | string | undefined;
|
3589
|
+
letterSpacing?: number | string | undefined;
|
3590
|
+
lightingColor?: number | string | undefined;
|
3591
|
+
limitingConeAngle?: number | string | undefined;
|
3592
|
+
local?: number | string | undefined;
|
3593
|
+
markerEnd?: string | undefined;
|
3594
|
+
markerHeight?: number | string | undefined;
|
3595
|
+
markerMid?: string | undefined;
|
3596
|
+
markerStart?: string | undefined;
|
3597
|
+
markerUnits?: number | string | undefined;
|
3598
|
+
markerWidth?: number | string | undefined;
|
3599
|
+
mask?: string | undefined;
|
3600
|
+
maskContentUnits?: number | string | undefined;
|
3601
|
+
maskUnits?: number | string | undefined;
|
3602
|
+
mathematical?: number | string | undefined;
|
3603
|
+
mode?: number | string | undefined;
|
3604
|
+
numOctaves?: number | string | undefined;
|
3605
|
+
offset?: number | string | undefined;
|
3606
|
+
opacity?: number | string | undefined;
|
3607
|
+
operator?: number | string | undefined;
|
3608
|
+
order?: number | string | undefined;
|
3609
|
+
orient?: number | string | undefined;
|
3610
|
+
orientation?: number | string | undefined;
|
3611
|
+
origin?: number | string | undefined;
|
3612
|
+
overflow?: number | string | undefined;
|
3613
|
+
overlinePosition?: number | string | undefined;
|
3614
|
+
overlineThickness?: number | string | undefined;
|
3615
|
+
paintOrder?: number | string | undefined;
|
3616
|
+
panose1?: number | string | undefined;
|
3617
|
+
path?: string | undefined;
|
3618
|
+
pathLength?: number | string | undefined;
|
3619
|
+
patternContentUnits?: string | undefined;
|
3620
|
+
patternTransform?: number | string | undefined;
|
3621
|
+
patternUnits?: string | undefined;
|
3622
|
+
pointerEvents?: number | string | undefined;
|
3623
|
+
points?: string | undefined;
|
3624
|
+
pointsAtX?: number | string | undefined;
|
3625
|
+
pointsAtY?: number | string | undefined;
|
3626
|
+
pointsAtZ?: number | string | undefined;
|
3627
|
+
preserveAlpha?: Booleanish | undefined;
|
3628
|
+
preserveAspectRatio?: string | undefined;
|
3629
|
+
primitiveUnits?: number | string | undefined;
|
3630
|
+
r?: number | string | undefined;
|
3631
|
+
radius?: number | string | undefined;
|
3632
|
+
refX?: number | string | undefined;
|
3633
|
+
refY?: number | string | undefined;
|
3634
|
+
renderingIntent?: number | string | undefined;
|
3635
|
+
repeatCount?: number | string | undefined;
|
3636
|
+
repeatDur?: number | string | undefined;
|
3637
|
+
requiredExtensions?: number | string | undefined;
|
3638
|
+
requiredFeatures?: number | string | undefined;
|
3639
|
+
restart?: number | string | undefined;
|
3640
|
+
result?: string | undefined;
|
3641
|
+
rotate?: number | string | undefined;
|
3642
|
+
rx?: number | string | undefined;
|
3643
|
+
ry?: number | string | undefined;
|
3644
|
+
scale?: number | string | undefined;
|
3645
|
+
seed?: number | string | undefined;
|
3646
|
+
shapeRendering?: number | string | undefined;
|
3647
|
+
slope?: number | string | undefined;
|
3648
|
+
spacing?: number | string | undefined;
|
3649
|
+
specularConstant?: number | string | undefined;
|
3650
|
+
specularExponent?: number | string | undefined;
|
3651
|
+
speed?: number | string | undefined;
|
3652
|
+
spreadMethod?: string | undefined;
|
3653
|
+
startOffset?: number | string | undefined;
|
3654
|
+
stdDeviation?: number | string | undefined;
|
3655
|
+
stemh?: number | string | undefined;
|
3656
|
+
stemv?: number | string | undefined;
|
3657
|
+
stitchTiles?: number | string | undefined;
|
3658
|
+
stopColor?: string | undefined;
|
3659
|
+
stopOpacity?: number | string | undefined;
|
3660
|
+
strikethroughPosition?: number | string | undefined;
|
3661
|
+
strikethroughThickness?: number | string | undefined;
|
3662
|
+
string?: number | string | undefined;
|
3663
|
+
stroke?: string | undefined;
|
3664
|
+
strokeDasharray?: string | number | undefined;
|
3665
|
+
strokeDashoffset?: string | number | undefined;
|
3666
|
+
strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
|
3667
|
+
strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
|
3668
|
+
strokeMiterlimit?: number | string | undefined;
|
3669
|
+
strokeOpacity?: number | string | undefined;
|
3670
|
+
strokeWidth?: number | string | undefined;
|
3671
|
+
surfaceScale?: number | string | undefined;
|
3672
|
+
systemLanguage?: number | string | undefined;
|
3673
|
+
tableValues?: number | string | undefined;
|
3674
|
+
targetX?: number | string | undefined;
|
3675
|
+
targetY?: number | string | undefined;
|
3676
|
+
textAnchor?: string | undefined;
|
3677
|
+
textDecoration?: number | string | undefined;
|
3678
|
+
textLength?: number | string | undefined;
|
3679
|
+
textRendering?: number | string | undefined;
|
3680
|
+
to?: number | string | undefined;
|
3681
|
+
transform?: string | undefined;
|
3682
|
+
u1?: number | string | undefined;
|
3683
|
+
u2?: number | string | undefined;
|
3684
|
+
underlinePosition?: number | string | undefined;
|
3685
|
+
underlineThickness?: number | string | undefined;
|
3686
|
+
unicode?: number | string | undefined;
|
3687
|
+
unicodeBidi?: number | string | undefined;
|
3688
|
+
unicodeRange?: number | string | undefined;
|
3689
|
+
unitsPerEm?: number | string | undefined;
|
3690
|
+
vAlphabetic?: number | string | undefined;
|
3691
|
+
values?: string | undefined;
|
3692
|
+
vectorEffect?: number | string | undefined;
|
3693
|
+
version?: string | undefined;
|
3694
|
+
vertAdvY?: number | string | undefined;
|
3695
|
+
vertOriginX?: number | string | undefined;
|
3696
|
+
vertOriginY?: number | string | undefined;
|
3697
|
+
vHanging?: number | string | undefined;
|
3698
|
+
vIdeographic?: number | string | undefined;
|
3699
|
+
viewBox?: string | undefined;
|
3700
|
+
viewTarget?: number | string | undefined;
|
3701
|
+
visibility?: number | string | undefined;
|
3702
|
+
vMathematical?: number | string | undefined;
|
3703
|
+
widths?: number | string | undefined;
|
3704
|
+
wordSpacing?: number | string | undefined;
|
3705
|
+
writingMode?: number | string | undefined;
|
3706
|
+
x1?: number | string | undefined;
|
3707
|
+
x2?: number | string | undefined;
|
3708
|
+
x?: number | string | undefined;
|
3709
|
+
xChannelSelector?: string | undefined;
|
3710
|
+
xHeight?: number | string | undefined;
|
3711
|
+
xlinkActuate?: string | undefined;
|
3712
|
+
xlinkArcrole?: string | undefined;
|
3713
|
+
xlinkHref?: string | undefined;
|
3714
|
+
xlinkRole?: string | undefined;
|
3715
|
+
xlinkShow?: string | undefined;
|
3716
|
+
xlinkTitle?: string | undefined;
|
3717
|
+
xlinkType?: string | undefined;
|
3718
|
+
xmlBase?: string | undefined;
|
3719
|
+
xmlLang?: string | undefined;
|
3720
|
+
xmlns?: string | undefined;
|
3721
|
+
xmlnsXlink?: string | undefined;
|
3722
|
+
xmlSpace?: string | undefined;
|
3723
|
+
y1?: number | string | undefined;
|
3724
|
+
y2?: number | string | undefined;
|
3725
|
+
y?: number | string | undefined;
|
3726
|
+
yChannelSelector?: string | undefined;
|
3727
|
+
z?: number | string | undefined;
|
3728
|
+
zoomAndPan?: string | undefined;
|
3729
|
+
}
|
3730
|
+
|
3731
|
+
interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
|
3732
|
+
allowFullScreen?: boolean | undefined;
|
3733
|
+
allowpopups?: boolean | undefined;
|
3734
|
+
autosize?: boolean | undefined;
|
3735
|
+
blinkfeatures?: string | undefined;
|
3736
|
+
disableblinkfeatures?: string | undefined;
|
3737
|
+
disableguestresize?: boolean | undefined;
|
3738
|
+
disablewebsecurity?: boolean | undefined;
|
3739
|
+
guestinstance?: string | undefined;
|
3740
|
+
httpreferrer?: string | undefined;
|
3741
|
+
nodeintegration?: boolean | undefined;
|
3742
|
+
partition?: string | undefined;
|
3743
|
+
plugins?: boolean | undefined;
|
3744
|
+
preload?: string | undefined;
|
3745
|
+
src?: string | undefined;
|
3746
|
+
useragent?: string | undefined;
|
3747
|
+
webpreferences?: string | undefined;
|
3748
|
+
}
|
3749
|
+
|
3750
|
+
// TODO: Move to react-dom
|
3751
|
+
type HTMLElementType =
|
3752
|
+
| "a"
|
3753
|
+
| "abbr"
|
3754
|
+
| "address"
|
3755
|
+
| "area"
|
3756
|
+
| "article"
|
3757
|
+
| "aside"
|
3758
|
+
| "audio"
|
3759
|
+
| "b"
|
3760
|
+
| "base"
|
3761
|
+
| "bdi"
|
3762
|
+
| "bdo"
|
3763
|
+
| "big"
|
3764
|
+
| "blockquote"
|
3765
|
+
| "body"
|
3766
|
+
| "br"
|
3767
|
+
| "button"
|
3768
|
+
| "canvas"
|
3769
|
+
| "caption"
|
3770
|
+
| "center"
|
3771
|
+
| "cite"
|
3772
|
+
| "code"
|
3773
|
+
| "col"
|
3774
|
+
| "colgroup"
|
3775
|
+
| "data"
|
3776
|
+
| "datalist"
|
3777
|
+
| "dd"
|
3778
|
+
| "del"
|
3779
|
+
| "details"
|
3780
|
+
| "dfn"
|
3781
|
+
| "dialog"
|
3782
|
+
| "div"
|
3783
|
+
| "dl"
|
3784
|
+
| "dt"
|
3785
|
+
| "em"
|
3786
|
+
| "embed"
|
3787
|
+
| "fieldset"
|
3788
|
+
| "figcaption"
|
3789
|
+
| "figure"
|
3790
|
+
| "footer"
|
3791
|
+
| "form"
|
3792
|
+
| "h1"
|
3793
|
+
| "h2"
|
3794
|
+
| "h3"
|
3795
|
+
| "h4"
|
3796
|
+
| "h5"
|
3797
|
+
| "h6"
|
3798
|
+
| "head"
|
3799
|
+
| "header"
|
3800
|
+
| "hgroup"
|
3801
|
+
| "hr"
|
3802
|
+
| "html"
|
3803
|
+
| "i"
|
3804
|
+
| "iframe"
|
3805
|
+
| "img"
|
3806
|
+
| "input"
|
3807
|
+
| "ins"
|
3808
|
+
| "kbd"
|
3809
|
+
| "keygen"
|
3810
|
+
| "label"
|
3811
|
+
| "legend"
|
3812
|
+
| "li"
|
3813
|
+
| "link"
|
3814
|
+
| "main"
|
3815
|
+
| "map"
|
3816
|
+
| "mark"
|
3817
|
+
| "menu"
|
3818
|
+
| "menuitem"
|
3819
|
+
| "meta"
|
3820
|
+
| "meter"
|
3821
|
+
| "nav"
|
3822
|
+
| "noscript"
|
3823
|
+
| "object"
|
3824
|
+
| "ol"
|
3825
|
+
| "optgroup"
|
3826
|
+
| "option"
|
3827
|
+
| "output"
|
3828
|
+
| "p"
|
3829
|
+
| "param"
|
3830
|
+
| "picture"
|
3831
|
+
| "pre"
|
3832
|
+
| "progress"
|
3833
|
+
| "q"
|
3834
|
+
| "rp"
|
3835
|
+
| "rt"
|
3836
|
+
| "ruby"
|
3837
|
+
| "s"
|
3838
|
+
| "samp"
|
3839
|
+
| "search"
|
3840
|
+
| "slot"
|
3841
|
+
| "script"
|
3842
|
+
| "section"
|
3843
|
+
| "select"
|
3844
|
+
| "small"
|
3845
|
+
| "source"
|
3846
|
+
| "span"
|
3847
|
+
| "strong"
|
3848
|
+
| "style"
|
3849
|
+
| "sub"
|
3850
|
+
| "summary"
|
3851
|
+
| "sup"
|
3852
|
+
| "table"
|
3853
|
+
| "template"
|
3854
|
+
| "tbody"
|
3855
|
+
| "td"
|
3856
|
+
| "textarea"
|
3857
|
+
| "tfoot"
|
3858
|
+
| "th"
|
3859
|
+
| "thead"
|
3860
|
+
| "time"
|
3861
|
+
| "title"
|
3862
|
+
| "tr"
|
3863
|
+
| "track"
|
3864
|
+
| "u"
|
3865
|
+
| "ul"
|
3866
|
+
| "var"
|
3867
|
+
| "video"
|
3868
|
+
| "wbr"
|
3869
|
+
| "webview";
|
3870
|
+
|
3871
|
+
// TODO: Move to react-dom
|
3872
|
+
type SVGElementType =
|
3873
|
+
| "animate"
|
3874
|
+
| "circle"
|
3875
|
+
| "clipPath"
|
3876
|
+
| "defs"
|
3877
|
+
| "desc"
|
3878
|
+
| "ellipse"
|
3879
|
+
| "feBlend"
|
3880
|
+
| "feColorMatrix"
|
3881
|
+
| "feComponentTransfer"
|
3882
|
+
| "feComposite"
|
3883
|
+
| "feConvolveMatrix"
|
3884
|
+
| "feDiffuseLighting"
|
3885
|
+
| "feDisplacementMap"
|
3886
|
+
| "feDistantLight"
|
3887
|
+
| "feDropShadow"
|
3888
|
+
| "feFlood"
|
3889
|
+
| "feFuncA"
|
3890
|
+
| "feFuncB"
|
3891
|
+
| "feFuncG"
|
3892
|
+
| "feFuncR"
|
3893
|
+
| "feGaussianBlur"
|
3894
|
+
| "feImage"
|
3895
|
+
| "feMerge"
|
3896
|
+
| "feMergeNode"
|
3897
|
+
| "feMorphology"
|
3898
|
+
| "feOffset"
|
3899
|
+
| "fePointLight"
|
3900
|
+
| "feSpecularLighting"
|
3901
|
+
| "feSpotLight"
|
3902
|
+
| "feTile"
|
3903
|
+
| "feTurbulence"
|
3904
|
+
| "filter"
|
3905
|
+
| "foreignObject"
|
3906
|
+
| "g"
|
3907
|
+
| "image"
|
3908
|
+
| "line"
|
3909
|
+
| "linearGradient"
|
3910
|
+
| "marker"
|
3911
|
+
| "mask"
|
3912
|
+
| "metadata"
|
3913
|
+
| "path"
|
3914
|
+
| "pattern"
|
3915
|
+
| "polygon"
|
3916
|
+
| "polyline"
|
3917
|
+
| "radialGradient"
|
3918
|
+
| "rect"
|
3919
|
+
| "stop"
|
3920
|
+
| "svg"
|
3921
|
+
| "switch"
|
3922
|
+
| "symbol"
|
3923
|
+
| "text"
|
3924
|
+
| "textPath"
|
3925
|
+
| "tspan"
|
3926
|
+
| "use"
|
3927
|
+
| "view";
|
3928
|
+
|
3929
|
+
//
|
3930
|
+
// Browser Interfaces
|
3931
|
+
// https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
|
3932
|
+
// ----------------------------------------------------------------------
|
3933
|
+
|
3934
|
+
interface AbstractView {
|
3935
|
+
styleMedia: StyleMedia;
|
3936
|
+
document: Document;
|
3937
|
+
}
|
3938
|
+
|
3939
|
+
interface Touch {
|
3940
|
+
identifier: number;
|
3941
|
+
target: EventTarget;
|
3942
|
+
screenX: number;
|
3943
|
+
screenY: number;
|
3944
|
+
clientX: number;
|
3945
|
+
clientY: number;
|
3946
|
+
pageX: number;
|
3947
|
+
pageY: number;
|
3948
|
+
}
|
3949
|
+
|
3950
|
+
interface TouchList {
|
3951
|
+
[index: number]: Touch;
|
3952
|
+
length: number;
|
3953
|
+
item(index: number): Touch;
|
3954
|
+
identifiedTouch(identifier: number): Touch;
|
3955
|
+
}
|
3956
|
+
|
3957
|
+
//
|
3958
|
+
// Error Interfaces
|
3959
|
+
// ----------------------------------------------------------------------
|
3960
|
+
interface ErrorInfo {
|
3961
|
+
/**
|
3962
|
+
* Captures which component contained the exception, and its ancestors.
|
3963
|
+
*/
|
3964
|
+
componentStack?: string | null;
|
3965
|
+
digest?: string | null;
|
3966
|
+
}
|
3967
|
+
|
3968
|
+
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
3969
|
+
namespace JSX {
|
3970
|
+
interface Element extends React.ReactElement<any, any> {}
|
3971
|
+
interface ElementClass extends React.Component<any> {
|
3972
|
+
render(): React.ReactNode;
|
3973
|
+
}
|
3974
|
+
interface ElementAttributesProperty {
|
3975
|
+
props: {};
|
3976
|
+
}
|
3977
|
+
interface ElementChildrenAttribute {
|
3978
|
+
children: {};
|
3979
|
+
}
|
3980
|
+
|
3981
|
+
// We can't recurse forever because `type` can't be self-referential;
|
3982
|
+
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
|
3983
|
+
type LibraryManagedAttributes<C, P> = C extends
|
3984
|
+
React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
|
3985
|
+
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
|
3986
|
+
? ReactManagedAttributes<U, P>
|
3987
|
+
: ReactManagedAttributes<T, P>
|
3988
|
+
: ReactManagedAttributes<C, P>;
|
3989
|
+
|
3990
|
+
interface IntrinsicAttributes extends React.Attributes {}
|
3991
|
+
interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {}
|
3992
|
+
|
3993
|
+
interface IntrinsicElements {
|
3994
|
+
// HTML
|
3995
|
+
a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
3996
|
+
abbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
3997
|
+
address: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
3998
|
+
area: React.DetailedHTMLProps<React.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
|
3999
|
+
article: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4000
|
+
aside: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4001
|
+
audio: React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
|
4002
|
+
b: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4003
|
+
base: React.DetailedHTMLProps<React.BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
|
4004
|
+
bdi: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4005
|
+
bdo: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4006
|
+
big: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4007
|
+
blockquote: React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
|
4008
|
+
body: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
|
4009
|
+
br: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
|
4010
|
+
button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
|
4011
|
+
canvas: React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
|
4012
|
+
caption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4013
|
+
center: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4014
|
+
cite: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4015
|
+
code: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4016
|
+
col: React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
|
4017
|
+
colgroup: React.DetailedHTMLProps<React.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
|
4018
|
+
data: React.DetailedHTMLProps<React.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
|
4019
|
+
datalist: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
|
4020
|
+
dd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4021
|
+
del: React.DetailedHTMLProps<React.DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
|
4022
|
+
details: React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
|
4023
|
+
dfn: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4024
|
+
dialog: React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
|
4025
|
+
div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
4026
|
+
dl: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
|
4027
|
+
dt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4028
|
+
em: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4029
|
+
embed: React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
|
4030
|
+
fieldset: React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
|
4031
|
+
figcaption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4032
|
+
figure: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4033
|
+
footer: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4034
|
+
form: React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
|
4035
|
+
h1: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
4036
|
+
h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
4037
|
+
h3: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
4038
|
+
h4: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
4039
|
+
h5: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
4040
|
+
h6: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
4041
|
+
head: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>;
|
4042
|
+
header: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4043
|
+
hgroup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4044
|
+
hr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
|
4045
|
+
html: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
|
4046
|
+
i: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4047
|
+
iframe: React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
|
4048
|
+
img: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
4049
|
+
input: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
4050
|
+
ins: React.DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
|
4051
|
+
kbd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4052
|
+
keygen: React.DetailedHTMLProps<React.KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
|
4053
|
+
label: React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
|
4054
|
+
legend: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
|
4055
|
+
li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
|
4056
|
+
link: React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
|
4057
|
+
main: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4058
|
+
map: React.DetailedHTMLProps<React.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
|
4059
|
+
mark: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4060
|
+
menu: React.DetailedHTMLProps<React.MenuHTMLAttributes<HTMLElement>, HTMLElement>;
|
4061
|
+
menuitem: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4062
|
+
meta: React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
|
4063
|
+
meter: React.DetailedHTMLProps<React.MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
|
4064
|
+
nav: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4065
|
+
noindex: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4066
|
+
noscript: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4067
|
+
object: React.DetailedHTMLProps<React.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
|
4068
|
+
ol: React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
|
4069
|
+
optgroup: React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
|
4070
|
+
option: React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
|
4071
|
+
output: React.DetailedHTMLProps<React.OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
|
4072
|
+
p: React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
|
4073
|
+
param: React.DetailedHTMLProps<React.ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
|
4074
|
+
picture: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4075
|
+
pre: React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
|
4076
|
+
progress: React.DetailedHTMLProps<React.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
|
4077
|
+
q: React.DetailedHTMLProps<React.QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
|
4078
|
+
rp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4079
|
+
rt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4080
|
+
ruby: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4081
|
+
s: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4082
|
+
samp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4083
|
+
search: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4084
|
+
slot: React.DetailedHTMLProps<React.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
|
4085
|
+
script: React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
|
4086
|
+
section: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4087
|
+
select: React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
|
4088
|
+
small: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4089
|
+
source: React.DetailedHTMLProps<React.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
|
4090
|
+
span: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
|
4091
|
+
strong: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4092
|
+
style: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
|
4093
|
+
sub: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4094
|
+
summary: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4095
|
+
sup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4096
|
+
table: React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
|
4097
|
+
template: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
|
4098
|
+
tbody: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
|
4099
|
+
td: React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
|
4100
|
+
textarea: React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
|
4101
|
+
tfoot: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
|
4102
|
+
th: React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
|
4103
|
+
thead: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
|
4104
|
+
time: React.DetailedHTMLProps<React.TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
|
4105
|
+
title: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
|
4106
|
+
tr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
|
4107
|
+
track: React.DetailedHTMLProps<React.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
|
4108
|
+
u: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4109
|
+
ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
|
4110
|
+
"var": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4111
|
+
video: React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
|
4112
|
+
wbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
4113
|
+
webview: React.DetailedHTMLProps<React.WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
|
4114
|
+
|
4115
|
+
// SVG
|
4116
|
+
svg: React.SVGProps<SVGSVGElement>;
|
4117
|
+
|
4118
|
+
animate: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now.
|
4119
|
+
animateMotion: React.SVGProps<SVGElement>;
|
4120
|
+
animateTransform: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now.
|
4121
|
+
circle: React.SVGProps<SVGCircleElement>;
|
4122
|
+
clipPath: React.SVGProps<SVGClipPathElement>;
|
4123
|
+
defs: React.SVGProps<SVGDefsElement>;
|
4124
|
+
desc: React.SVGProps<SVGDescElement>;
|
4125
|
+
ellipse: React.SVGProps<SVGEllipseElement>;
|
4126
|
+
feBlend: React.SVGProps<SVGFEBlendElement>;
|
4127
|
+
feColorMatrix: React.SVGProps<SVGFEColorMatrixElement>;
|
4128
|
+
feComponentTransfer: React.SVGProps<SVGFEComponentTransferElement>;
|
4129
|
+
feComposite: React.SVGProps<SVGFECompositeElement>;
|
4130
|
+
feConvolveMatrix: React.SVGProps<SVGFEConvolveMatrixElement>;
|
4131
|
+
feDiffuseLighting: React.SVGProps<SVGFEDiffuseLightingElement>;
|
4132
|
+
feDisplacementMap: React.SVGProps<SVGFEDisplacementMapElement>;
|
4133
|
+
feDistantLight: React.SVGProps<SVGFEDistantLightElement>;
|
4134
|
+
feDropShadow: React.SVGProps<SVGFEDropShadowElement>;
|
4135
|
+
feFlood: React.SVGProps<SVGFEFloodElement>;
|
4136
|
+
feFuncA: React.SVGProps<SVGFEFuncAElement>;
|
4137
|
+
feFuncB: React.SVGProps<SVGFEFuncBElement>;
|
4138
|
+
feFuncG: React.SVGProps<SVGFEFuncGElement>;
|
4139
|
+
feFuncR: React.SVGProps<SVGFEFuncRElement>;
|
4140
|
+
feGaussianBlur: React.SVGProps<SVGFEGaussianBlurElement>;
|
4141
|
+
feImage: React.SVGProps<SVGFEImageElement>;
|
4142
|
+
feMerge: React.SVGProps<SVGFEMergeElement>;
|
4143
|
+
feMergeNode: React.SVGProps<SVGFEMergeNodeElement>;
|
4144
|
+
feMorphology: React.SVGProps<SVGFEMorphologyElement>;
|
4145
|
+
feOffset: React.SVGProps<SVGFEOffsetElement>;
|
4146
|
+
fePointLight: React.SVGProps<SVGFEPointLightElement>;
|
4147
|
+
feSpecularLighting: React.SVGProps<SVGFESpecularLightingElement>;
|
4148
|
+
feSpotLight: React.SVGProps<SVGFESpotLightElement>;
|
4149
|
+
feTile: React.SVGProps<SVGFETileElement>;
|
4150
|
+
feTurbulence: React.SVGProps<SVGFETurbulenceElement>;
|
4151
|
+
filter: React.SVGProps<SVGFilterElement>;
|
4152
|
+
foreignObject: React.SVGProps<SVGForeignObjectElement>;
|
4153
|
+
g: React.SVGProps<SVGGElement>;
|
4154
|
+
image: React.SVGProps<SVGImageElement>;
|
4155
|
+
line: React.SVGLineElementAttributes<SVGLineElement>;
|
4156
|
+
linearGradient: React.SVGProps<SVGLinearGradientElement>;
|
4157
|
+
marker: React.SVGProps<SVGMarkerElement>;
|
4158
|
+
mask: React.SVGProps<SVGMaskElement>;
|
4159
|
+
metadata: React.SVGProps<SVGMetadataElement>;
|
4160
|
+
mpath: React.SVGProps<SVGElement>;
|
4161
|
+
path: React.SVGProps<SVGPathElement>;
|
4162
|
+
pattern: React.SVGProps<SVGPatternElement>;
|
4163
|
+
polygon: React.SVGProps<SVGPolygonElement>;
|
4164
|
+
polyline: React.SVGProps<SVGPolylineElement>;
|
4165
|
+
radialGradient: React.SVGProps<SVGRadialGradientElement>;
|
4166
|
+
rect: React.SVGProps<SVGRectElement>;
|
4167
|
+
set: React.SVGProps<SVGSetElement>;
|
4168
|
+
stop: React.SVGProps<SVGStopElement>;
|
4169
|
+
switch: React.SVGProps<SVGSwitchElement>;
|
4170
|
+
symbol: React.SVGProps<SVGSymbolElement>;
|
4171
|
+
text: React.SVGTextElementAttributes<SVGTextElement>;
|
4172
|
+
textPath: React.SVGProps<SVGTextPathElement>;
|
4173
|
+
tspan: React.SVGProps<SVGTSpanElement>;
|
4174
|
+
use: React.SVGProps<SVGUseElement>;
|
4175
|
+
view: React.SVGProps<SVGViewElement>;
|
4176
|
+
}
|
4177
|
+
}
|
4178
|
+
}
|
4179
|
+
|
4180
|
+
type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
|
4181
|
+
|
4182
|
+
// Any prop that has a default prop becomes optional, but its type is unchanged
|
4183
|
+
// Undeclared default props are augmented into the resulting allowable attributes
|
4184
|
+
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
4185
|
+
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
4186
|
+
type Defaultize<P, D> = P extends any ? string extends keyof P ? P
|
4187
|
+
:
|
4188
|
+
& Pick<P, Exclude<keyof P, keyof D>>
|
4189
|
+
& InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
|
4190
|
+
& InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
|
4191
|
+
: never;
|
4192
|
+
|
4193
|
+
type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
|
4194
|
+
: P;
|