further improve import sorting

This commit is contained in:
Robin Malfait
2023-09-11 18:47:30 +02:00
parent 76dd10ea55
commit f2179f36c0
88 changed files with 249 additions and 302 deletions
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React, { createElement, useEffect, useState } from 'react'
import {
assertActiveComboboxOption,
assertActiveElement,
@@ -1,58 +1,55 @@
import React, {
createContext,
createRef,
ElementType,
FocusEvent as ReactFocusEvent,
Fragment,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
useCallback,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
type ElementType,
type FocusEvent as ReactFocusEvent,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
} from 'react'
import { ByComparator, EnsureArray, Expand, Props } from '../../types'
import { useComputed } from '../../hooks/use-computed'
import { useControllable } from '../../hooks/use-controllable'
import { useDisposables } from '../../hooks/use-disposables'
import { useEvent } from '../../hooks/use-event'
import { useId } from '../../hooks/use-id'
import { useIsoMorphicEffect } from '../../hooks/use-iso-morphic-effect'
import { useLatestValue } from '../../hooks/use-latest-value'
import { useOutsideClick } from '../../hooks/use-outside-click'
import { useOwnerDocument } from '../../hooks/use-owner'
import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { useTrackedPointer } from '../../hooks/use-tracked-pointer'
import { useTreeWalker } from '../../hooks/use-tree-walker'
import { useWatch } from '../../hooks/use-watch'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import type { ByComparator, EnsureArray, Expand, Props } from '../../types'
import { history } from '../../utils/active-element-history'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { calculateActiveIndex, Focus } from '../../utils/calculate-active-index'
import { disposables } from '../../utils/disposables'
import { sortByDomNode } from '../../utils/focus-management'
import { objectToFormEntries } from '../../utils/form'
import { match } from '../../utils/match'
import { isMobile } from '../../utils/platform'
import {
compact,
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import { useControllable } from '../../hooks/use-controllable'
import { useOwnerDocument } from '../../hooks/use-owner'
import { useTrackedPointer } from '../../hooks/use-tracked-pointer'
import { useWatch } from '../../hooks/use-watch'
import { isMobile } from '../../utils/platform'
import { Keys } from '../keyboard'
enum ComboboxState {
@@ -1,19 +1,18 @@
import React, {
createContext,
ElementType,
ReactNode,
Ref,
useContext,
useMemo,
useState,
type ElementType,
type ReactNode,
type Ref,
} from 'react'
import { useEvent } from '../../hooks/use-event'
import { useId } from '../../hooks/use-id'
import { useIsoMorphicEffect } from '../../hooks/use-iso-morphic-effect'
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { Props } from '../../types'
import { forwardRefWithAs, HasDisplayName, RefProp, render } from '../../utils/render'
import { forwardRefWithAs, render, type HasDisplayName, type RefProp } from '../../utils/render'
// ---
@@ -1,7 +1,6 @@
import { render } from '@testing-library/react'
import React, { createElement, Fragment, useCallback, useEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { OpenClosedProvider, State } from '../../internal/open-closed'
import {
assertActiveElement,
@@ -22,7 +21,7 @@ import {
} from '../../test-utils/accessibility-assertions'
import { click, focus, Keys, mouseDrag, press, shift } from '../../test-utils/interactions'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { PropsOf } from '../../types'
import type { PropsOf } from '../../types'
import { Popover } from '../popover/popover'
import { Transition } from '../transitions/transition'
import { Dialog } from './dialog'
@@ -1,13 +1,7 @@
// WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/
import React, {
ContextType,
createContext,
createRef,
ElementType,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
RefObject,
useCallback,
useContext,
useEffect,
@@ -15,8 +9,13 @@ import React, {
useReducer,
useRef,
useState,
type ContextType,
type ElementType,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
type RefObject,
} from 'react'
import { FocusTrap } from '../../components/focus-trap/focus-trap'
import { Portal, useNestedPortals } from '../../components/portal/portal'
import { useDocumentOverflowLockedEffect } from '../../hooks/document-overflow/use-document-overflow'
@@ -32,16 +31,16 @@ import { useSyncRefs } from '../../hooks/use-sync-refs'
import { State, useOpenClosed } from '../../internal/open-closed'
import { ForcePortalRoot } from '../../internal/portal-force-root'
import { StackMessage, StackProvider } from '../../internal/stack-context'
import { Props } from '../../types'
import type { Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { match } from '../../utils/match'
import {
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import {
Description,
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React, { createElement, Suspense, useEffect, useRef } from 'react'
import {
assertActiveElement,
assertDisclosureButton,
@@ -1,37 +1,36 @@
// WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
import React, {
ContextType,
createContext,
Dispatch,
ElementType,
Fragment,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
type ContextType,
type Dispatch,
type ElementType,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
} from 'react'
import { useEvent } from '../../hooks/use-event'
import { useId } from '../../hooks/use-id'
import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
import { optionalRef, useSyncRefs } from '../../hooks/use-sync-refs'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import { Props } from '../../types'
import type { Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { match } from '../../utils/match'
import { getOwnerDocument } from '../../utils/owner'
import {
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import { startTransition } from '../../utils/start-transition'
import { Keys } from '../keyboard'
@@ -1,6 +1,5 @@
import { render, screen } from '@testing-library/react'
import React, { useRef, useState } from 'react'
import { assertActiveElement } from '../../test-utils/accessibility-assertions'
import { click, Keys, press, shift } from '../../test-utils/interactions'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
@@ -1,11 +1,10 @@
import React, {
ElementType,
FocusEvent as ReactFocusEvent,
MutableRefObject,
Ref,
useRef,
type ElementType,
type FocusEvent as ReactFocusEvent,
type MutableRefObject,
type Ref,
} from 'react'
import { useDisposables } from '../../hooks/use-disposables'
import { useEvent } from '../../hooks/use-event'
import { useEventListener } from '../../hooks/use-event-listener'
@@ -17,12 +16,12 @@ import { useSyncRefs } from '../../hooks/use-sync-refs'
import { Direction as TabDirection, useTabDirection } from '../../hooks/use-tab-direction'
import { useWatch } from '../../hooks/use-watch'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { Props } from '../../types'
import type { Props } from '../../types'
import { history } from '../../utils/active-element-history'
import { Focus, focusElement, focusIn, FocusResult } from '../../utils/focus-management'
import { match } from '../../utils/match'
import { microTask } from '../../utils/micro-task'
import { forwardRefWithAs, HasDisplayName, RefProp, render } from '../../utils/render'
import { forwardRefWithAs, render, type HasDisplayName, type RefProp } from '../../utils/render'
type Containers =
// Lazy resolved containers
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react'
import React, { ReactNode } from 'react'
import React, { type ReactNode } from 'react'
import { Label, useLabels } from './label'
jest.mock('../../hooks/use-id')
@@ -1,19 +1,18 @@
import React, {
createContext,
ElementType,
ReactNode,
Ref,
useContext,
useMemo,
useState,
type ElementType,
type ReactNode,
type Ref,
} from 'react'
import { useEvent } from '../../hooks/use-event'
import { useId } from '../../hooks/use-id'
import { useIsoMorphicEffect } from '../../hooks/use-iso-morphic-effect'
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { Props } from '../../types'
import { forwardRefWithAs, HasDisplayName, RefProp, render } from '../../utils/render'
import type { Props } from '../../types'
import { forwardRefWithAs, render, type HasDisplayName, type RefProp } from '../../utils/render'
// ---
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React, { createElement, useEffect, useState } from 'react'
import {
assertActiveElement,
assertActiveListboxOption,
@@ -1,20 +1,19 @@
import React, {
createContext,
createRef,
ElementType,
Fragment,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
useCallback,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
type ElementType,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
} from 'react'
import { useComputed } from '../../hooks/use-computed'
import { useControllable } from '../../hooks/use-controllable'
import { useDisposables } from '../../hooks/use-disposables'
@@ -29,7 +28,7 @@ import { useTextValue } from '../../hooks/use-text-value'
import { useTrackedPointer } from '../../hooks/use-tracked-pointer'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import { EnsureArray, Props } from '../../types'
import type { EnsureArray, Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { calculateActiveIndex, Focus } from '../../utils/calculate-active-index'
import { disposables } from '../../utils/disposables'
@@ -41,10 +40,10 @@ import {
compact,
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import { Keys } from '../keyboard'
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React, { createElement, useEffect } from 'react'
import {
assertActiveElement,
assertMenu,
@@ -2,20 +2,19 @@
import React, {
createContext,
createRef,
Dispatch,
ElementType,
Fragment,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
type Dispatch,
type ElementType,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
} from 'react'
import { useDisposables } from '../../hooks/use-disposables'
import { useEvent } from '../../hooks/use-event'
import { useId } from '../../hooks/use-id'
@@ -28,7 +27,7 @@ import { useTextValue } from '../../hooks/use-text-value'
import { useTrackedPointer } from '../../hooks/use-tracked-pointer'
import { useTreeWalker } from '../../hooks/use-tree-walker'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import { Props } from '../../types'
import type { Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { calculateActiveIndex, Focus } from '../../utils/calculate-active-index'
import { disposables } from '../../utils/disposables'
@@ -44,10 +43,10 @@ import { match } from '../../utils/match'
import {
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import { Keys } from '../keyboard'
@@ -1,6 +1,5 @@
import { act as _act, render } from '@testing-library/react'
import React, { createElement, Fragment, useEffect, useRef, useState } from 'react'
import ReactDOM from 'react-dom'
import {
assertActiveElement,
@@ -1,21 +1,21 @@
import React, {
ContextType,
createContext,
createRef,
Dispatch,
ElementType,
FocusEvent as ReactFocusEvent,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MouseEventHandler,
MutableRefObject,
Ref,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
useState,
type ContextType,
type Dispatch,
type ElementType,
type FocusEvent as ReactFocusEvent,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MouseEventHandler,
type MutableRefObject,
type Ref,
} from 'react'
import { useNestedPortals } from '../../components/portal/portal'
@@ -32,7 +32,7 @@ import { optionalRef, useSyncRefs } from '../../hooks/use-sync-refs'
import { Direction as TabDirection, useTabDirection } from '../../hooks/use-tab-direction'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import { Props } from '../../types'
import type { Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import {
Focus,
@@ -48,10 +48,10 @@ import { getOwnerDocument } from '../../utils/owner'
import {
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import { Keys } from '../keyboard'
@@ -1,9 +1,7 @@
import { render } from '@testing-library/react'
import React, { useRef, useState } from 'react'
import { Portal } from './portal'
import { click } from '../../test-utils/interactions'
import { Portal } from './portal'
function getPortalRoot() {
return document.getElementById('headlessui-portal-root')!
@@ -1,18 +1,17 @@
import React, {
ContextType,
createContext,
ElementType,
Fragment,
MutableRefObject,
Ref,
useContext,
useEffect,
useMemo,
useRef,
useState,
type ContextType,
type ElementType,
type MutableRefObject,
type Ref,
} from 'react'
import { createPortal } from 'react-dom'
import { useEvent } from '../../hooks/use-event'
import { useIsoMorphicEffect } from '../../hooks/use-iso-morphic-effect'
import { useOnUnmount } from '../../hooks/use-on-unmount'
@@ -20,7 +19,7 @@ import { useOwnerDocument } from '../../hooks/use-owner'
import { useServerHandoffComplete } from '../../hooks/use-server-handoff-complete'
import { optionalRef, useSyncRefs } from '../../hooks/use-sync-refs'
import { usePortalRoot } from '../../internal/portal-force-root'
import { Props } from '../../types'
import type { Props } from '../../types'
import { env } from '../../utils/env'
import { forwardRefWithAs, HasDisplayName, RefProp, render } from '../../utils/render'
@@ -1,9 +1,5 @@
import React, { createElement, useState } from 'react'
import { render } from '@testing-library/react'
import { RadioGroup } from './radio-group'
import React, { createElement, useState } from 'react'
import {
assertActiveElement,
assertFocusable,
@@ -14,6 +10,7 @@ import {
} from '../../test-utils/accessibility-assertions'
import { click, focus, Keys, press, shift } from '../../test-utils/interactions'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { RadioGroup } from './radio-group'
jest.mock('../../hooks/use-id')
@@ -1,16 +1,16 @@
import React, {
createContext,
ElementType,
FocusEvent as ReactFocusEvent,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
useContext,
useEffect,
useMemo,
useReducer,
useRef,
type ElementType,
type FocusEvent as ReactFocusEvent,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
} from 'react'
import {
@@ -30,13 +30,19 @@ import { useLatestValue } from '../../hooks/use-latest-value'
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { useTreeWalker } from '../../hooks/use-tree-walker'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { Expand, Props } from '../../types'
import type { Expand, Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { Focus, focusIn, FocusResult, sortByDomNode } from '../../utils/focus-management'
import { attemptSubmit, objectToFormEntries } from '../../utils/form'
import { match } from '../../utils/match'
import { getOwnerDocument } from '../../utils/owner'
import { compact, forwardRefWithAs, HasDisplayName, RefProp, render } from '../../utils/render'
import {
compact,
forwardRefWithAs,
render,
type HasDisplayName,
type RefProp,
} from '../../utils/render'
interface Option<T = unknown> {
id: string
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React, { useState } from 'react'
import {
assertActiveElement,
assertSwitch,
@@ -1,17 +1,16 @@
import React, {
createContext,
ElementType,
Fragment,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
Ref,
useContext,
useEffect,
useMemo,
useRef,
useState,
type ElementType,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type Ref,
} from 'react'
import { useControllable } from '../../hooks/use-controllable'
import { useDisposables } from '../../hooks/use-disposables'
import { useEvent } from '../../hooks/use-event'
@@ -19,10 +18,16 @@ import { useId } from '../../hooks/use-id'
import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { Features as HiddenFeatures, Hidden } from '../../internal/hidden'
import { Props } from '../../types'
import type { Props } from '../../types'
import { isDisabledReactIssue7711 } from '../../utils/bugs'
import { attemptSubmit } from '../../utils/form'
import { compact, forwardRefWithAs, HasDisplayName, RefProp, render } from '../../utils/render'
import {
compact,
forwardRefWithAs,
render,
type HasDisplayName,
type RefProp,
} from '../../utils/render'
import {
Description,
useDescriptions,
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React, { createElement, useState } from 'react'
import {
assertActiveElement,
assertTabs,
@@ -1,17 +1,16 @@
import React, {
createContext,
ElementType,
Fragment,
KeyboardEvent as ReactKeyboardEvent,
MouseEvent as ReactMouseEvent,
MutableRefObject,
Ref,
useContext,
useMemo,
useReducer,
useRef,
type ElementType,
type KeyboardEvent as ReactKeyboardEvent,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type Ref,
} from 'react'
import { Keys } from '../../components/keyboard'
import { useEvent } from '../../hooks/use-event'
import { useId } from '../../hooks/use-id'
@@ -21,7 +20,7 @@ import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { FocusSentinel } from '../../internal/focus-sentinel'
import { Hidden } from '../../internal/hidden'
import { Props } from '../../types'
import type { Props } from '../../types'
import { Focus, focusIn, FocusResult, sortByDomNode } from '../../utils/focus-management'
import { match } from '../../utils/match'
import { microTask } from '../../utils/micro-task'
@@ -29,10 +28,10 @@ import { getOwnerDocument } from '../../utils/owner'
import {
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
import { StableCollection, useStableCollectionIndex } from '../../utils/stable-collection'
@@ -1,11 +1,9 @@
import { act as _act, fireEvent, render } from '@testing-library/react'
import React, { Fragment, useEffect, useLayoutEffect, useRef, useState } from 'react'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { Transition } from './transition'
import { executeTimeline } from '../../test-utils/execute-timeline'
import { createSnapshot } from '../../test-utils/snapshot'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { Transition } from './transition'
let act = _act as unknown as <T>(fn: () => T) => PromiseLike<T>
@@ -1,14 +1,14 @@
import React, {
createContext,
ElementType,
Fragment,
MutableRefObject,
Ref,
useContext,
useEffect,
useMemo,
useRef,
useState,
type ElementType,
type MutableRefObject,
type Ref,
} from 'react'
import { useDisposables } from '../../hooks/use-disposables'
import { useEvent } from '../../hooks/use-event'
@@ -20,17 +20,17 @@ import { useServerHandoffComplete } from '../../hooks/use-server-handoff-complet
import { useSyncRefs } from '../../hooks/use-sync-refs'
import { useTransition } from '../../hooks/use-transition'
import { OpenClosedProvider, State, useOpenClosed } from '../../internal/open-closed'
import { Props, ReactTag } from '../../types'
import type { Props, ReactTag } from '../../types'
import { classNames } from '../../utils/class-names'
import { match } from '../../utils/match'
import {
Features,
forwardRefWithAs,
HasDisplayName,
PropsForFeatures,
RefProp,
render,
RenderStrategy,
type HasDisplayName,
type PropsForFeatures,
type RefProp,
} from '../../utils/render'
type ContainerElement = MutableRefObject<HTMLElement | null>
@@ -1,7 +1,6 @@
import { transition } from './transition'
import { reportChanges } from '../../../test-utils/report-dom-node-changes'
import { disposables } from '../../../utils/disposables'
import { transition } from './transition'
beforeEach(() => {
document.body.innerHTML = ''
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react'
import { disposables } from '../utils/disposables'
export function useDisposables() {
@@ -1,5 +1,4 @@
import { useEffect } from 'react'
import { useLatestValue } from './use-latest-value'
export function useDocumentEvent<TType extends keyof DocumentEventMap>(
@@ -1,5 +1,4 @@
import { useEffect } from 'react'
import { useLatestValue } from './use-latest-value'
export function useEventListener<TType extends keyof WindowEventMap>(
@@ -1,4 +1,4 @@
import { MutableRefObject } from 'react'
import { type MutableRefObject } from 'react'
import { useIsoMorphicEffect } from './use-iso-morphic-effect'
let originals = new Map<HTMLElement, { 'aria-hidden': string | null; inert: boolean }>()
@@ -1,5 +1,4 @@
import { MutableRefObject, useState } from 'react'
import { useState, type MutableRefObject } from 'react'
import { useIsoMorphicEffect } from './use-iso-morphic-effect'
function resolveType<TTag>(props: { type?: string; as?: TTag }) {
@@ -1,4 +1,4 @@
import { MutableRefObject, useRef } from 'react'
import { useRef, type MutableRefObject } from 'react'
import { getTextValue } from '../utils/get-text-value'
import { useEvent } from './use-event'
@@ -1,8 +1,6 @@
import { MutableRefObject } from 'react'
import { type MutableRefObject } from 'react'
import { transition } from '../components/transitions/utils/transition'
import { disposables } from '../utils/disposables'
import { useDisposables } from './use-disposables'
import { useIsMounted } from './use-is-mounted'
import { useIsoMorphicEffect } from './use-iso-morphic-effect'
@@ -1,5 +1,4 @@
import { useEffect } from 'react'
import { useLatestValue } from './use-latest-value'
export function useWindowEvent<TType extends keyof WindowEventMap>(
@@ -1,5 +1,4 @@
import React, { FocusEvent as ReactFocusEvent, useState } from 'react'
import React, { useState, type FocusEvent as ReactFocusEvent } from 'react'
import { useIsMounted } from '../hooks/use-is-mounted'
import { Features, Hidden } from './hidden'
@@ -1,6 +1,6 @@
import { ElementType, Ref } from 'react'
import { Props } from '../types'
import { forwardRefWithAs, HasDisplayName, RefProp, render } from '../utils/render'
import type { ElementType, Ref } from 'react'
import type { Props } from '../types'
import { forwardRefWithAs, render, type HasDisplayName, type RefProp } from '../utils/render'
let DEFAULT_VISUALLY_HIDDEN_TAG = 'div' as const
@@ -1,4 +1,4 @@
import React, { createContext, ReactElement, ReactNode, useContext } from 'react'
import React, { createContext, useContext, type ReactElement, type ReactNode } from 'react'
let Context = createContext<State | null>(null)
Context.displayName = 'OpenClosedContext'
@@ -1,4 +1,4 @@
import React, { createContext, ReactNode, useContext } from 'react'
import React, { createContext, useContext, type ReactNode } from 'react'
let ForcePortalRootContext = createContext(false)
@@ -1,4 +1,4 @@
import React, { createContext, MutableRefObject, ReactNode, useContext } from 'react'
import React, { createContext, useContext, type MutableRefObject, type ReactNode } from 'react'
import { useEvent } from '../hooks/use-event'
import { useIsoMorphicEffect } from '../hooks/use-iso-morphic-effect'
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import snapshotDiff from 'snapshot-diff'
import { disposables } from '../utils/disposables'
import { reportChanges } from './report-dom-node-changes'
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
import React from 'react'
import { Keys, shift, type } from './interactions'
type Events = 'onKeyDown' | 'onKeyUp' | 'onKeyPress' | 'onClick' | 'onBlur' | 'onFocus'
@@ -1,4 +1,4 @@
import { MutableRefObject, useLayoutEffect, useRef } from 'react'
import { useLayoutEffect, useRef, type MutableRefObject } from 'react'
export function createSnapshot() {
let snapshots: HTMLElement[] = []
@@ -1,5 +1,11 @@
import { cleanup, render, RenderOptions, RenderResult, screen } from '@testing-library/react'
import React, { ReactElement } from 'react'
import {
cleanup,
render,
screen,
type RenderOptions,
type RenderResult,
} from '@testing-library/react'
import React, { type ReactElement } from 'react'
import { renderToString } from 'react-dom/server'
import { env } from '../utils/env'
+1 -1
View File
@@ -1,4 +1,4 @@
import { JSXElementConstructor, ReactElement, ReactNode } from 'react'
import type { JSXElementConstructor, ReactElement, ReactNode } from 'react'
export type ReactTag = keyof JSX.IntrinsicElements | JSXElementConstructor<any>
@@ -1,4 +1,4 @@
import { MutableRefObject } from 'react'
import { type MutableRefObject } from 'react'
import { env } from './env'
export function getOwnerDocument<T extends Element | MutableRefObject<Element | null>>(
@@ -1,8 +1,7 @@
import { getByTestId, prettyDOM, render as testRender } from '@testing-library/react'
import React, { createRef, ElementType, Fragment, Ref } from 'react'
import React, { createRef, Fragment, type ElementType, type Ref } from 'react'
import { suppressConsoleLogs } from '../test-utils/suppress-console-logs'
import { Expand, Props } from '../types'
import type { Expand, Props } from '../types'
import { Features, PropsForFeatures, render } from './render'
function contents(id = 'wrapper') {
@@ -1,14 +1,14 @@
import {
cloneElement,
createElement,
ElementType,
forwardRef,
Fragment,
isValidElement,
ReactElement,
Ref,
type ElementType,
type ReactElement,
type Ref,
} from 'react'
import { Expand, Props, XOR, __ } from '../types'
import type { Expand, Props, XOR, __ } from '../types'
import { classNames } from './class-names'
import { match } from './match'
@@ -1,24 +1,23 @@
import {
computed,
ComputedRef,
defineComponent,
Fragment,
h,
inject,
InjectionKey,
nextTick,
onMounted,
onUnmounted,
PropType,
provide,
ref,
Ref,
toRaw,
UnwrapNestedRefs,
watch,
watchEffect,
type ComputedRef,
type InjectionKey,
type PropType,
type Ref,
type UnwrapNestedRefs,
} from 'vue'
import { useControllable } from '../../hooks/use-controllable'
import { useId } from '../../hooks/use-id'
import { useOutsideClick } from '../../hooks/use-outside-click'
@@ -1,12 +1,10 @@
import prettier from 'prettier'
import { defineComponent, h, nextTick, ref } from 'vue'
import { render } from '../../test-utils/vue-testing-library'
import { Description, useDescriptions } from './description'
import { getByText } from '../../test-utils/accessibility-assertions'
import { html } from '../../test-utils/html'
import { click } from '../../test-utils/interactions'
import { render } from '../../test-utils/vue-testing-library'
import { Description, useDescriptions } from './description'
function format(input: Element | null | string) {
if (input === null) throw new Error('input is null')
@@ -1,17 +1,16 @@
import {
computed,
ComputedRef,
defineComponent,
inject,
InjectionKey,
onMounted,
onUnmounted,
provide,
ref,
Ref,
unref,
type ComputedRef,
type InjectionKey,
type Ref,
} from 'vue'
import { useId } from '../../hooks/use-id'
import { render } from '../../utils/render'
@@ -1,24 +1,13 @@
import {
computed,
ConcreteComponent,
defineComponent,
h,
nextTick,
onMounted,
PropType,
ref,
type ConcreteComponent,
type PropType,
} from 'vue'
import { createRenderTemplate, render } from '../../test-utils/vue-testing-library'
import {
Dialog,
DialogBackdrop,
DialogDescription,
DialogOverlay,
DialogPanel,
DialogTitle,
} from './dialog'
import { State, useOpenClosedProvider } from '../../internal/open-closed'
import {
assertActiveElement,
@@ -40,8 +29,17 @@ import {
import { html } from '../../test-utils/html'
import { click, focus, Keys, mouseDrag, press, shift } from '../../test-utils/interactions'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { createRenderTemplate, render } from '../../test-utils/vue-testing-library'
import { Popover, PopoverButton, PopoverPanel } from '../popover/popover'
import { TransitionRoot } from '../transitions/transition'
import {
Dialog,
DialogBackdrop,
DialogDescription,
DialogOverlay,
DialogPanel,
DialogTitle,
} from './dialog'
// @ts-expect-error
global.ResizeObserver = class FakeResizeObserver {
@@ -4,17 +4,16 @@ import {
defineComponent,
h,
inject,
InjectionKey,
nextTick,
onMounted,
onUnmounted,
PropType,
provide,
ref,
Ref,
watchEffect,
type InjectionKey,
type PropType,
type Ref,
} from 'vue'
import { FocusTrap } from '../../components/focus-trap/focus-trap'
import { useDocumentOverflowLockedEffect } from '../../hooks/document-overflow/use-document-overflow'
import { useEventListener } from '../../hooks/use-event-listener'
@@ -3,15 +3,14 @@ import {
computed,
defineComponent,
inject,
InjectionKey,
onMounted,
onUnmounted,
provide,
ref,
Ref,
watchEffect,
type InjectionKey,
type Ref,
} from 'vue'
import { useId } from '../../hooks/use-id'
import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
import { State, useOpenClosed, useOpenClosedProvider } from '../../internal/open-closed'
@@ -1,5 +1,4 @@
import { onMounted, ref } from 'vue'
import { assertActiveElement, getByText } from '../../test-utils/accessibility-assertions'
import { html } from '../../test-utils/html'
import { click, Keys, press, shift } from '../../test-utils/interactions'
@@ -5,11 +5,11 @@ import {
h,
onMounted,
onUnmounted,
PropType,
ref,
Ref,
watch,
watchEffect,
type PropType,
type Ref,
} from 'vue'
import { useEventListener } from '../../hooks/use-event-listener'
import { Direction as TabDirection, useTabDirection } from '../../hooks/use-tab-direction'
@@ -1,12 +1,10 @@
import prettier from 'prettier'
import { defineComponent, h, nextTick, ref } from 'vue'
import { render } from '../../test-utils/vue-testing-library'
import { Label, useLabels } from './label'
import { getByText } from '../../test-utils/accessibility-assertions'
import { html } from '../../test-utils/html'
import { click } from '../../test-utils/interactions'
import { render } from '../../test-utils/vue-testing-library'
import { Label, useLabels } from './label'
function format(input: Element | null | string) {
if (input === null) throw new Error('input is null')
@@ -1,16 +1,15 @@
import {
computed,
ComputedRef,
defineComponent,
inject,
InjectionKey,
onMounted,
onUnmounted,
provide,
ref,
unref,
type ComputedRef,
type InjectionKey,
} from 'vue'
import { useId } from '../../hooks/use-id'
import { render } from '../../utils/render'
@@ -1,24 +1,23 @@
import {
computed,
ComputedRef,
defineComponent,
Fragment,
h,
inject,
InjectionKey,
nextTick,
onMounted,
onUnmounted,
PropType,
provide,
ref,
Ref,
toRaw,
UnwrapNestedRefs,
watch,
watchEffect,
type ComputedRef,
type InjectionKey,
type PropType,
type Ref,
type UnwrapNestedRefs,
} from 'vue'
import { useControllable } from '../../hooks/use-controllable'
import { useId } from '../../hooks/use-id'
import { useOutsideClick } from '../../hooks/use-outside-click'
@@ -1,17 +1,17 @@
import {
computed,
ComputedRef,
defineComponent,
inject,
InjectionKey,
nextTick,
onMounted,
onUnmounted,
provide,
ref,
Ref,
UnwrapNestedRefs,
watchEffect,
type ComputedRef,
type InjectionKey,
type Ref,
type UnwrapNestedRefs,
} from 'vue'
import { useId } from '../../hooks/use-id'
import { useOutsideClick } from '../../hooks/use-outside-click'
@@ -1,20 +1,19 @@
import {
ComponentPublicInstance,
computed,
defineComponent,
Fragment,
h,
inject,
InjectionKey,
onMounted,
onUnmounted,
provide,
ref,
Ref,
shallowRef,
watchEffect,
type ComponentPublicInstance,
type InjectionKey,
type Ref,
} from 'vue'
import { useNestedPortals } from '../../components/portal/portal'
import { useEventListener } from '../../hooks/use-event-listener'
import { useId } from '../../hooks/use-id'
@@ -1,5 +1,4 @@
import { ComponentOptionsWithoutProps, createSSRApp, defineComponent, h, nextTick, ref } from 'vue'
import { renderToString } from 'vue/server-renderer'
import { html } from '../../test-utils/html'
import { click } from '../../test-utils/interactions'
@@ -4,17 +4,17 @@ import {
getCurrentInstance,
h,
inject,
InjectionKey,
onMounted,
onUnmounted,
PropType,
provide,
reactive,
ref,
Ref,
Teleport,
watch,
watchEffect,
type InjectionKey,
type PropType,
type Ref,
} from 'vue'
import { usePortalRoot } from '../../internal/portal-force-root'
import { dom } from '../../utils/dom'
@@ -1,8 +1,4 @@
import { defineComponent, nextTick, reactive, ref, watch } from 'vue'
import { createRenderTemplate, render } from '../../test-utils/vue-testing-library'
import { RadioGroup, RadioGroupDescription, RadioGroupLabel, RadioGroupOption } from './radio-group'
import {
assertActiveElement,
assertFocusable,
@@ -14,6 +10,8 @@ import {
import { html } from '../../test-utils/html'
import { click, Keys, press, shift } from '../../test-utils/interactions'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { createRenderTemplate, render } from '../../test-utils/vue-testing-library'
import { RadioGroup, RadioGroupDescription, RadioGroupLabel, RadioGroupOption } from './radio-group'
jest.mock('../../hooks/use-id')
@@ -4,15 +4,15 @@ import {
Fragment,
h,
inject,
InjectionKey,
onMounted,
onUnmounted,
provide,
ref,
Ref,
toRaw,
UnwrapRef,
watch,
type InjectionKey,
type Ref,
type UnwrapRef,
} from 'vue'
import { useControllable } from '../../hooks/use-controllable'
import { useId } from '../../hooks/use-id'
@@ -1,6 +1,4 @@
import { defineComponent, h, ref, watch } from 'vue'
import { createRenderTemplate } from '../../test-utils/vue-testing-library'
import {
assertActiveElement,
assertSwitch,
@@ -12,6 +10,7 @@ import {
import { html } from '../../test-utils/html'
import { click, Keys, mouseEnter, press } from '../../test-utils/interactions'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { createRenderTemplate } from '../../test-utils/vue-testing-library'
import { Switch, SwitchDescription, SwitchGroup, SwitchLabel } from './switch'
jest.mock('../../hooks/use-id')
@@ -4,14 +4,13 @@ import {
Fragment,
h,
inject,
InjectionKey,
onMounted,
provide,
ref,
Ref,
watch,
type InjectionKey,
type Ref,
} from 'vue'
import { useControllable } from '../../hooks/use-controllable'
import { useId } from '../../hooks/use-id'
import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
@@ -4,16 +4,15 @@ import {
Fragment,
h,
inject,
InjectionKey,
onMounted,
onUnmounted,
provide,
ref,
Ref,
watch,
watchEffect,
type InjectionKey,
type Ref,
} from 'vue'
import { useId } from '../../hooks/use-id'
import { useResolveButtonType } from '../../hooks/use-resolve-button-type'
import { FocusSentinel } from '../../internal/focus-sentinel'
@@ -1,11 +1,9 @@
import { defineComponent, onMounted, ref } from 'vue'
import { createRenderTemplate, fireEvent } from '../../test-utils/vue-testing-library'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { TransitionChild, TransitionRoot } from './transition'
import { executeTimeline } from '../../test-utils/execute-timeline'
import { html } from '../../test-utils/html'
import { suppressConsoleLogs } from '../../test-utils/suppress-console-logs'
import { createRenderTemplate, fireEvent } from '../../test-utils/vue-testing-library'
import { TransitionChild, TransitionRoot } from './transition'
jest.mock('../../hooks/use-id')
@@ -1,24 +1,20 @@
import {
computed,
ConcreteComponent,
defineComponent,
h,
inject,
InjectionKey,
normalizeClass,
onMounted,
onUnmounted,
provide,
ref,
Ref,
watch,
watchEffect,
type ConcreteComponent,
type InjectionKey,
type Ref,
} from 'vue'
import { useId } from '../../hooks/use-id'
import { env } from '../../utils/env'
import { match } from '../../utils/match'
import {
hasOpenClosed,
State,
@@ -26,6 +22,8 @@ import {
useOpenClosedProvider,
} from '../../internal/open-closed'
import { dom } from '../../utils/dom'
import { env } from '../../utils/env'
import { match } from '../../utils/match'
import { Features, omit, render, RenderStrategy } from '../../utils/render'
import { Reason, transition } from './utils/transition'
@@ -1,7 +1,6 @@
import { Reason, transition } from './transition'
import { reportChanges } from '../../../test-utils/report-dom-node-changes'
import { disposables } from '../../../utils/disposables'
import { Reason, transition } from './transition'
beforeEach(() => {
document.body.innerHTML = ''
@@ -1,5 +1,4 @@
import { ComponentOptionsWithoutProps, computed, defineComponent, nextTick, ref } from 'vue'
import { assertInert, assertNotInert, getByText } from '../test-utils/accessibility-assertions'
import { html } from '../test-utils/html'
import { click } from '../test-utils/interactions'
@@ -1,4 +1,4 @@
import { computed, ComputedRef, Ref, ref } from 'vue'
import { computed, ref, type ComputedRef, type Ref } from 'vue'
import { dom } from '../utils/dom'
import { FocusableMode, isFocusableElement } from '../utils/focus-management'
import { isMobile } from '../utils/platform'
@@ -1,4 +1,4 @@
import { ComponentPublicInstance, onMounted, ref, Ref, watchEffect } from 'vue'
import { onMounted, ref, watchEffect, type ComponentPublicInstance, type Ref } from 'vue'
import { dom } from '../utils/dom'
function resolveType(type: unknown, as: string | object) {
@@ -1,4 +1,4 @@
import { h, ref, Ref } from 'vue'
import { h, ref, type Ref } from 'vue'
import { Features as HiddenFeatures, Hidden } from '../internal/hidden'
import { dom } from '../utils/dom'
import { getOwnerDocument } from '../utils/owner'
@@ -1,4 +1,4 @@
import { ComputedRef, watchEffect } from 'vue'
import { watchEffect, type ComputedRef } from 'vue'
import { getOwnerDocument } from '../utils/owner'
type AcceptNode = (
@@ -1,5 +1,4 @@
import { defineComponent, h, ref } from 'vue'
import { Features, Hidden } from './hidden'
export let FocusSentinel = defineComponent({
@@ -1,4 +1,4 @@
import { defineComponent, PropType } from 'vue'
import { defineComponent, type PropType } from 'vue'
import { render } from '../utils/render'
export enum Features {
@@ -1,4 +1,4 @@
import { inject, InjectionKey, provide, Ref } from 'vue'
import { inject, provide, type InjectionKey, type Ref } from 'vue'
let Context = Symbol('Context') as InjectionKey<Ref<State>>
@@ -1,4 +1,4 @@
import { defineComponent, inject, InjectionKey, provide } from 'vue'
import { defineComponent, inject, provide, type InjectionKey } from 'vue'
import { render } from '../utils/render'
let ForcePortalRootContext = Symbol('ForcePortalRootContext') as InjectionKey<Boolean>
@@ -1,4 +1,4 @@
import { inject, InjectionKey, onMounted, onUnmounted, provide, Ref, watch } from 'vue'
import { inject, onMounted, onUnmounted, provide, watch, type InjectionKey, type Ref } from 'vue'
type OnUpdate = (message: StackMessage, type: string, element: Ref<HTMLElement | null>) => void
@@ -1,9 +1,8 @@
import snapshotDiff from 'snapshot-diff'
import { defineComponent } from 'vue'
import { render } from './vue-testing-library'
import { disposables } from '../utils/disposables'
import { reportChanges } from './report-dom-node-changes'
import { render } from './vue-testing-library'
function redentSnapshot(input: string) {
let minSpaces = Infinity
@@ -1,7 +1,6 @@
import { render } from './vue-testing-library'
import { ComponentOptionsWithoutProps, defineComponent, h } from 'vue'
import { defineComponent, h, type ComponentOptionsWithoutProps } from 'vue'
import { Keys, shift, type } from './interactions'
import { render } from './vue-testing-library'
type Events = 'onKeydown' | 'onKeyup' | 'onKeypress' | 'onClick' | 'onBlur' | 'onFocus'
let events: Events[] = ['onKeydown', 'onKeyup', 'onKeypress', 'onClick', 'onBlur', 'onFocus']
@@ -1,6 +1,6 @@
import { fireEvent, logDOM, screen } from '@testing-library/dom'
import { mount } from '@vue/test-utils'
import { ComponentOptionsWithoutProps, defineComponent } from 'vue'
import { defineComponent, type ComponentOptionsWithoutProps } from 'vue'
let mountedWrappers = new Set()
+1 -1
View File
@@ -1,4 +1,4 @@
import { Ref } from 'vue'
import { type Ref } from 'vue'
import { dom } from './dom'
import { env } from './env'
@@ -1,7 +1,6 @@
import { defineComponent } from 'vue'
import { createRenderTemplate } from '../test-utils/vue-testing-library'
import { html } from '../test-utils/html'
import { createRenderTemplate } from '../test-utils/vue-testing-library'
import { render } from './render'
let Dummy = defineComponent({
+1 -1
View File
@@ -1,4 +1,4 @@
import { cloneVNode, Fragment, h, Slots, VNode } from 'vue'
import { cloneVNode, Fragment, h, type Slots, type VNode } from 'vue'
import { match } from './match'
export enum Features {