Unverified Commit db008670 authored by Sebastian Silbermann's avatar Sebastian Silbermann Committed by GitHub

Upgrade `@types/react` to latest 18.x (#48645)

Required for  https://github.com/vercel/next.js/pull/48641

[React 18 types
changelog](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210)

Revealed some bugs in `React.Children` typings that were hidden due to
`{}` being part of `ReactNode` before 18.x types.
The rest is mostly missing `children` props types.
parent e9521600
...@@ -86,13 +86,13 @@ ...@@ -86,13 +86,13 @@
"@types/jest": "24.0.13", "@types/jest": "24.0.13",
"@types/node": "14.14.31", "@types/node": "14.14.31",
"@types/node-fetch": "2.6.1", "@types/node-fetch": "2.6.1",
"@types/react": "16.9.17", "@types/react": "18.0.37",
"@types/react-dom": "16.9.4", "@types/react-dom": "18.0.11",
"@types/relay-runtime": "13.0.0", "@types/relay-runtime": "13.0.0",
"@types/selenium-webdriver": "4.0.15", "@types/selenium-webdriver": "4.0.15",
"@types/sharp": "0.29.3", "@types/sharp": "0.29.3",
"@types/string-hash": "1.1.1", "@types/string-hash": "1.1.1",
"@types/trusted-types": "2.0.2", "@types/trusted-types": "2.0.3",
"@typescript-eslint/eslint-plugin": "4.29.1", "@typescript-eslint/eslint-plugin": "4.29.1",
"@typescript-eslint/parser": "4.29.1", "@typescript-eslint/parser": "4.29.1",
"@vercel/fetch": "6.1.1", "@vercel/fetch": "6.1.1",
...@@ -240,7 +240,9 @@ ...@@ -240,7 +240,9 @@
"@babel/core": "7.18.0", "@babel/core": "7.18.0",
"@babel/parser": "7.18.0", "@babel/parser": "7.18.0",
"@babel/types": "7.18.0", "@babel/types": "7.18.0",
"@babel/traverse": "7.18.0" "@babel/traverse": "7.18.0",
"@types/react": "18.0.37",
"@types/react-dom": "18.0.11"
}, },
"engines": { "engines": {
"node": ">=14.18.0" "node": ">=14.18.0"
......
...@@ -174,9 +174,9 @@ ...@@ -174,9 +174,9 @@
"@types/node-fetch": "2.6.1", "@types/node-fetch": "2.6.1",
"@types/path-to-regexp": "1.7.0", "@types/path-to-regexp": "1.7.0",
"@types/platform": "1.3.4", "@types/platform": "1.3.4",
"@types/react": "16.9.17", "@types/react": "18.0.37",
"@types/react-dom": "16.9.4", "@types/react-dom": "18.0.11",
"@types/react-is": "16.7.1", "@types/react-is": "17.0.3",
"@types/semver": "7.3.1", "@types/semver": "7.3.1",
"@types/send": "0.14.4", "@types/send": "0.14.4",
"@types/shell-quote": "1.7.1", "@types/shell-quote": "1.7.1",
......
...@@ -31,6 +31,7 @@ export type ErrorComponent = React.ComponentType<{ ...@@ -31,6 +31,7 @@ export type ErrorComponent = React.ComponentType<{
}> }>
export interface ErrorBoundaryProps { export interface ErrorBoundaryProps {
children?: React.ReactNode
errorComponent: ErrorComponent errorComponent: ErrorComponent
errorStyles?: React.ReactNode | undefined errorStyles?: React.ReactNode | undefined
} }
......
...@@ -4,7 +4,6 @@ import React, { ...@@ -4,7 +4,6 @@ import React, {
useEffect, useEffect,
useReducer, useReducer,
useMemo, useMemo,
// @ts-expect-error TODO-APP: startTransition exists
startTransition, startTransition,
} from 'react' } from 'react'
import stripAnsi from 'next/dist/compiled/strip-ansi' import stripAnsi from 'next/dist/compiled/strip-ansi'
......
...@@ -2,6 +2,7 @@ import * as React from 'react' ...@@ -2,6 +2,7 @@ import * as React from 'react'
import { useOnClickOutside } from '../../hooks/use-on-click-outside' import { useOnClickOutside } from '../../hooks/use-on-click-outside'
export type DialogProps = { export type DialogProps = {
children?: React.ReactNode
type: 'error' | 'warning' type: 'error' | 'warning'
'aria-labelledby': string 'aria-labelledby': string
'aria-describedby': string 'aria-describedby': string
...@@ -15,7 +16,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -15,7 +16,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
...props ...props
}) { }) {
const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null) const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null)
const onDialog = React.useCallback((node) => { const onDialog = React.useCallback((node: HTMLDivElement | null) => {
setDialog(node) setDialog(node)
}, []) }, [])
useOnClickOutside(dialog, onClose) useOnClickOutside(dialog, onClose)
......
import * as React from 'react' import * as React from 'react'
export type DialogBodyProps = { export type DialogBodyProps = {
children?: React.ReactNode
className?: string className?: string
} }
......
import * as React from 'react' import * as React from 'react'
export type DialogContentProps = { export type DialogContentProps = {
children?: React.ReactNode
className?: string className?: string
} }
......
import * as React from 'react' import * as React from 'react'
export type DialogHeaderProps = { export type DialogHeaderProps = {
children?: React.ReactNode
className?: string className?: string
} }
......
...@@ -2,6 +2,7 @@ import * as React from 'react' ...@@ -2,6 +2,7 @@ import * as React from 'react'
import { CloseIcon } from '../../icons/CloseIcon' import { CloseIcon } from '../../icons/CloseIcon'
export type LeftRightDialogHeaderProps = { export type LeftRightDialogHeaderProps = {
children?: React.ReactNode
className?: string className?: string
previous: (() => void) | null previous: (() => void) | null
next: (() => void) | null next: (() => void) | null
......
...@@ -3,7 +3,11 @@ import allyTrap from './maintain--tab-focus' ...@@ -3,7 +3,11 @@ import allyTrap from './maintain--tab-focus'
import * as React from 'react' import * as React from 'react'
import { lock, unlock } from './body-locker' import { lock, unlock } from './body-locker'
export type OverlayProps = { className?: string; fixed?: boolean } export type OverlayProps = {
children?: React.ReactNode
className?: string
fixed?: boolean
}
const Overlay: React.FC<OverlayProps> = function Overlay({ const Overlay: React.FC<OverlayProps> = function Overlay({
className, className,
......
import * as React from 'react' import * as React from 'react'
export type ToastProps = { export type ToastProps = {
children?: React.ReactNode
onClick?: (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => void onClick?: (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
className?: string className?: string
} }
......
...@@ -30,7 +30,7 @@ export function useWebsocket(assetPrefix: string) { ...@@ -30,7 +30,7 @@ export function useWebsocket(assetPrefix: string) {
export function useSendMessage(webSocketRef: ReturnType<typeof useWebsocket>) { export function useSendMessage(webSocketRef: ReturnType<typeof useWebsocket>) {
const sendMessage = useCallback( const sendMessage = useCallback(
(data) => { (data: string) => {
const socket = webSocketRef.current const socket = webSocketRef.current
if (!socket || socket.readyState !== socket.OPEN) { if (!socket || socket.readyState !== socket.OPEN) {
return return
......
...@@ -145,7 +145,6 @@ type ImageElementProps = Omit<ImageProps, 'src' | 'alt' | 'loader'> & { ...@@ -145,7 +145,6 @@ type ImageElementProps = Omit<ImageProps, 'src' | 'alt' | 'loader'> & {
imgStyle: ImgElementStyle imgStyle: ImgElementStyle
blurStyle: ImgElementStyle blurStyle: ImgElementStyle
isLazy: boolean isLazy: boolean
fetchPriority: string
fill?: boolean fill?: boolean
loading: LoadingValue loading: LoadingValue
config: ImageConfig config: ImageConfig
...@@ -420,7 +419,6 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>( ...@@ -420,7 +419,6 @@ const ImageElement = forwardRef<HTMLImageElement | null, ImageElementProps>(
<img <img
{...rest} {...rest}
{...getDynamicProps(fetchPriority)} {...getDynamicProps(fetchPriority)}
// @ts-expect-error - TODO: upgrade to `@types/react@18`
loading={loading} loading={loading}
width={widthInt} width={widthInt}
height={heightInt} height={heightInt}
...@@ -534,7 +532,6 @@ const Image = forwardRef<HTMLImageElement | null, ImageProps>( ...@@ -534,7 +532,6 @@ const Image = forwardRef<HTMLImageElement | null, ImageProps>(
onLoadingComplete, onLoadingComplete,
placeholder = 'empty', placeholder = 'empty',
blurDataURL, blurDataURL,
// @ts-expect-error - TODO: upgrade to `@types/react@18`
fetchPriority, fetchPriority,
layout, layout,
objectFit, objectFit,
...@@ -972,7 +969,6 @@ const Image = forwardRef<HTMLImageElement | null, ImageProps>( ...@@ -972,7 +969,6 @@ const Image = forwardRef<HTMLImageElement | null, ImageProps>(
rel="preload" rel="preload"
as="image" as="image"
href={imgAttributes.srcSet ? undefined : imgAttributes.src} href={imgAttributes.srcSet ? undefined : imgAttributes.src}
// @ts-expect-error - TODO: upgrade to `@types/react@18`
imageSrcSet={imgAttributes.srcSet} imageSrcSet={imgAttributes.srcSet}
imageSizes={imgAttributes.sizes} imageSizes={imgAttributes.sizes}
crossOrigin={rest.crossOrigin} crossOrigin={rest.crossOrigin}
......
...@@ -9,7 +9,6 @@ import type { ...@@ -9,7 +9,6 @@ import type {
} from '../shared/lib/router/router' } from '../shared/lib/router/router'
import React from 'react' import React from 'react'
// @ts-expect-error upgrade react types to react 18
import ReactDOM from 'react-dom/client' import ReactDOM from 'react-dom/client'
import { HeadManagerContext } from '../shared/lib/head-manager-context' import { HeadManagerContext } from '../shared/lib/head-manager-context'
import mitt, { MittEmitter } from '../shared/lib/mitt' import mitt, { MittEmitter } from '../shared/lib/mitt'
...@@ -101,6 +100,7 @@ let CachedComponent: React.ComponentType ...@@ -101,6 +100,7 @@ let CachedComponent: React.ComponentType
;(self as any).__next_require__ = __webpack_require__ ;(self as any).__next_require__ = __webpack_require__
class Container extends React.Component<{ class Container extends React.Component<{
children?: React.ReactNode
fn: (err: Error, info?: any) => void fn: (err: Error, info?: any) => void
}> { }> {
componentDidCatch(componentErr: Error, info: any) { componentDidCatch(componentErr: Error, info: any) {
...@@ -509,6 +509,7 @@ function renderReactElement( ...@@ -509,6 +509,7 @@ function renderReactElement(
if (!reactRoot) { if (!reactRoot) {
// Unlike with createRoot, you don't need a separate root.render() call here // Unlike with createRoot, you don't need a separate root.render() call here
reactRoot = ReactDOM.hydrateRoot(domEl, reactEl, { reactRoot = ReactDOM.hydrateRoot(domEl, reactEl, {
// @ts-expect-error Missing errorInfo in @types/react
onRecoverableError, onRecoverableError,
}) })
// TODO: Remove shouldHydrate variable when React 18 is stable as it can depend on `reactRoot` existing // TODO: Remove shouldHydrate variable when React 18 is stable as it can depend on `reactRoot` existing
......
...@@ -976,7 +976,6 @@ export default function Image({ ...@@ -976,7 +976,6 @@ export default function Image({
React.LinkHTMLAttributes<HTMLLinkElement>, React.LinkHTMLAttributes<HTMLLinkElement>,
HTMLLinkElement HTMLLinkElement
> = { > = {
// @ts-expect-error upgrade react types to react 18
imageSrcSet: imgAttributes.srcSet, imageSrcSet: imgAttributes.srcSet,
imageSizes: imgAttributes.sizes, imageSizes: imgAttributes.sizes,
crossOrigin: rest.crossOrigin, crossOrigin: rest.crossOrigin,
......
...@@ -224,7 +224,6 @@ function linkClicked( ...@@ -224,7 +224,6 @@ function linkClicked(
} }
if (isAppRouter) { if (isAppRouter) {
// @ts-expect-error startTransition exists.
React.startTransition(navigate) React.startTransition(navigate)
} else { } else {
navigate() navigate()
......
...@@ -91,7 +91,8 @@ const loadScript = (props: ScriptProps): void => { ...@@ -91,7 +91,8 @@ const loadScript = (props: ScriptProps): void => {
}) })
if (dangerouslySetInnerHTML) { if (dangerouslySetInnerHTML) {
el.innerHTML = dangerouslySetInnerHTML.__html || '' // Casting since lib.dom.d.ts doesn't have TrustedHTML yet.
el.innerHTML = (dangerouslySetInnerHTML.__html as string) || ''
afterLoad() afterLoad()
} else if (children) { } else if (children) {
...@@ -264,7 +265,9 @@ function Script(props: ScriptProps): JSX.Element | null { ...@@ -264,7 +265,9 @@ function Script(props: ScriptProps): JSX.Element | null {
if (!src) { if (!src) {
// For inlined scripts, we put the content in `children`. // For inlined scripts, we put the content in `children`.
if (restProps.dangerouslySetInnerHTML) { if (restProps.dangerouslySetInnerHTML) {
restProps.children = restProps.dangerouslySetInnerHTML.__html // Casting since lib.dom.d.ts doesn't have TrustedHTML yet.
restProps.children = restProps.dangerouslySetInnerHTML
.__html as string
delete restProps.dangerouslySetInnerHTML delete restProps.dangerouslySetInnerHTML
} }
......
...@@ -24,7 +24,7 @@ export { DocumentContext, DocumentInitialProps, DocumentProps } ...@@ -24,7 +24,7 @@ export { DocumentContext, DocumentInitialProps, DocumentProps }
export type OriginProps = { export type OriginProps = {
nonce?: string nonce?: string
crossOrigin?: string crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined
children?: React.ReactNode children?: React.ReactNode
} }
...@@ -259,9 +259,7 @@ function getPreNextWorkerScripts(context: HtmlProps, props: OriginProps) { ...@@ -259,9 +259,7 @@ function getPreNextWorkerScripts(context: HtmlProps, props: OriginProps) {
let srcProps: { let srcProps: {
src?: string src?: string
dangerouslySetInnerHTML?: { dangerouslySetInnerHTML?: ScriptProps['dangerouslySetInnerHTML']
__html: string
}
} = {} } = {}
if (src) { if (src) {
...@@ -582,7 +580,9 @@ export class Head extends React.Component<HeadProps> { ...@@ -582,7 +580,9 @@ export class Head extends React.Component<HeadProps> {
src, src,
...scriptProps ...scriptProps
} = file } = file
let html = '' let html: NonNullable<
ScriptProps['dangerouslySetInnerHTML']
>['__html'] = ''
if (dangerouslySetInnerHTML && dangerouslySetInnerHTML.__html) { if (dangerouslySetInnerHTML && dangerouslySetInnerHTML.__html) {
html = dangerouslySetInnerHTML.__html html = dangerouslySetInnerHTML.__html
...@@ -602,7 +602,10 @@ export class Head extends React.Component<HeadProps> { ...@@ -602,7 +602,10 @@ export class Head extends React.Component<HeadProps> {
key={scriptProps.id || index} key={scriptProps.id || index}
nonce={nonce} nonce={nonce}
data-nscript="beforeInteractive" data-nscript="beforeInteractive"
crossOrigin={crossOrigin || process.env.__NEXT_CROSS_ORIGIN} crossOrigin={
crossOrigin ||
(process.env.__NEXT_CROSS_ORIGIN as typeof crossOrigin)
}
/> />
) )
}) })
...@@ -624,7 +627,7 @@ export class Head extends React.Component<HeadProps> { ...@@ -624,7 +627,7 @@ export class Head extends React.Component<HeadProps> {
return getPolyfillScripts(this.context, this.props) return getPolyfillScripts(this.context, this.props)
} }
makeStylesheetInert(node: ReactNode): ReactNode[] { makeStylesheetInert(node: ReactNode[]): ReactNode[] {
return React.Children.map(node, (c: any) => { return React.Children.map(node, (c: any) => {
if ( if (
c?.type === 'link' && c?.type === 'link' &&
...@@ -650,7 +653,8 @@ export class Head extends React.Component<HeadProps> { ...@@ -650,7 +653,8 @@ export class Head extends React.Component<HeadProps> {
} }
return c return c
}).filter(Boolean) // @types/react bug. Returned value from .map will not be `null` if you pass in `[null]`
})!.filter(Boolean)
} }
render() { render() {
...@@ -711,7 +715,9 @@ export class Head extends React.Component<HeadProps> { ...@@ -711,7 +715,9 @@ export class Head extends React.Component<HeadProps> {
}) })
head = cssPreloads.concat(otherHeadElements) head = cssPreloads.concat(otherHeadElements)
} }
let children = React.Children.toArray(this.props.children).filter(Boolean) let children: React.ReactNode[] = React.Children.toArray(
this.props.children
).filter(Boolean)
// show a warning if Head contains <title> (only in development) // show a warning if Head contains <title> (only in development)
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
children = React.Children.map(children, (child: any) => { children = React.Children.map(children, (child: any) => {
...@@ -731,7 +737,8 @@ export class Head extends React.Component<HeadProps> { ...@@ -731,7 +737,8 @@ export class Head extends React.Component<HeadProps> {
} }
} }
return child return child
}) // @types/react bug. Returned value from .map will not be `null` if you pass in `[null]`
})!
if (this.props.crossOrigin) if (this.props.crossOrigin)
console.warn( console.warn(
'Warning: `Head` attribute `crossOrigin` is deprecated. https://nextjs.org/docs/messages/doc-crossorigin-deprecated' 'Warning: `Head` attribute `crossOrigin` is deprecated. https://nextjs.org/docs/messages/doc-crossorigin-deprecated'
...@@ -791,7 +798,8 @@ export class Head extends React.Component<HeadProps> { ...@@ -791,7 +798,8 @@ export class Head extends React.Component<HeadProps> {
} }
} }
return child return child
}) // @types/react bug. Returned value from .map will not be `null` if you pass in `[null]`
})!
const files: DocumentFiles = getDocumentFiles( const files: DocumentFiles = getDocumentFiles(
this.context.buildManifest, this.context.buildManifest,
......
...@@ -236,7 +236,7 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -236,7 +236,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
distDir: string distDir: string
runtime?: ServerRuntime runtime?: ServerRuntime
serverComponents?: boolean serverComponents?: boolean
crossOrigin?: string crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined
supportsDynamicHTML?: boolean supportsDynamicHTML?: boolean
isBot?: boolean isBot?: boolean
clientReferenceManifest?: ClientReferenceManifest clientReferenceManifest?: ClientReferenceManifest
......
...@@ -263,7 +263,7 @@ export type RenderOptsPartial = { ...@@ -263,7 +263,7 @@ export type RenderOptsPartial = {
runtime?: ServerRuntime runtime?: ServerRuntime
serverComponents?: boolean serverComponents?: boolean
customServer?: boolean customServer?: boolean
crossOrigin?: string crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined
images: ImageConfigComplete images: ImageConfigComplete
largePageDataBytes?: number largePageDataBytes?: number
isOnDemandRevalidate?: boolean isOnDemandRevalidate?: boolean
......
...@@ -78,7 +78,7 @@ export default function dynamic<P = {}>( ...@@ -78,7 +78,7 @@ export default function dynamic<P = {}>(
dynamicOptions: DynamicOptions<P> | Loader<P>, dynamicOptions: DynamicOptions<P> | Loader<P>,
options?: DynamicOptions<P> options?: DynamicOptions<P>
): React.ComponentType<P> { ): React.ComponentType<P> {
let loadableFn: LoadableFn<P> = Loadable let loadableFn = Loadable as LoadableFn<P>
let loadableOptions: LoadableOptions<P> = { let loadableOptions: LoadableOptions<P> = {
// A loading component is not required, so we default it // A loading component is not required, so we default it
......
...@@ -30,7 +30,9 @@ function onlyReactElement( ...@@ -30,7 +30,9 @@ function onlyReactElement(
// Adds support for React.Fragment // Adds support for React.Fragment
if (child.type === React.Fragment) { if (child.type === React.Fragment) {
return list.concat( return list.concat(
// @ts-expect-error @types/react does not remove fragments but this could also return ReactPortal[]
React.Children.toArray(child.props.children).reduce( React.Children.toArray(child.props.children).reduce(
// @ts-expect-error @types/react does not remove fragments but this could also return ReactPortal[]
( (
fragmentList: Array<React.ReactElement<any>>, fragmentList: Array<React.ReactElement<any>>,
fragmentChild: React.ReactChild fragmentChild: React.ReactChild
......
...@@ -37,7 +37,7 @@ export type HtmlProps = { ...@@ -37,7 +37,7 @@ export type HtmlProps = {
disableOptimizedLoading?: boolean disableOptimizedLoading?: boolean
styles?: React.ReactElement[] | React.ReactFragment styles?: React.ReactElement[] | React.ReactFragment
head?: Array<JSX.Element | null> head?: Array<JSX.Element | null>
crossOrigin?: string crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined
optimizeCss?: any optimizeCss?: any
optimizeFonts?: FontConfig optimizeFonts?: FontConfig
nextConfigOutput?: 'standalone' | 'export' nextConfigOutput?: 'standalone' | 'export'
......
...@@ -23,7 +23,9 @@ export default function SideEffect(props: SideEffectProps) { ...@@ -23,7 +23,9 @@ export default function SideEffect(props: SideEffectProps) {
function emitChange() { function emitChange() {
if (headManager && headManager.mountedInstances) { if (headManager && headManager.mountedInstances) {
const headElements = Children.toArray( const headElements = Children.toArray(
Array.from(headManager.mountedInstances as Set<unknown>).filter(Boolean) Array.from(headManager.mountedInstances as Set<React.ReactNode>).filter(
Boolean
)
) as React.ReactElement[] ) as React.ReactElement[]
headManager.updateHead(reduceComponentsToState(headElements, props)) headManager.updateHead(reduceComponentsToState(headElements, props))
} }
......
...@@ -47,6 +47,12 @@ declare module 'react' { ...@@ -47,6 +47,12 @@ declare module 'react' {
nonce?: string nonce?: string
} }
// <img fetchPriority=""> support
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- It's actually required for module augmentation to work.
interface ImgHTMLAttributes<T> {
fetchPriority?: 'high' | 'low' | 'auto' | undefined
}
function use<T>(promise: Promise<T> | React.Context<T>): T function use<T>(promise: Promise<T> | React.Context<T>): T
function cache<T extends Function>(fn: T): T function cache<T extends Function>(fn: T): T
} }
......
import React from 'react' import React from 'react'
type ErrorBoundaryProps = { type ErrorBoundaryProps = {
children?: React.ReactNode
onError: (error: Error, componentStack: string | null) => void onError: (error: Error, componentStack: string | null) => void
globalOverlay?: boolean globalOverlay?: boolean
isMounted?: boolean isMounted?: boolean
......
...@@ -2,6 +2,7 @@ import * as React from 'react' ...@@ -2,6 +2,7 @@ import * as React from 'react'
import { useOnClickOutside } from '../../hooks/use-on-click-outside' import { useOnClickOutside } from '../../hooks/use-on-click-outside'
export type DialogProps = { export type DialogProps = {
children?: React.ReactNode
type: 'error' | 'warning' type: 'error' | 'warning'
'aria-labelledby': string 'aria-labelledby': string
'aria-describedby': string 'aria-describedby': string
...@@ -15,7 +16,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -15,7 +16,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
...props ...props
}) { }) {
const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null) const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null)
const onDialog = React.useCallback((node) => { const onDialog = React.useCallback((node: HTMLDivElement | null) => {
setDialog(node) setDialog(node)
}, []) }, [])
useOnClickOutside(dialog, onClose) useOnClickOutside(dialog, onClose)
......
import * as React from 'react' import * as React from 'react'
export type DialogBodyProps = { export type DialogBodyProps = {
children?: React.ReactNode
className?: string className?: string
} }
......
import * as React from 'react' import * as React from 'react'
export type DialogContentProps = { export type DialogContentProps = {
children?: React.ReactNode
className?: string className?: string
} }
......
import * as React from 'react' import * as React from 'react'
export type DialogHeaderProps = { export type DialogHeaderProps = {
children?: React.ReactNode
className?: string className?: string
} }
......
...@@ -2,6 +2,7 @@ import * as React from 'react' ...@@ -2,6 +2,7 @@ import * as React from 'react'
import { CloseIcon } from '../../icons/CloseIcon' import { CloseIcon } from '../../icons/CloseIcon'
export type LeftRightDialogHeaderProps = { export type LeftRightDialogHeaderProps = {
children?: React.ReactNode
className?: string className?: string
previous: (() => void) | null previous: (() => void) | null
next: (() => void) | null next: (() => void) | null
......
...@@ -3,7 +3,11 @@ import allyTrap from './maintain--tab-focus' ...@@ -3,7 +3,11 @@ import allyTrap from './maintain--tab-focus'
import * as React from 'react' import * as React from 'react'
import { lock, unlock } from './body-locker' import { lock, unlock } from './body-locker'
export type OverlayProps = { className?: string; fixed?: boolean } export type OverlayProps = {
children?: React.ReactNode
className?: string
fixed?: boolean
}
const Overlay: React.FC<OverlayProps> = function Overlay({ const Overlay: React.FC<OverlayProps> = function Overlay({
className, className,
......
import * as React from 'react' import * as React from 'react'
export type ToastProps = { export type ToastProps = {
children?: React.ReactNode
onClick?: (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => void onClick?: (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
className?: string className?: string
} }
......
...@@ -7,6 +7,8 @@ overrides: ...@@ -7,6 +7,8 @@ overrides:
'@babel/parser': 7.18.0 '@babel/parser': 7.18.0
'@babel/types': 7.18.0 '@babel/types': 7.18.0
'@babel/traverse': 7.18.0 '@babel/traverse': 7.18.0
'@types/react': 18.0.37
'@types/react-dom': 18.0.11
importers: importers:
...@@ -45,13 +47,13 @@ importers: ...@@ -45,13 +47,13 @@ importers:
'@types/jest': 24.0.13 '@types/jest': 24.0.13
'@types/node': 14.14.31 '@types/node': 14.14.31
'@types/node-fetch': 2.6.1 '@types/node-fetch': 2.6.1
'@types/react': 16.9.17 '@types/react': 18.0.37
'@types/react-dom': 16.9.4 '@types/react-dom': 18.0.11
'@types/relay-runtime': 13.0.0 '@types/relay-runtime': 13.0.0
'@types/selenium-webdriver': 4.0.15 '@types/selenium-webdriver': 4.0.15
'@types/sharp': 0.29.3 '@types/sharp': 0.29.3
'@types/string-hash': 1.1.1 '@types/string-hash': 1.1.1
'@types/trusted-types': 2.0.2 '@types/trusted-types': 2.0.3
'@typescript-eslint/eslint-plugin': 4.29.1 '@typescript-eslint/eslint-plugin': 4.29.1
'@typescript-eslint/parser': 4.29.1 '@typescript-eslint/parser': 4.29.1
'@vercel/fetch': 6.1.1 '@vercel/fetch': 6.1.1
...@@ -226,13 +228,13 @@ importers: ...@@ -226,13 +228,13 @@ importers:
'@types/jest': 24.0.13 '@types/jest': 24.0.13
'@types/node': 14.14.31 '@types/node': 14.14.31
'@types/node-fetch': 2.6.1 '@types/node-fetch': 2.6.1
'@types/react': 16.9.17 '@types/react': 18.0.37
'@types/react-dom': 16.9.4 '@types/react-dom': 18.0.11
'@types/relay-runtime': 13.0.0 '@types/relay-runtime': 13.0.0
'@types/selenium-webdriver': 4.0.15 '@types/selenium-webdriver': 4.0.15
'@types/sharp': 0.29.3 '@types/sharp': 0.29.3
'@types/string-hash': 1.1.1 '@types/string-hash': 1.1.1
'@types/trusted-types': 2.0.2 '@types/trusted-types': 2.0.3
'@typescript-eslint/eslint-plugin': 4.29.1_qxyn66xcaddhgaahwkbomftvi4 '@typescript-eslint/eslint-plugin': 4.29.1_qxyn66xcaddhgaahwkbomftvi4
'@typescript-eslint/parser': 4.29.1_6x3mpmmsttbpxxsctsorxedanu '@typescript-eslint/parser': 4.29.1_6x3mpmmsttbpxxsctsorxedanu
'@vercel/fetch': 6.1.1_fii5qhbaymjqmfm7e2spxc5z4m '@vercel/fetch': 6.1.1_fii5qhbaymjqmfm7e2spxc5z4m
...@@ -564,9 +566,9 @@ importers: ...@@ -564,9 +566,9 @@ importers:
'@types/node-fetch': 2.6.1 '@types/node-fetch': 2.6.1
'@types/path-to-regexp': 1.7.0 '@types/path-to-regexp': 1.7.0
'@types/platform': 1.3.4 '@types/platform': 1.3.4
'@types/react': 16.9.17 '@types/react': 18.0.37
'@types/react-dom': 16.9.4 '@types/react-dom': 18.0.11
'@types/react-is': 16.7.1 '@types/react-is': 17.0.3
'@types/semver': 7.3.1 '@types/semver': 7.3.1
'@types/send': 0.14.4 '@types/send': 0.14.4
'@types/shell-quote': 1.7.1 '@types/shell-quote': 1.7.1
...@@ -784,9 +786,9 @@ importers: ...@@ -784,9 +786,9 @@ importers:
'@types/node-fetch': 2.6.1 '@types/node-fetch': 2.6.1
'@types/path-to-regexp': 1.7.0 '@types/path-to-regexp': 1.7.0
'@types/platform': 1.3.4 '@types/platform': 1.3.4
'@types/react': 16.9.17 '@types/react': 18.0.37
'@types/react-dom': 16.9.4 '@types/react-dom': 18.0.11
'@types/react-is': 16.7.1 '@types/react-is': 17.0.3
'@types/semver': 7.3.1 '@types/semver': 7.3.1
'@types/send': 0.14.4 '@types/send': 0.14.4
'@types/shell-quote': 1.7.1 '@types/shell-quote': 1.7.1
...@@ -1005,8 +1007,8 @@ importers: ...@@ -1005,8 +1007,8 @@ importers:
specifiers: specifiers:
'@types/node': ^18.11.11 '@types/node': ^18.11.11
'@types/platform': ^1.3.4 '@types/platform': ^1.3.4
'@types/react': ^18.0.26 '@types/react': 18.0.37
'@types/react-dom': ^18.0.9 '@types/react-dom': 18.0.11
'@vercel/ncc': ^0.36.0 '@vercel/ncc': ^0.36.0
'@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230420.2 '@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230420.2
'@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230420.2 '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230420.2
...@@ -1035,7 +1037,7 @@ importers: ...@@ -1035,7 +1037,7 @@ importers:
devDependencies: devDependencies:
'@types/node': 18.11.18 '@types/node': 18.11.18
'@types/platform': 1.3.4 '@types/platform': 1.3.4
'@types/react': 18.0.28 '@types/react': 18.0.37
'@types/react-dom': 18.0.11 '@types/react-dom': 18.0.11
'@vercel/ncc': 0.36.1 '@vercel/ncc': 0.36.1
find-up: 6.3.0 find-up: 6.3.0
...@@ -6037,7 +6039,7 @@ packages: ...@@ -6037,7 +6039,7 @@ packages:
react: '>=16' react: '>=16'
dependencies: dependencies:
'@types/mdx': 2.0.3 '@types/mdx': 2.0.3
'@types/react': 16.9.17 '@types/react': 18.0.37
react: 18.2.0 react: 18.2.0
/@mrmlnc/readdir-enhanced/2.2.1: /@mrmlnc/readdir-enhanced/2.2.1:
...@@ -6852,7 +6854,7 @@ packages: ...@@ -6852,7 +6854,7 @@ packages:
dependencies: dependencies:
'@babel/runtime': 7.16.7 '@babel/runtime': 7.16.7
'@testing-library/dom': 8.13.0 '@testing-library/dom': 8.13.0
'@types/react-dom': 17.0.14 '@types/react-dom': 18.0.11
react: 18.2.0 react: 18.2.0
react-dom: 18.2.0_react@18.2.0 react-dom: 18.2.0_react@18.2.0
dev: true dev: true
...@@ -7327,43 +7329,24 @@ packages: ...@@ -7327,43 +7329,24 @@ packages:
resolution: {integrity: sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==} resolution: {integrity: sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==}
dev: true dev: true
/@types/react-dom/16.9.4:
resolution: {integrity: sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw==}
dependencies:
'@types/react': 16.9.17
dev: true
/@types/react-dom/17.0.14:
resolution: {integrity: sha512-H03xwEP1oXmSfl3iobtmQ/2dHF5aBHr8aUMwyGZya6OW45G+xtdzmq6HkncefiBt5JU8DVyaWl/nWZbjZCnzAQ==}
dependencies:
'@types/react': 16.9.17
dev: true
/@types/react-dom/18.0.11: /@types/react-dom/18.0.11:
resolution: {integrity: sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==} resolution: {integrity: sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==}
dependencies: dependencies:
'@types/react': 18.0.28 '@types/react': 18.0.37
dev: true dev: true
/@types/react-is/16.7.1: /@types/react-is/17.0.3:
resolution: {integrity: sha512-dMLFD2cCsxtDgMkTydQCM0PxDq8vwc6uN5M/jRktDfYvH3nQj6pjC9OrCXS2lKlYoYTNJorI/dI8x9dpLshexQ==} resolution: {integrity: sha512-aBTIWg1emtu95bLTLx0cpkxwGW3ueZv71nE2YFBpL8k/z5czEW8yYpOo8Dp+UUAFAtKwNaOsh/ioSeQnWlZcfw==}
dependencies: dependencies:
'@types/react': 16.9.17 '@types/react': 18.0.37
dev: true dev: true
/@types/react/16.9.17: /@types/react/18.0.37:
resolution: {integrity: sha512-UP27In4fp4sWF5JgyV6pwVPAQM83Fj76JOcg02X5BZcpSu5Wx+fP9RMqc2v0ssBoQIFvD5JdKY41gjJJKmw6Bg==} resolution: {integrity: sha512-4yaZZtkRN3ZIQD3KSEwkfcik8s0SWV+82dlJot1AbGYHCzJkWP3ENBY6wYeDRmKZ6HkrgoGAmR2HqdwYGp6OEw==}
dependencies:
'@types/prop-types': 15.7.3
csstype: 2.6.8
/@types/react/18.0.28:
resolution: {integrity: sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew==}
dependencies: dependencies:
'@types/prop-types': 15.7.3 '@types/prop-types': 15.7.3
'@types/scheduler': 0.16.2 '@types/scheduler': 0.16.2
csstype: 3.0.10 csstype: 3.0.10
dev: true
/@types/relay-runtime/13.0.0: /@types/relay-runtime/13.0.0:
resolution: {integrity: sha512-yzv6F8EZPWA2rtfFP2qMluS8tsz1q4lfdYxLegCshdAjX5uqxTR2pAliATj9wrzD6OMZF4fl9aU+Y+zmSfm2EA==} resolution: {integrity: sha512-yzv6F8EZPWA2rtfFP2qMluS8tsz1q4lfdYxLegCshdAjX5uqxTR2pAliATj9wrzD6OMZF4fl9aU+Y+zmSfm2EA==}
...@@ -7394,7 +7377,6 @@ packages: ...@@ -7394,7 +7377,6 @@ packages:
/@types/scheduler/0.16.2: /@types/scheduler/0.16.2:
resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==}
dev: true
/@types/selenium-webdriver/4.0.15: /@types/selenium-webdriver/4.0.15:
resolution: {integrity: sha512-5760PIZkzhPejy3hsKAdCKe5LJygGdxLKOLxmZL9GEUcFlO5OgzM6G2EbdbvOnaw4xvUSa9Uip6Ipwkih12BPA==} resolution: {integrity: sha512-5760PIZkzhPejy3hsKAdCKe5LJygGdxLKOLxmZL9GEUcFlO5OgzM6G2EbdbvOnaw4xvUSa9Uip6Ipwkih12BPA==}
...@@ -7462,8 +7444,8 @@ packages: ...@@ -7462,8 +7444,8 @@ packages:
'@types/node': 18.11.18 '@types/node': 18.11.18
dev: true dev: true
/@types/trusted-types/2.0.2: /@types/trusted-types/2.0.3:
resolution: {integrity: sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==} resolution: {integrity: sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==}
dev: true dev: true
/@types/ua-parser-js/0.7.36: /@types/ua-parser-js/0.7.36:
...@@ -10819,12 +10801,8 @@ packages: ...@@ -10819,12 +10801,8 @@ packages:
cssom: 0.3.8 cssom: 0.3.8
dev: true dev: true
/csstype/2.6.8:
resolution: {integrity: sha512-msVS9qTuMT5zwAGCVm4mxfrZ18BNc6Csd0oJAtiFMZ1FAx1CCvy2+5MDmYoix63LM/6NDbNtodCiGYGmFgO0dA==}
/csstype/3.0.10: /csstype/3.0.10:
resolution: {integrity: sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA==} resolution: {integrity: sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA==}
dev: true
/currently-unhandled/0.4.1: /currently-unhandled/0.4.1:
resolution: {integrity: sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==} resolution: {integrity: sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment