diff --git a/.eslintrc.js b/.eslintrc.js index 3aa1d6ba168..d68a228bbeb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -53,6 +53,7 @@ module.exports = { }, { files: ['**/test/**', '**/stories/**', '**/docs/**', '**/chromatic/**', '**/__tests__/**'], rules: { + 'rsp-rules/no-react-key': [ERROR], 'rsp-rules/act-events-test': ERROR, 'rsp-rules/no-getByRole-toThrow': ERROR, 'rulesdir/imports': OFF, @@ -182,7 +183,8 @@ module.exports = { 'react-hooks/exhaustive-deps': WARN, // custom rules - 'rulesdir/sort-imports': [ERROR], + 'rsp-rules/no-react-key': [ERROR], + 'rsp-rules/sort-imports': [ERROR], 'rulesdir/imports': [ERROR], 'rulesdir/useLayoutEffectRule': [ERROR], 'rulesdir/pure-render': [ERROR], diff --git a/examples/rsp-cra-18/src/App.tsx b/examples/rsp-cra-18/src/App.tsx index a9c7e980683..148c1e7c22c 100644 --- a/examples/rsp-cra-18/src/App.tsx +++ b/examples/rsp-cra-18/src/App.tsx @@ -46,7 +46,7 @@ function App() { {(item: any) => ( {(key) => { - return {item[key.toString()]}; + return {item[key]}; }} ) } diff --git a/examples/rsp-cra-18/src/Journal.tsx b/examples/rsp-cra-18/src/Journal.tsx index 99938fc1fcc..f00e30e63ee 100644 --- a/examples/rsp-cra-18/src/Journal.tsx +++ b/examples/rsp-cra-18/src/Journal.tsx @@ -1,9 +1,9 @@ -import {Key} from 'react' +import {Key} from '@react-types/shared'; interface Journal{ - rate: Key, - description: string, + rate: Key, + description: string, id: number } -export default Journal \ No newline at end of file +export default Journal diff --git a/examples/rsp-cra-18/src/JournalEntries.tsx b/examples/rsp-cra-18/src/JournalEntries.tsx index 8e2d9a5c8ec..eea6d20f619 100644 --- a/examples/rsp-cra-18/src/JournalEntries.tsx +++ b/examples/rsp-cra-18/src/JournalEntries.tsx @@ -6,7 +6,7 @@ function JournalEntries(props : {list : Journal[]}){ const element = props.list.map(item => (
  • -

    Your day was: {item.rate.toString()}

    +

    Your day was: {item.rate}

    {item.description}

  • diff --git a/examples/rsp-next-ts-17/components/Section.tsx b/examples/rsp-next-ts-17/components/Section.tsx index c4ce0ca090c..a0d2372fbb8 100644 --- a/examples/rsp-next-ts-17/components/Section.tsx +++ b/examples/rsp-next-ts-17/components/Section.tsx @@ -3,7 +3,7 @@ import React from "react"; interface SectionProps { title: string; - children: JSX.Element | JSX.Element[]; + children: React.JSX.Element | React.JSX.Element[]; } export default function Section(props: SectionProps) { diff --git a/examples/rsp-next-ts/components/Section.tsx b/examples/rsp-next-ts/components/Section.tsx index c4ce0ca090c..a0d2372fbb8 100644 --- a/examples/rsp-next-ts/components/Section.tsx +++ b/examples/rsp-next-ts/components/Section.tsx @@ -3,7 +3,7 @@ import React from "react"; interface SectionProps { title: string; - children: JSX.Element | JSX.Element[]; + children: React.JSX.Element | React.JSX.Element[]; } export default function Section(props: SectionProps) { diff --git a/package.json b/package.json index e34683de483..8d7728913fe 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "copyrights": "babel-node --presets @babel/env ./scripts/addHeaders.js", "build:icons": "babel-node --presets @babel/env ./scripts/buildIcons.js", "clean:icons": "babel-node --presets @babel/env ./scripts/cleanIcons.js", - "postinstall": "yarn build:icons && patch-package", + "postinstall": "patch-package && yarn build:icons", "plop": "plop --plopfile scripts/plopfile.js", "chromatic": "NODE_ENV=production CHROMATIC=1 chromatic --project-token $CHROMATIC_PROJECT_TOKEN --build-script-name 'build:chromatic'", "chromatic:forced-colors": "NODE_ENV=production CHROMATIC=1 chromatic --project-token $CHROMATIC_FC_PROJECT_TOKEN --build-script-name 'build:chromatic-fc'", @@ -98,10 +98,10 @@ "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", - "@types/react": "^18.2.7", + "@types/react": "^18.2.28", "@types/storybook__react": "^5.2.1", - "@typescript-eslint/eslint-plugin": "^5.40.0", - "@typescript-eslint/parser": "^5.40.0", + "@typescript-eslint/eslint-plugin": "^6.7.5", + "@typescript-eslint/parser": "^6.7.5", "autoprefixer": "^9.6.0", "axe-core": "^4.6.3", "axe-playwright": "^1.1.11", @@ -169,7 +169,7 @@ "tailwindcss": "^3.2.2", "tailwindcss-animate": "^1.0.7", "tempy": "^0.5.0", - "typescript": "5.0.4", + "typescript": "5.2.2", "typescript-strict-plugin": "^2.0.0", "verdaccio": "^5.13.0", "walk-object": "^4.0.0", @@ -178,6 +178,7 @@ }, "resolutions": { "@babel/core": "7.12.10", + "@types/react": "18.2.28", "postcss": "8.4.24", "postcss-custom-properties": "13.2.0", "postcss-import": "15.1.0", diff --git a/packages/@react-aria/actiongroup/src/useActionGroupItem.ts b/packages/@react-aria/actiongroup/src/useActionGroupItem.ts index 4c999cc8803..86d9de06cff 100644 --- a/packages/@react-aria/actiongroup/src/useActionGroupItem.ts +++ b/packages/@react-aria/actiongroup/src/useActionGroupItem.ts @@ -10,11 +10,11 @@ * governing permissions and limitations under the License. */ -import {DOMAttributes, FocusableElement} from '@react-types/shared'; -import {Key, RefObject, useEffect} from 'react'; +import {DOMAttributes, FocusableElement, Key} from '@react-types/shared'; import {ListState} from '@react-stately/list'; import {mergeProps, useEffectEvent} from '@react-aria/utils'; import {PressProps} from '@react-aria/interactions'; +import {RefObject, useEffect} from 'react'; export interface AriaActionGroupItemProps { key: Key diff --git a/packages/@react-aria/dnd/src/DragPreview.tsx b/packages/@react-aria/dnd/src/DragPreview.tsx index 4b7b7668905..95949c492db 100644 --- a/packages/@react-aria/dnd/src/DragPreview.tsx +++ b/packages/@react-aria/dnd/src/DragPreview.tsx @@ -15,12 +15,12 @@ import {flushSync} from 'react-dom'; import React, {RefObject, useImperativeHandle, useRef, useState} from 'react'; export interface DragPreviewProps { - children: (items: DragItem[]) => JSX.Element + children: (items: DragItem[]) => React.JSX.Element } function DragPreview(props: DragPreviewProps, ref: RefObject) { let render = props.children; - let [children, setChildren] = useState(null); + let [children, setChildren] = useState(null); let domRef = useRef(null); useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement) => void) => { diff --git a/packages/@react-aria/dnd/src/useDraggableItem.ts b/packages/@react-aria/dnd/src/useDraggableItem.ts index 7ff860673bc..e0a7f847c47 100644 --- a/packages/@react-aria/dnd/src/useDraggableItem.ts +++ b/packages/@react-aria/dnd/src/useDraggableItem.ts @@ -13,9 +13,10 @@ import {AriaButtonProps} from '@react-types/button'; import {clearGlobalDnDState, isInternalDropOperation, setDraggingKeys, useDragModality} from './utils'; import {DraggableCollectionState} from '@react-stately/dnd'; -import {HTMLAttributes, Key} from 'react'; +import {HTMLAttributes} from 'react'; // @ts-ignore import intlMessages from '../intl/*.json'; +import {Key} from '@react-types/shared'; import {useDescription} from '@react-aria/utils'; import {useDrag} from './useDrag'; import {useLocalizedStringFormatter} from '@react-aria/i18n'; diff --git a/packages/@react-aria/dnd/src/useDropIndicator.ts b/packages/@react-aria/dnd/src/useDropIndicator.ts index e3a11908be3..8bcf6c6b5e7 100644 --- a/packages/@react-aria/dnd/src/useDropIndicator.ts +++ b/packages/@react-aria/dnd/src/useDropIndicator.ts @@ -12,9 +12,9 @@ import * as DragManager from './DragManager'; import {DroppableCollectionState} from '@react-stately/dnd'; -import {DropTarget} from '@react-types/shared'; +import {DropTarget, Key} from '@react-types/shared'; import {getDroppableCollectionId} from './utils'; -import {HTMLAttributes, Key, RefObject} from 'react'; +import {HTMLAttributes, RefObject} from 'react'; // @ts-ignore import intlMessages from '../intl/*.json'; import {useDroppableItem} from './useDroppableItem'; diff --git a/packages/@react-aria/dnd/src/useDroppableCollection.ts b/packages/@react-aria/dnd/src/useDroppableCollection.ts index 058fb58356c..ee1091764ae 100644 --- a/packages/@react-aria/dnd/src/useDroppableCollection.ts +++ b/packages/@react-aria/dnd/src/useDroppableCollection.ts @@ -28,12 +28,13 @@ import { DropPosition, DropTarget, DropTargetDelegate, + Key, KeyboardDelegate, Node } from '@react-types/shared'; import * as DragManager from './DragManager'; import {DroppableCollectionState} from '@react-stately/dnd'; -import {HTMLAttributes, Key, RefObject, useCallback, useEffect, useRef} from 'react'; +import {HTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react'; import {mergeProps, useId, useLayoutEffect} from '@react-aria/utils'; import {setInteractionModality} from '@react-aria/interactions'; import {useAutoScroll} from './useAutoScroll'; diff --git a/packages/@react-aria/dnd/src/utils.ts b/packages/@react-aria/dnd/src/utils.ts index c46e495dc8a..3ee71a4a488 100644 --- a/packages/@react-aria/dnd/src/utils.ts +++ b/packages/@react-aria/dnd/src/utils.ts @@ -11,10 +11,10 @@ */ import {CUSTOM_DRAG_TYPE, DROP_OPERATION, GENERIC_TYPE, NATIVE_DRAG_TYPES} from './constants'; -import {DirectoryDropItem, DragItem, DropItem, FileDropItem, DragTypes as IDragTypes, TextDropItem} from '@react-types/shared'; +import {DirectoryDropItem, DragItem, DropItem, FileDropItem, DragTypes as IDragTypes, Key, TextDropItem} from '@react-types/shared'; import {DroppableCollectionState} from '@react-stately/dnd'; import {getInteractionModality, useInteractionModality} from '@react-aria/interactions'; -import {Key, RefObject} from 'react'; +import {RefObject} from 'react'; interface DroppableCollectionMap { id: string, diff --git a/packages/@react-aria/dnd/stories/Reorderable.tsx b/packages/@react-aria/dnd/stories/Reorderable.tsx index 0ace6f4d7a6..e5aef3c9d59 100644 --- a/packages/@react-aria/dnd/stories/Reorderable.tsx +++ b/packages/@react-aria/dnd/stories/Reorderable.tsx @@ -20,7 +20,7 @@ import {FocusRing} from '@react-aria/focus'; import Folder from '@spectrum-icons/workflow/Folder'; import {GridCollection, useGridState} from '@react-stately/grid'; import {Item} from '@react-stately/collections'; -import {ItemDropTarget} from '@react-types/shared'; +import {ItemDropTarget, Key} from '@react-types/shared'; import {ListDropTargetDelegate} from '@react-aria/dnd'; import {ListKeyboardDelegate} from '@react-aria/selection'; import React, {useRef} from 'react'; @@ -45,7 +45,7 @@ export function ReorderableGridExample(props) { ] }); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { if (target.dropPosition === 'before') { list.moveBefore(target.key, keys); } else { diff --git a/packages/@react-aria/grid/src/GridKeyboardDelegate.ts b/packages/@react-aria/grid/src/GridKeyboardDelegate.ts index 87526277f18..7f6a8d264ea 100644 --- a/packages/@react-aria/grid/src/GridKeyboardDelegate.ts +++ b/packages/@react-aria/grid/src/GridKeyboardDelegate.ts @@ -10,11 +10,11 @@ * governing permissions and limitations under the License. */ -import {Direction, KeyboardDelegate, Node} from '@react-types/shared'; +import {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared'; import {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections'; import {GridCollection} from '@react-types/grid'; -import {Key, RefObject} from 'react'; import {Layout, Rect} from '@react-stately/virtualizer'; +import {RefObject} from 'react'; export interface GridKeyboardDelegateOptions { collection: C, diff --git a/packages/@react-aria/grid/src/useGrid.ts b/packages/@react-aria/grid/src/useGrid.ts index d9b64b6f5b4..b1d8efdbb9c 100644 --- a/packages/@react-aria/grid/src/useGrid.ts +++ b/packages/@react-aria/grid/src/useGrid.ts @@ -10,13 +10,13 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, DOMAttributes, DOMProps, KeyboardDelegate} from '@react-types/shared'; +import {AriaLabelingProps, DOMAttributes, DOMProps, Key, KeyboardDelegate} from '@react-types/shared'; import {filterDOMProps, mergeProps, useId} from '@react-aria/utils'; import {GridCollection} from '@react-types/grid'; import {GridKeyboardDelegate} from './GridKeyboardDelegate'; import {gridMap} from './utils'; import {GridState} from '@react-stately/grid'; -import {Key, RefObject, useCallback, useMemo} from 'react'; +import {RefObject, useCallback, useMemo} from 'react'; import {useCollator, useLocale} from '@react-aria/i18n'; import {useGridSelectionAnnouncement} from './useGridSelectionAnnouncement'; import {useHasTabbableChild} from '@react-aria/focus'; diff --git a/packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts b/packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts index a9308d87ece..35fcf9368a1 100644 --- a/packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts +++ b/packages/@react-aria/grid/src/useGridSelectionAnnouncement.ts @@ -11,12 +11,12 @@ */ import {announce} from '@react-aria/live-announcer'; -import {Collection, Node, Selection} from '@react-types/shared'; +import {Collection, Key, Node, Selection} from '@react-types/shared'; // @ts-ignore import intlMessages from '../intl/*.json'; -import {Key, useRef} from 'react'; import {SelectionManager} from '@react-stately/selection'; import {useLocalizedStringFormatter} from '@react-aria/i18n'; +import {useRef} from 'react'; import {useUpdateEffect} from '@react-aria/utils'; export interface GridSelectionAnnouncementProps { diff --git a/packages/@react-aria/grid/src/useGridSelectionCheckbox.ts b/packages/@react-aria/grid/src/useGridSelectionCheckbox.ts index 8768438952d..651bb441236 100644 --- a/packages/@react-aria/grid/src/useGridSelectionCheckbox.ts +++ b/packages/@react-aria/grid/src/useGridSelectionCheckbox.ts @@ -3,7 +3,7 @@ import {GridCollection} from '@react-types/grid'; import {GridState} from '@react-stately/grid'; // @ts-ignore import intlMessages from '../intl/*.json'; -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {useId} from '@react-aria/utils'; import {useLocalizedStringFormatter} from '@react-aria/i18n'; diff --git a/packages/@react-aria/grid/src/utils.ts b/packages/@react-aria/grid/src/utils.ts index 9165373f089..169d3c168c2 100644 --- a/packages/@react-aria/grid/src/utils.ts +++ b/packages/@react-aria/grid/src/utils.ts @@ -12,8 +12,7 @@ import type {GridCollection} from '@react-types/grid'; import type {GridState} from '@react-stately/grid'; -import {Key} from 'react'; -import type {KeyboardDelegate} from '@react-types/shared'; +import type {Key, KeyboardDelegate} from '@react-types/shared'; interface GridMapShared { keyboardDelegate: KeyboardDelegate, diff --git a/packages/@react-aria/gridlist/src/useGridList.ts b/packages/@react-aria/gridlist/src/useGridList.ts index 3cc9dba3949..c014c66f47f 100644 --- a/packages/@react-aria/gridlist/src/useGridList.ts +++ b/packages/@react-aria/gridlist/src/useGridList.ts @@ -16,13 +16,14 @@ import { DisabledBehavior, DOMAttributes, DOMProps, + Key, KeyboardDelegate, MultipleSelection } from '@react-types/shared'; import {filterDOMProps, mergeProps, useId} from '@react-aria/utils'; -import {Key, RefObject} from 'react'; import {listMap} from './utils'; import {ListState} from '@react-stately/list'; +import {RefObject} from 'react'; import {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid'; import {useHasTabbableChild} from '@react-aria/focus'; import {useSelectableList} from '@react-aria/selection'; diff --git a/packages/@react-aria/gridlist/src/utils.ts b/packages/@react-aria/gridlist/src/utils.ts index 0cfebfa329f..9e95034b170 100644 --- a/packages/@react-aria/gridlist/src/utils.ts +++ b/packages/@react-aria/gridlist/src/utils.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import type {ListState} from '@react-stately/list'; interface ListMapShared { diff --git a/packages/@react-aria/i18n/src/useListFormatter.tsx b/packages/@react-aria/i18n/src/useListFormatter.tsx index e782ffeeead..4465b73d6b8 100644 --- a/packages/@react-aria/i18n/src/useListFormatter.tsx +++ b/packages/@react-aria/i18n/src/useListFormatter.tsx @@ -18,11 +18,7 @@ import {useMemo} from 'react'; * and handles caching of the list formatter for performance. * @param options - Formatting options. */ - -// Typescript version 4.7 supports Intl.ListFormat - TODO upgrade -// @ts-ignore export function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat { let {locale} = useLocale(); - // @ts-ignore return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]); } diff --git a/packages/@react-aria/interactions/stories/useFocusRing.stories.tsx b/packages/@react-aria/interactions/stories/useFocusRing.stories.tsx index f64716519dc..58420fcfdc9 100644 --- a/packages/@react-aria/interactions/stories/useFocusRing.stories.tsx +++ b/packages/@react-aria/interactions/stories/useFocusRing.stories.tsx @@ -11,6 +11,7 @@ */ import {Cell, Column, Row, TableBody, TableHeader, TableView} from '@react-spectrum/table'; +import {Key} from '@react-types/shared'; import React, {useState} from 'react'; import {SearchField} from '@react-spectrum/searchfield'; @@ -80,7 +81,7 @@ function SearchExample() { {item => ( - {key => {item[key]}} + {(key: Key) => {item[key]}} ) } diff --git a/packages/@react-aria/listbox/src/useOption.ts b/packages/@react-aria/listbox/src/useOption.ts index 574e6801467..9e2d59ec046 100644 --- a/packages/@react-aria/listbox/src/useOption.ts +++ b/packages/@react-aria/listbox/src/useOption.ts @@ -10,13 +10,13 @@ * governing permissions and limitations under the License. */ -import {DOMAttributes, FocusableElement} from '@react-types/shared'; +import {DOMAttributes, FocusableElement, Key} from '@react-types/shared'; import {filterDOMProps, isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils'; import {getItemCount} from '@react-stately/collections'; import {getItemId, listData} from './utils'; import {isFocusVisible, useHover} from '@react-aria/interactions'; -import {Key, RefObject} from 'react'; import {ListState} from '@react-stately/list'; +import {RefObject} from 'react'; import {SelectableItemStates, useSelectableItem} from '@react-aria/selection'; export interface OptionAria extends SelectableItemStates { diff --git a/packages/@react-aria/listbox/src/utils.ts b/packages/@react-aria/listbox/src/utils.ts index 9a60da278ce..674d91d9599 100644 --- a/packages/@react-aria/listbox/src/utils.ts +++ b/packages/@react-aria/listbox/src/utils.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {ListState} from '@react-stately/list'; interface ListData { diff --git a/packages/@react-aria/menu/src/useMenu.ts b/packages/@react-aria/menu/src/useMenu.ts index f9624255f95..95547f9ccc0 100644 --- a/packages/@react-aria/menu/src/useMenu.ts +++ b/packages/@react-aria/menu/src/useMenu.ts @@ -11,9 +11,9 @@ */ import {AriaMenuProps} from '@react-types/menu'; -import {DOMAttributes, KeyboardDelegate} from '@react-types/shared'; +import {DOMAttributes, Key, KeyboardDelegate} from '@react-types/shared'; import {filterDOMProps, mergeProps} from '@react-aria/utils'; -import {Key, RefObject} from 'react'; +import {RefObject} from 'react'; import {TreeState} from '@react-stately/tree'; import {useSelectableList} from '@react-aria/selection'; diff --git a/packages/@react-aria/menu/src/useMenuItem.ts b/packages/@react-aria/menu/src/useMenuItem.ts index cb6b9897775..b0b0d3b2073 100644 --- a/packages/@react-aria/menu/src/useMenuItem.ts +++ b/packages/@react-aria/menu/src/useMenuItem.ts @@ -10,13 +10,13 @@ * governing permissions and limitations under the License. */ -import {DOMAttributes, FocusableElement, PressEvent} from '@react-types/shared'; +import {DOMAttributes, FocusableElement, Key, PressEvent} from '@react-types/shared'; import {filterDOMProps, mergeProps, useEffectEvent, useLayoutEffect, useRouter, useSlotId} from '@react-aria/utils'; import {focusSafely} from '@react-aria/focus'; import {getItemCount} from '@react-stately/collections'; import {isFocusVisible, useHover, useKeyboard, usePress} from '@react-aria/interactions'; -import {Key, RefObject, useCallback, useRef} from 'react'; import {menuData} from './useMenu'; +import {RefObject, useCallback, useRef} from 'react'; import {TreeState} from '@react-stately/tree'; import {useLocale} from '@react-aria/i18n'; import {useSelectableItem} from '@react-aria/selection'; diff --git a/packages/@react-aria/selection/src/ListKeyboardDelegate.ts b/packages/@react-aria/selection/src/ListKeyboardDelegate.ts index 7405467b0bc..870105a961b 100644 --- a/packages/@react-aria/selection/src/ListKeyboardDelegate.ts +++ b/packages/@react-aria/selection/src/ListKeyboardDelegate.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {Collection, Direction, KeyboardDelegate, Node, Orientation} from '@react-types/shared'; +import {Collection, Direction, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared'; import {isScrollable} from '@react-aria/utils'; -import {Key, RefObject} from 'react'; +import {RefObject} from 'react'; interface ListKeyboardDelegateOptions { collection: Collection>, diff --git a/packages/@react-aria/selection/src/useSelectableCollection.ts b/packages/@react-aria/selection/src/useSelectableCollection.ts index df489ad31c3..b365b4df42b 100644 --- a/packages/@react-aria/selection/src/useSelectableCollection.ts +++ b/packages/@react-aria/selection/src/useSelectableCollection.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {DOMAttributes, FocusableElement, FocusStrategy, KeyboardDelegate} from '@react-types/shared'; +import {DOMAttributes, FocusableElement, FocusStrategy, Key, KeyboardDelegate} from '@react-types/shared'; import {flushSync} from 'react-dom'; -import {FocusEvent, Key, KeyboardEvent, RefObject, useEffect, useRef} from 'react'; +import {FocusEvent, KeyboardEvent, RefObject, useEffect, useRef} from 'react'; import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus'; import {focusWithoutScrolling, mergeProps, scrollIntoView, scrollIntoViewport, useEvent, useRouter} from '@react-aria/utils'; import {getInteractionModality} from '@react-aria/interactions'; diff --git a/packages/@react-aria/selection/src/useSelectableItem.ts b/packages/@react-aria/selection/src/useSelectableItem.ts index 4802cb53e3a..cb722929ec5 100644 --- a/packages/@react-aria/selection/src/useSelectableItem.ts +++ b/packages/@react-aria/selection/src/useSelectableItem.ts @@ -10,13 +10,13 @@ * governing permissions and limitations under the License. */ -import {DOMAttributes, FocusableElement, LongPressEvent, PressEvent} from '@react-types/shared'; +import {DOMAttributes, FocusableElement, Key, LongPressEvent, PressEvent} from '@react-types/shared'; import {focusSafely} from '@react-aria/focus'; import {isCtrlKeyPressed, isNonContiguousSelectionModifier} from './utils'; -import {Key, RefObject, useEffect, useRef} from 'react'; import {mergeProps, openLink, useRouter} from '@react-aria/utils'; import {MultipleSelectionManager} from '@react-stately/selection'; import {PressProps, useLongPress, usePress} from '@react-aria/interactions'; +import {RefObject, useEffect, useRef} from 'react'; export interface SelectableItemOptions { /** diff --git a/packages/@react-aria/selection/src/useSelectableList.ts b/packages/@react-aria/selection/src/useSelectableList.ts index 87acf4f50b8..702c346a14a 100644 --- a/packages/@react-aria/selection/src/useSelectableList.ts +++ b/packages/@react-aria/selection/src/useSelectableList.ts @@ -11,10 +11,10 @@ */ import {AriaSelectableCollectionOptions, useSelectableCollection} from './useSelectableCollection'; -import {Collection, DOMAttributes, KeyboardDelegate, Node} from '@react-types/shared'; -import {Key, useMemo} from 'react'; +import {Collection, DOMAttributes, Key, KeyboardDelegate, Node} from '@react-types/shared'; import {ListKeyboardDelegate} from './ListKeyboardDelegate'; import {useCollator} from '@react-aria/i18n'; +import {useMemo} from 'react'; export interface AriaSelectableListOptions extends Omit { /** diff --git a/packages/@react-aria/selection/src/useTypeSelect.ts b/packages/@react-aria/selection/src/useTypeSelect.ts index 51b80dcd675..c1814c470d0 100644 --- a/packages/@react-aria/selection/src/useTypeSelect.ts +++ b/packages/@react-aria/selection/src/useTypeSelect.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {DOMAttributes, KeyboardDelegate} from '@react-types/shared'; -import {Key, KeyboardEvent, useRef} from 'react'; +import {DOMAttributes, Key, KeyboardDelegate} from '@react-types/shared'; +import {KeyboardEvent, useRef} from 'react'; import {MultipleSelectionManager} from '@react-stately/selection'; /** diff --git a/packages/@react-aria/ssr/src/SSRProvider.tsx b/packages/@react-aria/ssr/src/SSRProvider.tsx index 7be1abf3c6f..ea637eafce0 100644 --- a/packages/@react-aria/ssr/src/SSRProvider.tsx +++ b/packages/@react-aria/ssr/src/SSRProvider.tsx @@ -45,7 +45,7 @@ export interface SSRProviderProps { } // This is only used in React < 18. -function LegacySSRProvider(props: SSRProviderProps): JSX.Element { +function LegacySSRProvider(props: SSRProviderProps): React.JSX.Element { let cur = useContext(SSRContext); let counter = useCounter(cur === defaultContext); let [isSSR, setIsSSR] = useState(true); @@ -82,7 +82,7 @@ let warnedAboutSSRProvider = false; * When using SSR with React Aria in React 16 or 17, applications must be wrapped in an SSRProvider. * This ensures that auto generated ids are consistent between the client and server. */ -export function SSRProvider(props: SSRProviderProps): JSX.Element { +export function SSRProvider(props: SSRProviderProps): React.JSX.Element { if (typeof React['useId'] === 'function') { if (process.env.NODE_ENV !== 'test' && !warnedAboutSSRProvider) { console.warn('In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app.'); diff --git a/packages/@react-aria/steplist/package.json b/packages/@react-aria/steplist/package.json index 5b943f72e76..943a0b2b24d 100644 --- a/packages/@react-aria/steplist/package.json +++ b/packages/@react-aria/steplist/package.json @@ -27,6 +27,7 @@ "@react-aria/selection": "^3.16.2", "@react-aria/utils": "^3.20.0", "@react-stately/steplist": "3.0.0-alpha.1", + "@react-types/shared": "^3.21.0", "@react-types/steplist": "^3.0.0-alpha.1", "@swc/helpers": "^0.5.0" }, diff --git a/packages/@react-aria/steplist/src/useStepListItem.ts b/packages/@react-aria/steplist/src/useStepListItem.ts index 19487052db2..b14d2794ed5 100644 --- a/packages/@react-aria/steplist/src/useStepListItem.ts +++ b/packages/@react-aria/steplist/src/useStepListItem.ts @@ -10,7 +10,8 @@ * governing permissions and limitations under the License. */ -import {HTMLAttributes, Key, RefObject} from 'react'; +import {HTMLAttributes, RefObject} from 'react'; +import {Key} from '@react-types/shared'; import {StepListState} from '@react-stately/steplist'; import {useSelectableItem} from '@react-aria/selection'; diff --git a/packages/@react-aria/table/src/TableKeyboardDelegate.ts b/packages/@react-aria/table/src/TableKeyboardDelegate.ts index 9db5ce438f0..bb0a9e27789 100644 --- a/packages/@react-aria/table/src/TableKeyboardDelegate.ts +++ b/packages/@react-aria/table/src/TableKeyboardDelegate.ts @@ -12,8 +12,7 @@ import {getChildNodes, getFirstItem, getNthItem} from '@react-stately/collections'; import {GridKeyboardDelegate} from '@react-aria/grid'; -import {Key} from 'react'; -import {Node} from '@react-types/shared'; +import {Key, Node} from '@react-types/shared'; import {TableCollection} from '@react-types/table'; export class TableKeyboardDelegate extends GridKeyboardDelegate> { diff --git a/packages/@react-aria/table/src/useTableColumnResize.ts b/packages/@react-aria/table/src/useTableColumnResize.ts index ce6535e246f..2ba39b4813c 100644 --- a/packages/@react-aria/table/src/useTableColumnResize.ts +++ b/packages/@react-aria/table/src/useTableColumnResize.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {ChangeEvent, Key, RefObject, useCallback, useEffect, useRef} from 'react'; +import {ChangeEvent, RefObject, useCallback, useEffect, useRef} from 'react'; import {ColumnSize} from '@react-types/table'; -import {DOMAttributes, FocusableElement} from '@react-types/shared'; +import {DOMAttributes, FocusableElement, Key} from '@react-types/shared'; import {focusSafely} from '@react-aria/focus'; import {getColumnHeaderId} from './utils'; import {GridNode} from '@react-types/grid'; diff --git a/packages/@react-aria/table/src/useTableSelectionCheckbox.ts b/packages/@react-aria/table/src/useTableSelectionCheckbox.ts index b4e0a2cb302..496059e7119 100644 --- a/packages/@react-aria/table/src/useTableSelectionCheckbox.ts +++ b/packages/@react-aria/table/src/useTableSelectionCheckbox.ts @@ -14,7 +14,7 @@ import {AriaCheckboxProps} from '@react-types/checkbox'; import {getRowLabelledBy} from './utils'; // @ts-ignore import intlMessages from '../intl/*.json'; -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {TableState} from '@react-stately/table'; import {useGridSelectionCheckbox} from '@react-aria/grid'; import {useLocalizedStringFormatter} from '@react-aria/i18n'; diff --git a/packages/@react-aria/table/src/utils.ts b/packages/@react-aria/table/src/utils.ts index a19078d8311..d65169deaef 100644 --- a/packages/@react-aria/table/src/utils.ts +++ b/packages/@react-aria/table/src/utils.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {TableState} from '@react-stately/table'; export const gridIds = new WeakMap, string>(); diff --git a/packages/@react-aria/table/stories/useTable.stories.tsx b/packages/@react-aria/table/stories/useTable.stories.tsx index d129fecfd06..e27fcad5fc4 100644 --- a/packages/@react-aria/table/stories/useTable.stories.tsx +++ b/packages/@react-aria/table/stories/useTable.stories.tsx @@ -15,8 +15,9 @@ import {Table as BackwardCompatTable} from './example-backwards-compat'; import {Cell, Column, Row, TableBody, TableHeader} from '@react-stately/table'; import {ColumnSize} from '@react-types/table'; import {Table as DocsTable} from './example-docs'; +import {Key} from '@react-types/shared'; import {Meta, StoryFn} from '@storybook/react'; -import React, {Key, useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import {Table as ResizingTable} from './example-resizing'; import {SpectrumTableProps} from '@react-spectrum/table'; import {Table} from './example'; diff --git a/packages/@react-aria/table/test/ariaTableResizing.test.tsx b/packages/@react-aria/table/test/ariaTableResizing.test.tsx index 934006e9ef1..9df53274203 100644 --- a/packages/@react-aria/table/test/ariaTableResizing.test.tsx +++ b/packages/@react-aria/table/test/ariaTableResizing.test.tsx @@ -13,7 +13,8 @@ import {act, fireEvent} from '@react-spectrum/test-utils'; import {Cell, Column, Row, TableBody, TableHeader} from '@react-stately/table'; import {composeStories} from '@storybook/testing-react'; -import React, {Key} from 'react'; +import {Key} from '@react-types/shared'; +import React from 'react'; import {render} from '@testing-library/react'; import {Table as ResizingTable} from '../stories/example-resizing'; import {resizingTests} from './tableResizingTests'; diff --git a/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts b/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts index 06ce301dc80..f2b36ecfd20 100644 --- a/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts +++ b/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts @@ -10,8 +10,7 @@ * governing permissions and limitations under the License. */ -import {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared'; -import {Key} from 'react'; +import {Collection, Direction, Key, KeyboardDelegate, Orientation} from '@react-types/shared'; export class TabsKeyboardDelegate implements KeyboardDelegate { private collection: Collection; @@ -20,7 +19,7 @@ export class TabsKeyboardDelegate implements KeyboardDelegate { constructor(collection: Collection, direction: Direction, orientation: Orientation, disabledKeys: Set = new Set()) { this.collection = collection; - this.flipDirection = direction === 'rtl' && orientation === 'horizontal'; + this.flipDirection = direction === 'rtl' && orientation === 'horizontal'; this.disabledKeys = disabledKeys; } @@ -34,7 +33,7 @@ export class TabsKeyboardDelegate implements KeyboardDelegate { getKeyRightOf(key: Key) { if (this.flipDirection) { return this.getPreviousKey(key); - } + } return this.getNextKey(key); } diff --git a/packages/@react-aria/tabs/src/utils.ts b/packages/@react-aria/tabs/src/utils.ts index d7b96f2a214..8311be6f686 100644 --- a/packages/@react-aria/tabs/src/utils.ts +++ b/packages/@react-aria/tabs/src/utils.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {TabListState} from '@react-stately/tabs'; export const tabsIds = new WeakMap, string>(); diff --git a/packages/@react-aria/tag/src/useTagGroup.ts b/packages/@react-aria/tag/src/useTagGroup.ts index 7a27970411d..9fc886056b0 100644 --- a/packages/@react-aria/tag/src/useTagGroup.ts +++ b/packages/@react-aria/tag/src/useTagGroup.ts @@ -10,11 +10,11 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, CollectionBase, DOMAttributes, DOMProps, HelpTextProps, KeyboardDelegate, LabelableProps, MultipleSelection, SelectionBehavior} from '@react-types/shared'; +import {AriaLabelingProps, CollectionBase, DOMAttributes, DOMProps, HelpTextProps, Key, KeyboardDelegate, LabelableProps, MultipleSelection, SelectionBehavior} from '@react-types/shared'; import {filterDOMProps, mergeProps} from '@react-aria/utils'; -import {Key, ReactNode, RefObject, useEffect, useRef, useState} from 'react'; import {ListKeyboardDelegate} from '@react-aria/selection'; import type {ListState} from '@react-stately/list'; +import {ReactNode, RefObject, useEffect, useRef, useState} from 'react'; import {useField} from '@react-aria/label'; import {useFocusWithin} from '@react-aria/interactions'; import {useGridList} from '@react-aria/gridlist'; diff --git a/packages/@react-aria/virtualizer/src/Virtualizer.tsx b/packages/@react-aria/virtualizer/src/Virtualizer.tsx index ed3e24a72d7..6e93a26af87 100644 --- a/packages/@react-aria/virtualizer/src/Virtualizer.tsx +++ b/packages/@react-aria/virtualizer/src/Virtualizer.tsx @@ -10,11 +10,11 @@ * governing permissions and limitations under the License. */ -import {Collection} from '@react-types/shared'; +import {Collection, Key} from '@react-types/shared'; import {getInteractionModality} from '@react-aria/interactions'; import {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer'; import {mergeProps, useLayoutEffect} from '@react-aria/utils'; -import React, {FocusEvent, HTMLAttributes, Key, ReactElement, ReactNode, RefObject, useCallback, useEffect, useMemo, useRef} from 'react'; +import React, {FocusEvent, HTMLAttributes, ReactElement, ReactNode, RefObject, useCallback, useEffect, useMemo, useRef} from 'react'; import {ScrollView} from './ScrollView'; import {VirtualizerItem} from './VirtualizerItem'; diff --git a/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts b/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts index 848027f0b0b..3a1539aeb96 100644 --- a/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts +++ b/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts @@ -10,8 +10,9 @@ * governing permissions and limitations under the License. */ -import {Key, RefObject, useCallback} from 'react'; +import {Key} from '@react-types/shared'; import {LayoutInfo, Size} from '@react-stately/virtualizer'; +import {RefObject, useCallback} from 'react'; import {useLayoutEffect} from '@react-aria/utils'; interface IVirtualizer { diff --git a/packages/@react-spectrum/accordion/stories/Accordion.stories.tsx b/packages/@react-spectrum/accordion/stories/Accordion.stories.tsx index a5a49fc2a94..8597b285c20 100644 --- a/packages/@react-spectrum/accordion/stories/Accordion.stories.tsx +++ b/packages/@react-spectrum/accordion/stories/Accordion.stories.tsx @@ -12,11 +12,12 @@ import {Accordion, Item} from '../src'; import {ComponentMeta, ComponentStoryObj} from '@storybook/react'; +import {Key} from '@react-types/shared'; import React, {useState} from 'react'; import {SpectrumAccordionProps} from '@react-types/accordion'; type ItemType = { - key: React.Key, + key: Key, title: string }; @@ -69,7 +70,7 @@ export const ControlledExpandedKeys: AccordionStory = { function ControlledAccordion(props: SpectrumAccordionProps) { - let [openKeys, setOpenKeys] = useState>(new Set(['files'])); + let [openKeys, setOpenKeys] = useState>(new Set(['files'])); return ( diff --git a/packages/@react-spectrum/actiongroup/docs/ActionGroup.mdx b/packages/@react-spectrum/actiongroup/docs/ActionGroup.mdx index 9021b0c4155..ab1ada97389 100644 --- a/packages/@react-spectrum/actiongroup/docs/ActionGroup.mdx +++ b/packages/@react-spectrum/actiongroup/docs/ActionGroup.mdx @@ -213,8 +213,9 @@ The `key` prop from the selected item will be passed into the callback. To continue to capturing actions when `selectionMode` is `none`, utilize the `onAction` prop. ```tsx example +import {Key} from '@react-types/shared'; function Example() { - let [actionKey, setActionKey] = React.useState(''); + let [actionKey, setActionKey] = React.useState(''); return ( <> diff --git a/packages/@react-spectrum/actiongroup/src/ActionGroup.tsx b/packages/@react-spectrum/actiongroup/src/ActionGroup.tsx index 00843cda956..ce4cd7d60ba 100644 --- a/packages/@react-spectrum/actiongroup/src/ActionGroup.tsx +++ b/packages/@react-spectrum/actiongroup/src/ActionGroup.tsx @@ -11,7 +11,7 @@ */ import {ActionButton} from '@react-spectrum/button'; -import {AriaLabelingProps, DOMProps, DOMRef, Node, StyleProps} from '@react-types/shared'; +import {AriaLabelingProps, DOMProps, DOMRef, Key, Node, StyleProps} from '@react-types/shared'; import buttonStyles from '@adobe/spectrum-css-temp/components/button/vars.css'; import ChevronDownMedium from '@spectrum-icons/ui/ChevronDownMedium'; import { @@ -29,7 +29,7 @@ import {ListState, useListState} from '@react-stately/list'; import More from '@spectrum-icons/workflow/More'; import {PressResponder, useHover} from '@react-aria/interactions'; import {Provider, useProviderProps} from '@react-spectrum/provider'; -import React, {forwardRef, Key, ReactElement, ReactNode, useCallback, useMemo, useRef, useState} from 'react'; +import React, {forwardRef, ReactElement, ReactNode, useCallback, useMemo, useRef, useState} from 'react'; import {SpectrumActionGroupProps} from '@react-types/actiongroup'; import styles from '@adobe/spectrum-css-temp/components/actiongroup/vars.css'; import {Text} from '@react-spectrum/text'; diff --git a/packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx b/packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx index 9e572297622..6bce1727b0e 100644 --- a/packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx +++ b/packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx @@ -12,10 +12,10 @@ import {ActionButton} from '@react-spectrum/button'; import {BreadcrumbItem} from './BreadcrumbItem'; import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils'; -import {DOMRef} from '@react-types/shared'; +import {DOMRef, Key} from '@react-types/shared'; import FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb'; import {Menu, MenuTrigger} from '@react-spectrum/menu'; -import React, {Key, ReactElement, useCallback, useRef} from 'react'; +import React, {ReactElement, useCallback, useRef} from 'react'; import {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs'; import styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css'; import {useBreadcrumbs} from '@react-aria/breadcrumbs'; diff --git a/packages/@react-spectrum/calendar/stories/Calendar.stories.tsx b/packages/@react-spectrum/calendar/stories/Calendar.stories.tsx index f48f2a0f30d..7af0a6998f9 100644 --- a/packages/@react-spectrum/calendar/stories/Calendar.stories.tsx +++ b/packages/@react-spectrum/calendar/stories/Calendar.stories.tsx @@ -18,6 +18,7 @@ import {ComponentMeta, ComponentStoryObj} from '@storybook/react'; import {DateValue} from '@react-types/calendar'; import {Flex} from '@react-spectrum/layout'; import {Item, Picker, Section} from '@react-spectrum/picker'; +import {Key} from '@react-types/shared'; import {Provider} from '@react-spectrum/provider'; import React, {useState} from 'react'; import {TimeField} from '@react-spectrum/datepicker'; @@ -198,7 +199,7 @@ const calendars = [ function Example(props) { let [locale, setLocale] = React.useState(''); - let [calendar, setCalendar] = React.useState(calendars[0].key); + let [calendar, setCalendar] = React.useState(calendars[0].key); let {locale: defaultLocale} = useLocale(); let pref = preferences.find(p => p.locale === locale); diff --git a/packages/@react-spectrum/card/src/BaseLayout.tsx b/packages/@react-spectrum/card/src/BaseLayout.tsx index 3e37a5baad4..93e47156f48 100644 --- a/packages/@react-spectrum/card/src/BaseLayout.tsx +++ b/packages/@react-spectrum/card/src/BaseLayout.tsx @@ -10,11 +10,10 @@ * governing permissions and limitations under the License. */ -import {Direction, KeyboardDelegate, Node} from '@react-types/shared'; +import {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared'; import {getChildNodes, getFirstItem} from '@react-stately/collections'; import {GridCollection} from '@react-stately/grid'; import {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer'; -import {Key} from 'react'; import {Scale} from '@react-types/provider'; export interface BaseLayoutOptions { diff --git a/packages/@react-spectrum/card/src/GridLayout.tsx b/packages/@react-spectrum/card/src/GridLayout.tsx index cbd9f1ce7d9..1c3f44c057e 100644 --- a/packages/@react-spectrum/card/src/GridLayout.tsx +++ b/packages/@react-spectrum/card/src/GridLayout.tsx @@ -12,9 +12,8 @@ import {BaseLayout, BaseLayoutOptions} from './BaseLayout'; import {getChildNodes, getFirstItem} from '@react-stately/collections'; -import {Key} from 'react'; +import {Key, Node, Orientation} from '@react-types/shared'; import {LayoutInfo, Rect, Size} from '@react-stately/virtualizer'; -import {Node, Orientation} from '@react-types/shared'; export interface GridLayoutOptions extends BaseLayoutOptions { // /** diff --git a/packages/@react-spectrum/card/src/WaterfallLayout.tsx b/packages/@react-spectrum/card/src/WaterfallLayout.tsx index f5fa4f836d2..eebd9203326 100644 --- a/packages/@react-spectrum/card/src/WaterfallLayout.tsx +++ b/packages/@react-spectrum/card/src/WaterfallLayout.tsx @@ -13,8 +13,7 @@ import {BaseLayout, BaseLayoutOptions} from './BaseLayout'; import {getChildNodes, getFirstItem} from '@react-stately/collections'; import {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer'; -import {Key} from 'react'; -import {KeyboardDelegate, Node} from '@react-types/shared'; +import {Key, KeyboardDelegate, Node} from '@react-types/shared'; export interface WaterfallLayoutOptions extends BaseLayoutOptions { /** diff --git a/packages/@react-spectrum/card/stories/GridCardView.stories.tsx b/packages/@react-spectrum/card/stories/GridCardView.stories.tsx index edf04a6a4aa..9699be1b5fd 100644 --- a/packages/@react-spectrum/card/stories/GridCardView.stories.tsx +++ b/packages/@react-spectrum/card/stories/GridCardView.stories.tsx @@ -21,8 +21,9 @@ import {GridLayoutOptions} from '../src/GridLayout'; import {Heading, Text} from '@react-spectrum/text'; import {IllustratedMessage} from '@react-spectrum/illustratedmessage'; import {Image} from '@react-spectrum/image'; +import {Key} from '@react-types/shared'; import {Link} from '@react-spectrum/link'; -import React, {Key, useMemo, useState} from 'react'; +import React, {useMemo, useState} from 'react'; import {Size} from '@react-stately/virtualizer'; import {SpectrumCardViewProps} from '@react-types/card'; import {TextField} from '@react-spectrum/textfield'; diff --git a/packages/@react-spectrum/combobox/docs/ComboBox.mdx b/packages/@react-spectrum/combobox/docs/ComboBox.mdx index ccb0bd48b21..abf03bcc809 100644 --- a/packages/@react-spectrum/combobox/docs/ComboBox.mdx +++ b/packages/@react-spectrum/combobox/docs/ComboBox.mdx @@ -260,6 +260,7 @@ Setting a selected option can be done by using the `defaultSelectedKey` or `sele Additionally, see the `react-stately` [Selection docs](../react-stately/selection.html#selected-key-data-type) for caveats regarding selection prop typing. ```tsx example +import {Key} from '@react-types/shared'; function Example() { let options = [ {id: 1, name: 'Adobe Photoshop'}, @@ -272,7 +273,7 @@ function Example() { {id: 8, name: 'Adobe Fresco'}, {id: 9, name: 'Adobe Dreamweaver'} ]; - let [productId, setProductId] = React.useState(9); + let [productId, setProductId] = React.useState(9); return ( diff --git a/packages/@react-spectrum/combobox/stories/ComboBox.stories.tsx b/packages/@react-spectrum/combobox/stories/ComboBox.stories.tsx index d70ff0fc0f6..838ac3c56db 100644 --- a/packages/@react-spectrum/combobox/stories/ComboBox.stories.tsx +++ b/packages/@react-spectrum/combobox/stories/ComboBox.stories.tsx @@ -26,6 +26,7 @@ import {Dialog, DialogTrigger} from '@react-spectrum/dialog'; import Draw from '@spectrum-icons/workflow/Draw'; import {Flex} from '@react-spectrum/layout'; import {Heading, Text} from '@react-spectrum/text'; +import {Key} from '@react-types/shared'; import {Link} from '@react-spectrum/link'; import React, {useRef, useState} from 'react'; import {useAsyncList, useListData, useTreeData} from '@react-stately/data'; @@ -576,7 +577,7 @@ function AsyncLoadingExampleControlledKey(props) { list.setFilterText(value); }; - let selectedKey = (list.selectedKeys as Set).values().next().value; + let selectedKey = (list.selectedKeys as Set).values().next().value; return ( ).values().next().value; + let selectedKey = (selectedKeys as Set).values().next().value; // If selectedKey exists and combobox is performing intial load, update the input value with the selected key text if (!isFocused.current && selectedKey) { @@ -644,7 +645,7 @@ function AsyncLoadingExampleControlledKeyWithReset(props) { list.setFilterText(value); }; - let selectedKey = (list.selectedKeys as Set).values().next().value; + let selectedKey = (list.selectedKeys as Set).values().next().value; return ( { + let onSelectionChange = (key: Key) => { setFieldState(prevState => ({ inputValue: list.getItem(key)?.value.name ?? (props.allowsCustomValue ? prevState.inputValue : ''), selectedKey: key diff --git a/packages/@react-spectrum/datepicker/stories/DateField.stories.tsx b/packages/@react-spectrum/datepicker/stories/DateField.stories.tsx index 77dd1ae086c..a822f1104d0 100644 --- a/packages/@react-spectrum/datepicker/stories/DateField.stories.tsx +++ b/packages/@react-spectrum/datepicker/stories/DateField.stories.tsx @@ -19,6 +19,7 @@ import {DateField} from '../'; import {Flex} from '@react-spectrum/layout'; import {Heading} from '@react-spectrum/text'; import {Item, Picker, Section} from '@react-spectrum/picker'; +import {Key} from '@react-types/shared'; import {Provider} from '@react-spectrum/provider'; import React from 'react'; import {useLocale} from '@react-aria/i18n'; @@ -309,7 +310,7 @@ const calendars = [ function Example(props) { let [locale, setLocale] = React.useState(''); - let [calendar, setCalendar] = React.useState(calendars[0].key); + let [calendar, setCalendar] = React.useState(calendars[0].key); let {locale: defaultLocale} = useLocale(); let pref = preferences.find(p => p.locale === locale); diff --git a/packages/@react-spectrum/datepicker/stories/DatePicker.stories.tsx b/packages/@react-spectrum/datepicker/stories/DatePicker.stories.tsx index 59bcce52378..c26c70ac3ef 100644 --- a/packages/@react-spectrum/datepicker/stories/DatePicker.stories.tsx +++ b/packages/@react-spectrum/datepicker/stories/DatePicker.stories.tsx @@ -22,6 +22,7 @@ import {DateValue} from '@react-types/calendar'; import {Flex} from '@react-spectrum/layout'; import {Heading} from '@react-spectrum/text'; import {Item, Picker, Section} from '@react-spectrum/picker'; +import {Key} from '@react-types/shared'; import {Provider} from '@react-spectrum/provider'; import React from 'react'; import {useLocale} from '@react-aria/i18n'; @@ -327,7 +328,7 @@ const calendars = [ function Example(props) { let [locale, setLocale] = React.useState(''); - let [calendar, setCalendar] = React.useState(calendars[0].key); + let [calendar, setCalendar] = React.useState(calendars[0].key); let {locale: defaultLocale} = useLocale(); let pref = preferences.find(p => p.locale === locale); diff --git a/packages/@react-spectrum/datepicker/stories/DateRangePicker.stories.tsx b/packages/@react-spectrum/datepicker/stories/DateRangePicker.stories.tsx index 90164b81f9f..37d1c0d8d81 100644 --- a/packages/@react-spectrum/datepicker/stories/DateRangePicker.stories.tsx +++ b/packages/@react-spectrum/datepicker/stories/DateRangePicker.stories.tsx @@ -18,6 +18,7 @@ import {DateRangePicker} from '../'; import {DateValue} from '@react-types/calendar'; import {Flex} from '@react-spectrum/layout'; import {Item, Picker, Section} from '@react-spectrum/picker'; +import {Key} from '@react-types/shared'; import {Provider} from '@adobe/react-spectrum'; import React from 'react'; import {useLocale} from '@react-aria/i18n'; @@ -233,7 +234,7 @@ const calendars = [ function Example(props) { let [locale, setLocale] = React.useState(''); - let [calendar, setCalendar] = React.useState(calendars[0].key); + let [calendar, setCalendar] = React.useState(calendars[0].key); let {locale: defaultLocale} = useLocale(); let pref = preferences.find(p => p.locale === locale); diff --git a/packages/@react-spectrum/dialog/src/DialogTrigger.tsx b/packages/@react-spectrum/dialog/src/DialogTrigger.tsx index 6c6f284c89b..ae88775fd06 100644 --- a/packages/@react-spectrum/dialog/src/DialogTrigger.tsx +++ b/packages/@react-spectrum/dialog/src/DialogTrigger.tsx @@ -140,7 +140,7 @@ DialogTrigger.getCollectionNode = function* (props: SpectrumDialogTriggerProps) */ // We don't want getCollectionNode to show up in the type definition -let _DialogTrigger = DialogTrigger as (props: SpectrumDialogTriggerProps) => JSX.Element; +let _DialogTrigger = DialogTrigger as (props: SpectrumDialogTriggerProps) => React.JSX.Element; export {_DialogTrigger as DialogTrigger}; function PopoverTrigger({state, targetRef, trigger, content, hideArrow, ...props}) { diff --git a/packages/@react-spectrum/dnd/src/useDragAndDrop.ts b/packages/@react-spectrum/dnd/src/useDragAndDrop.ts index f22332c15d0..769f60d1cca 100644 --- a/packages/@react-spectrum/dnd/src/useDragAndDrop.ts +++ b/packages/@react-spectrum/dnd/src/useDragAndDrop.ts @@ -28,7 +28,7 @@ import { useDroppableCollection, useDroppableItem } from '@react-aria/dnd'; -import {DraggableCollectionProps, DragItem, DroppableCollectionProps} from '@react-types/shared'; +import {DraggableCollectionProps, DragItem, DroppableCollectionProps, Key} from '@react-types/shared'; import { DraggableCollectionState, DraggableCollectionStateOptions, @@ -37,7 +37,7 @@ import { useDraggableCollectionState, useDroppableCollectionState } from '@react-stately/dnd'; -import {Key, RefObject, useMemo} from 'react'; +import React, {RefObject, useMemo} from 'react'; interface DraggableCollectionStateOpts extends Omit {} @@ -57,7 +57,7 @@ interface DropHooks { export interface DragAndDropHooks { /** Drag and drop hooks for the collection element. */ - dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set, draggedKey: Key) => JSX.Element} + dragAndDropHooks: DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set, draggedKey: Key) => React.JSX.Element} } export interface DragAndDropOptions extends Omit, DroppableCollectionProps { @@ -67,7 +67,7 @@ export interface DragAndDropOptions extends Omit) => DragItem[], /** Provide a custom drag preview. `draggedKey` represents the key of the item the user actually dragged. */ - renderPreview?: (keys: Set, draggedKey: Key) => JSX.Element + renderPreview?: (keys: Set, draggedKey: Key) => React.JSX.Element } /** @@ -88,7 +88,7 @@ export function useDragAndDrop(options: DragAndDropOptions): DragAndDropHooks { let isDraggable = !!getItems; let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop); - let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set, draggedKey: Key) => JSX.Element}; + let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set, draggedKey: Key) => React.JSX.Element}; if (isDraggable) { hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOptions) { return useDraggableCollectionState({...props, ...options}); diff --git a/packages/@react-spectrum/form/stories/Form.stories.tsx b/packages/@react-spectrum/form/stories/Form.stories.tsx index 18d18619b96..3bb3a0e41b5 100644 --- a/packages/@react-spectrum/form/stories/Form.stories.tsx +++ b/packages/@react-spectrum/form/stories/Form.stories.tsx @@ -28,9 +28,10 @@ import {FormTranslatedText} from './../chromatic/FormLanguages.chromatic'; import {Heading} from '@react-spectrum/text'; import {InlineAlert} from '@react-spectrum/inlinealert'; import {Item, Picker} from '@react-spectrum/picker'; +import {Key, ValidationState} from '@react-types/shared'; import {NumberField} from '@react-spectrum/numberfield'; import {Radio, RadioGroup} from '@react-spectrum/radio'; -import React, {Key, useEffect, useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {SearchAutocomplete} from '@react-spectrum/autocomplete'; import {SearchField} from '@react-spectrum/searchfield'; import {Slider} from '@react-spectrum/slider'; @@ -39,7 +40,6 @@ import {Switch} from '@react-spectrum/switch'; import {TagGroup} from '@react-spectrum/tag'; import {TextArea, TextField} from '@react-spectrum/textfield'; import typographyStyles from '@adobe/spectrum-css-temp/components/typography/vars.css'; -import {ValidationState} from '@react-types/shared'; import {Well} from '@react-spectrum/well'; export default { diff --git a/packages/@react-spectrum/labeledvalue/docs/types.ts b/packages/@react-spectrum/labeledvalue/docs/types.ts index b39452397c3..1f9094c38f9 100644 --- a/packages/@react-spectrum/labeledvalue/docs/types.ts +++ b/packages/@react-spectrum/labeledvalue/docs/types.ts @@ -6,6 +6,5 @@ export interface LabeledValueProps extends LabeledValueBaseProps { /** The value to display. */ value: string | string[] | number | RangeValue | DateTime | RangeValue, /** Formatting options for the value. The available options depend on the type passed to the `value` prop. */ - // @ts-ignore formatOptions?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | Intl.ListFormatOptions } diff --git a/packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx b/packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx index 9b63ce3ffe7..575de7f24cb 100644 --- a/packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx +++ b/packages/@react-spectrum/labeledvalue/src/LabeledValue.tsx @@ -55,7 +55,6 @@ interface StringListProps { /** The value to display. */ value: T, /** Formatting options for the value. */ - // @ts-ignore formatOptions?: Intl.ListFormatOptions } @@ -78,7 +77,6 @@ function LabeledValue(props: SpectrumLabele let children; if (Array.isArray(value)) { - // @ts-ignore children = ; } diff --git a/packages/@react-spectrum/link/src/Link.tsx b/packages/@react-spectrum/link/src/Link.tsx index 6b630e370cb..ff063721cee 100644 --- a/packages/@react-spectrum/link/src/Link.tsx +++ b/packages/@react-spectrum/link/src/Link.tsx @@ -59,7 +59,7 @@ export function Link(props: SpectrumLinkProps) { ) }; - let link: JSX.Element; + let link: React.JSX.Element; if (href) { link = {children}; } else { diff --git a/packages/@react-spectrum/list/src/ListView.tsx b/packages/@react-spectrum/list/src/ListView.tsx index ab526776725..ab25941ab93 100644 --- a/packages/@react-spectrum/list/src/ListView.tsx +++ b/packages/@react-spectrum/list/src/ListView.tsx @@ -11,7 +11,7 @@ */ import {AriaGridListProps, useGridList} from '@react-aria/gridlist'; -import {AsyncLoadable, DOMRef, LoadingState, SpectrumSelectionProps, StyleProps} from '@react-types/shared'; +import {AsyncLoadable, DOMRef, Key, LoadingState, SpectrumSelectionProps, StyleProps} from '@react-types/shared'; import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils'; import type {DragAndDropHooks} from '@react-spectrum/dnd'; import type {DraggableCollectionState, DroppableCollectionState} from '@react-stately/dnd'; @@ -26,7 +26,7 @@ import {ListState, useListState} from '@react-stately/list'; import listStyles from './styles.css'; import {ListViewItem} from './ListViewItem'; import {ProgressCircle} from '@react-spectrum/progress'; -import React, {Key, ReactElement, useContext, useEffect, useMemo, useRef, useState} from 'react'; +import React, {ReactElement, useContext, useEffect, useMemo, useRef, useState} from 'react'; import RootDropIndicator from './RootDropIndicator'; import {DragPreview as SpectrumDragPreview} from './DragPreview'; import {useCollator, useLocalizedStringFormatter} from '@react-aria/i18n'; @@ -49,7 +49,7 @@ export interface SpectrumListViewProps extends AriaGridListProps, StylePro */ overflowMode?: 'truncate' | 'wrap', /** Sets what the ListView should render when there is no content to display. */ - renderEmptyState?: () => JSX.Element, + renderEmptyState?: () => React.JSX.Element, /** * Handler that is called when a user performs an action on an item. The exact user event depends on * the collection's `selectionStyle` prop and the interaction modality. diff --git a/packages/@react-spectrum/list/stories/ListViewDnDExamples.tsx b/packages/@react-spectrum/list/stories/ListViewDnDExamples.tsx index 661f0decad7..2b6d2a54f07 100644 --- a/packages/@react-spectrum/list/stories/ListViewDnDExamples.tsx +++ b/packages/@react-spectrum/list/stories/ListViewDnDExamples.tsx @@ -7,7 +7,7 @@ import File from '@spectrum-icons/illustrations/File'; import {Flex} from '@react-spectrum/layout'; import Folder from '@spectrum-icons/illustrations/Folder'; import {Item, ListView} from '../'; -import {ItemDropTarget} from '@react-types/shared'; +import {ItemDropTarget, Key} from '@react-types/shared'; import {items} from './ListView.stories'; import React from 'react'; import {Text} from '@react-spectrum/text'; @@ -93,7 +93,7 @@ export function ReorderExample(props) { // Use a random drag type so the items can only be reordered within this list and not dragged elsewhere. let dragType = React.useMemo(() => `keys-${Math.random().toString(36).slice(2)}`, []); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { if (target.dropPosition === 'before') { list.moveBefore(target.key, keys); } else { @@ -191,12 +191,12 @@ export function DragIntoItemExample(props) { {id: '8', type: 'folder', textValue: 'Folder 2', childNodes: []} ] }); - let disabledKeys: React.Key[] = ['2', '7']; + let disabledKeys: Key[] = ['2', '7']; // Use a random drag type so the items can only be reordered within this list and not dragged elsewhere. let dragType = React.useMemo(() => `keys-${Math.random().toString(36).slice(2)}`, []); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { let folderItem = list.getItem(target.key); let draggedItems = keys.map((key) => list.getItem(key)); list.update(target.key, {...folderItem, childNodes: [...folderItem.childNodes, ...draggedItems]}); @@ -289,7 +289,7 @@ export function DragBetweenListsExample(props) { initialItems: props.items2 || itemList2 }); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { let sourceList = list1.getItem(keys[0]) ? list1 : list2; let destinationList = list1.getItem(target.key) ? list1 : list2; @@ -418,7 +418,7 @@ export function DragBetweenListsRootOnlyExample(props) { initialItems: props.items2 || itemList2 }); - let onMove = (keys: React.Key[], destinationList) => { + let onMove = (keys: Key[], destinationList) => { let sourceList = list1.getItem(keys[0]) ? list1 : list2; let items = keys.map(key => sourceList.getItem(key)); diff --git a/packages/@react-spectrum/menu/src/ContextualHelpTrigger.tsx b/packages/@react-spectrum/menu/src/ContextualHelpTrigger.tsx index 0f7fd5ff58c..f8517ba8b40 100644 --- a/packages/@react-spectrum/menu/src/ContextualHelpTrigger.tsx +++ b/packages/@react-spectrum/menu/src/ContextualHelpTrigger.tsx @@ -13,10 +13,10 @@ import {classNames, SlotProvider, useIsMobileDevice} from '@react-spectrum/utils'; import {DismissButton} from '@react-aria/overlays'; import helpStyles from '@adobe/spectrum-css-temp/components/contextualhelp/vars.css'; -import {ItemProps} from '@react-types/shared'; +import {ItemProps, Key} from '@react-types/shared'; import {MenuDialogContext, useMenuStateContext} from './context'; import {Modal, Popover} from '@react-spectrum/overlays'; -import React, {Key, ReactElement, useRef} from 'react'; +import React, {ReactElement, useRef} from 'react'; import styles from '@adobe/spectrum-css-temp/components/menu/vars.css'; import {useOverlayTriggerState} from '@react-stately/overlays'; @@ -123,5 +123,5 @@ ContextualHelpTrigger.getCollectionNode = function* getCollectionNode(props: }; }; -let _Item = ContextualHelpTrigger as (props: SpectrumMenuDialogTriggerProps) => JSX.Element; +let _Item = ContextualHelpTrigger as (props: SpectrumMenuDialogTriggerProps) => React.JSX.Element; export {_Item as ContextualHelpTrigger}; diff --git a/packages/@react-spectrum/menu/src/MenuItem.tsx b/packages/@react-spectrum/menu/src/MenuItem.tsx index 28de3f13939..fabd32f0493 100644 --- a/packages/@react-spectrum/menu/src/MenuItem.tsx +++ b/packages/@react-spectrum/menu/src/MenuItem.tsx @@ -12,14 +12,14 @@ import CheckmarkMedium from '@spectrum-icons/ui/CheckmarkMedium'; import {classNames, ClearSlots, SlotProvider} from '@react-spectrum/utils'; -import {DOMAttributes, Node} from '@react-types/shared'; +import {DOMAttributes, Key, Node} from '@react-types/shared'; import {FocusRing} from '@react-aria/focus'; import {Grid} from '@react-spectrum/layout'; import InfoOutline from '@spectrum-icons/workflow/InfoOutline'; // @ts-ignore import intlMessages from '../intl/*.json'; import {mergeRefs, useObjectRef, useSlotId} from '@react-aria/utils'; -import React, {Key, useMemo, useRef} from 'react'; +import React, {useMemo, useRef} from 'react'; import styles from '@adobe/spectrum-css-temp/components/menu/vars.css'; import {Text} from '@react-spectrum/text'; import {TreeState} from '@react-stately/tree'; diff --git a/packages/@react-spectrum/menu/src/MenuSection.tsx b/packages/@react-spectrum/menu/src/MenuSection.tsx index 6e5495c6f0a..3a4c7a94aa9 100644 --- a/packages/@react-spectrum/menu/src/MenuSection.tsx +++ b/packages/@react-spectrum/menu/src/MenuSection.tsx @@ -12,9 +12,9 @@ import {classNames} from '@react-spectrum/utils'; import {getChildNodes} from '@react-stately/collections'; +import {Key, Node} from '@react-types/shared'; import {MenuItem} from './MenuItem'; -import {Node} from '@react-types/shared'; -import React, {Fragment, Key} from 'react'; +import React, {Fragment} from 'react'; import styles from '@adobe/spectrum-css-temp/components/menu/vars.css'; import {TreeState} from '@react-stately/tree'; import {useMenuSection} from '@react-aria/menu'; diff --git a/packages/@react-spectrum/picker/docs/Picker.mdx b/packages/@react-spectrum/picker/docs/Picker.mdx index 79a3cf3d6d7..c31bc325582 100644 --- a/packages/@react-spectrum/picker/docs/Picker.mdx +++ b/packages/@react-spectrum/picker/docs/Picker.mdx @@ -119,6 +119,7 @@ Setting a selected option can be done by using the `defaultSelectedKey` or `sele Additionally see the `react-stately` [Selection docs](../react-stately/selection.html#selected-key-data-type) for caveats regarding selection prop typing. ```tsx example +import {Key} from '@react-types/shared'; function Example() { let options = [ {name: 'Koala'}, @@ -128,7 +129,7 @@ function Example() { {name: 'Bison'}, {name: 'Skunk'} ]; - let [animal, setAnimal] = React.useState("Bison"); + let [animal, setAnimal] = React.useState("Bison"); return ( diff --git a/packages/@react-spectrum/provider/test/Provider.test.tsx b/packages/@react-spectrum/provider/test/Provider.test.tsx index 8071869b8d7..ed7d068e411 100644 --- a/packages/@react-spectrum/provider/test/Provider.test.tsx +++ b/packages/@react-spectrum/provider/test/Provider.test.tsx @@ -12,7 +12,7 @@ // needs to be imported first import MatchMediaMock from 'jest-matchmedia-mock'; -// eslint-disable-next-line rulesdir/sort-imports +// eslint-disable-next-line rsp-rules/sort-imports import {act, fireEvent, pointerMap, render, triggerPress} from '@react-spectrum/test-utils'; import {ActionButton, Button} from '@react-spectrum/button'; import {Checkbox} from '@react-spectrum/checkbox'; diff --git a/packages/@react-spectrum/steplist/stories/StepList.stories.tsx b/packages/@react-spectrum/steplist/stories/StepList.stories.tsx index 826d95929c2..71e565763a6 100644 --- a/packages/@react-spectrum/steplist/stories/StepList.stories.tsx +++ b/packages/@react-spectrum/steplist/stories/StepList.stories.tsx @@ -16,8 +16,9 @@ import {ButtonGroup} from '@react-spectrum/buttongroup'; import {ComponentMeta, ComponentStoryObj} from '@storybook/react'; import {Flex} from '@react-spectrum/layout'; import {Item} from '@react-stately/collections'; +import {Key} from '@react-types/shared'; import {Picker} from '@react-spectrum/picker'; -import React, {Key, useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import {SpectrumStepListProps} from '@react-types/steplist'; import {StepList} from '../'; import {View} from '@react-spectrum/view'; diff --git a/packages/@react-spectrum/table/src/Resizer.tsx b/packages/@react-spectrum/table/src/Resizer.tsx index 280dcbb3f0e..57f7718f175 100644 --- a/packages/@react-spectrum/table/src/Resizer.tsx +++ b/packages/@react-spectrum/table/src/Resizer.tsx @@ -10,7 +10,8 @@ import {GridNode} from '@react-types/grid'; // @ts-ignore import intlMessages from '../intl/*.json'; import {isWebKit, mergeProps} from '@react-aria/utils'; -import React, {Key, RefObject, useEffect, useState} from 'react'; +import {Key} from '@react-types/shared'; +import React, {RefObject, useEffect, useState} from 'react'; import ReactDOM from 'react-dom'; import styles from '@adobe/spectrum-css-temp/components/table/vars.css'; import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n'; diff --git a/packages/@react-spectrum/table/src/TableViewBase.tsx b/packages/@react-spectrum/table/src/TableViewBase.tsx index 28d3cbaf88b..f748841eedb 100644 --- a/packages/@react-spectrum/table/src/TableViewBase.tsx +++ b/packages/@react-spectrum/table/src/TableViewBase.tsx @@ -24,7 +24,7 @@ import { useUnwrapDOMRef } from '@react-spectrum/utils'; import {ColumnSize, SpectrumColumnProps} from '@react-types/table'; -import {DOMRef, DropTarget, FocusableElement, FocusableRef} from '@react-types/shared'; +import {DOMRef, DropTarget, FocusableElement, FocusableRef, Key} from '@react-types/shared'; import type {DragAndDropHooks} from '@react-spectrum/dnd'; import type {DraggableCollectionState, DroppableCollectionState} from '@react-stately/dnd'; import type {DraggableItemResult, DropIndicatorAria, DroppableCollectionResult, DroppableItemResult} from '@react-aria/dnd'; @@ -39,7 +39,7 @@ import {layoutInfoToStyle, ScrollView, setScrollLeft, useVirtualizer, Virtualize import ListGripper from '@spectrum-icons/ui/ListGripper'; import {Nubbin} from './Nubbin'; import {ProgressCircle} from '@react-spectrum/progress'; -import React, {DOMAttributes, HTMLAttributes, Key, ReactElement, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; +import React, {DOMAttributes, HTMLAttributes, ReactElement, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; import {Resizer} from './Resizer'; import {ReusableView, useVirtualizerState} from '@react-stately/virtualizer'; import {RootDropIndicator} from './RootDropIndicator'; diff --git a/packages/@react-spectrum/table/src/TableViewWrapper.tsx b/packages/@react-spectrum/table/src/TableViewWrapper.tsx index 6d26e52e5d3..a7963b79dbb 100644 --- a/packages/@react-spectrum/table/src/TableViewWrapper.tsx +++ b/packages/@react-spectrum/table/src/TableViewWrapper.tsx @@ -10,10 +10,10 @@ * governing permissions and limitations under the License. */ -import type {AriaLabelingProps, DOMProps, DOMRef, SpectrumSelectionProps, StyleProps} from '@react-types/shared'; +import type {AriaLabelingProps, DOMProps, DOMRef, Key, SpectrumSelectionProps, StyleProps} from '@react-types/shared'; import type {ColumnSize, TableProps} from '@react-types/table'; import type {DragAndDropHooks} from '@react-spectrum/dnd'; -import React, {Key, ReactElement} from 'react'; +import React, {ReactElement} from 'react'; import {tableNestedRows} from '@react-stately/flags'; import {TableView} from './TableView'; import {TreeGridTableView} from './TreeGridTableView'; @@ -32,7 +32,7 @@ export interface SpectrumTableProps extends TableProps, SpectrumSelectionP /** Whether the TableView should be displayed with a quiet style. */ isQuiet?: boolean, /** Sets what the TableView should render when there is no content to display. */ - renderEmptyState?: () => JSX.Element, + renderEmptyState?: () => React.JSX.Element, /** Handler that is called when a user performs an action on a row. */ onAction?: (key: Key) => void, /** diff --git a/packages/@react-spectrum/table/src/index.ts b/packages/@react-spectrum/table/src/index.ts index f05623fa0c1..cd88e69b0c9 100644 --- a/packages/@react-spectrum/table/src/index.ts +++ b/packages/@react-spectrum/table/src/index.ts @@ -14,10 +14,11 @@ export {TableView} from './TableViewWrapper'; import {Column} from '@react-stately/table'; +import React from 'react'; import {SpectrumColumnProps} from '@react-types/table'; // Override TS for Column to support spectrum specific props. -const SpectrumColumn = Column as (props: SpectrumColumnProps) => JSX.Element; +const SpectrumColumn = Column as (props: SpectrumColumnProps) => React.JSX.Element; export {SpectrumColumn as Column}; export { diff --git a/packages/@react-spectrum/table/stories/ControllingResize.tsx b/packages/@react-spectrum/table/stories/ControllingResize.tsx index eb10be055a2..e939de4933d 100644 --- a/packages/@react-spectrum/table/stories/ControllingResize.tsx +++ b/packages/@react-spectrum/table/stories/ControllingResize.tsx @@ -13,7 +13,8 @@ import {Button} from '@react-spectrum/button'; import {Cell, Column, Row, SpectrumColumnProps, TableBody, TableHeader, TableView} from '../'; import {ColumnSize} from '@react-types/table'; -import React, {Key, useCallback, useMemo, useState} from 'react'; +import {Key} from '@react-types/shared'; +import React, {useCallback, useMemo, useState} from 'react'; export interface PokemonColumn extends Omit, 'children'> { name: string, diff --git a/packages/@react-spectrum/table/stories/Table.stories.tsx b/packages/@react-spectrum/table/stories/Table.stories.tsx index 96b65549fb1..14487e0595f 100644 --- a/packages/@react-spectrum/table/stories/Table.stories.tsx +++ b/packages/@react-spectrum/table/stories/Table.stories.tsx @@ -28,11 +28,11 @@ import {Heading} from '@react-spectrum/text'; import {HidingColumns} from './HidingColumns'; import {HidingColumnsAllowsResizing} from './HidingColumnsAllowsResizing'; import {IllustratedMessage} from '@react-spectrum/illustratedmessage'; +import {Key, LoadingState} from '@react-types/shared'; import {Link} from '@react-spectrum/link'; -import {LoadingState} from '@react-types/shared'; import NoSearchResults from '@spectrum-icons/illustrations/NoSearchResults'; import {Radio, RadioGroup} from '@react-spectrum/radio'; -import React, {Key, useCallback, useState} from 'react'; +import React, {useCallback, useState} from 'react'; import {SearchField} from '@react-spectrum/searchfield'; import {Switch} from '@react-spectrum/switch'; import {TextField} from '@react-spectrum/textfield'; diff --git a/packages/@react-spectrum/table/stories/TableDnDExamples.tsx b/packages/@react-spectrum/table/stories/TableDnDExamples.tsx index fddae61fd93..de3ca016d7a 100644 --- a/packages/@react-spectrum/table/stories/TableDnDExamples.tsx +++ b/packages/@react-spectrum/table/stories/TableDnDExamples.tsx @@ -3,7 +3,7 @@ import {action} from '@storybook/addon-actions'; import {Cell, Column, Row, TableBody, TableHeader, TableView} from '../'; import {chain} from '@react-aria/utils'; import {Flex} from '@react-spectrum/layout'; -import {ItemDropTarget} from '@react-types/shared'; +import {ItemDropTarget, Key} from '@react-types/shared'; import React from 'react'; import {Text} from '@react-spectrum/text'; import {useDragAndDrop} from '@react-spectrum/dnd'; @@ -79,7 +79,7 @@ export function ReorderExample(props) { // Use a random drag type so the items can only be reordered within this table and not dragged elsewhere. let dragType = React.useMemo(() => `keys-${Math.random().toString(36).slice(2)}`, []); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { if (target.dropPosition === 'before') { list.moveBefore(target.key, keys); } else { @@ -180,12 +180,12 @@ export function DragOntoRowExample(props) { {id: '8', type: 'folder', name: 'Folder 2', childNodes: []} ] }); - let disabledKeys: React.Key[] = ['2', '7']; + let disabledKeys: Key[] = ['2', '7']; // Use a random drag type so the items can only be reordered within this list and not dragged elsewhere. let dragType = React.useMemo(() => `keys-${Math.random().toString(36).slice(2)}`, []); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { let folderItem = list.getItem(target.key); let draggedItems = keys.map((key) => list.getItem(key)); list.update(target.key, {...folderItem, childNodes: [...folderItem.childNodes, ...draggedItems]}); @@ -299,7 +299,7 @@ export function DragBetweenTablesExample(props) { initialItems: props.items2 || itemList2 }); - let onMove = (keys: React.Key[], target: ItemDropTarget) => { + let onMove = (keys: Key[], target: ItemDropTarget) => { let sourceList = list1.getItem(keys[0]) ? list1 : list2; let destinationList = list1.getItem(target.key) ? list1 : list2; @@ -424,7 +424,7 @@ export function DragBetweenTablesRootOnlyExample(props) { initialItems: props.items2 || itemList2 }); - let onMove = (keys: React.Key[], destinationList) => { + let onMove = (keys: Key[], destinationList) => { let sourceList = list1.getItem(keys[0]) ? list1 : list2; let items = keys.map(key => sourceList.getItem(key)); diff --git a/packages/@react-spectrum/table/stories/TreeGridTable.stories.tsx b/packages/@react-spectrum/table/stories/TreeGridTable.stories.tsx index 84f57ea991d..3fe4a6b8c28 100644 --- a/packages/@react-spectrum/table/stories/TreeGridTable.stories.tsx +++ b/packages/@react-spectrum/table/stories/TreeGridTable.stories.tsx @@ -18,7 +18,8 @@ import {ComponentMeta} from '@storybook/react'; import defaultConfig, {columns, EmptyStateTable, TableStory} from './Table.stories'; import {enableTableNestedRows} from '@react-stately/flags'; import {Flex} from '@react-spectrum/layout'; -import React, {Key, useState} from 'react'; +import {Key} from '@react-types/shared'; +import React, {useState} from 'react'; enableTableNestedRows(); diff --git a/packages/@react-spectrum/table/test/TableSizing.test.tsx b/packages/@react-spectrum/table/test/TableSizing.test.tsx index fbe1ed430a1..7dadf2f0ee7 100644 --- a/packages/@react-spectrum/table/test/TableSizing.test.tsx +++ b/packages/@react-spectrum/table/test/TableSizing.test.tsx @@ -19,8 +19,9 @@ import {ColumnSize} from '@react-types/table'; import {ControllingResize} from '../stories/ControllingResize'; import {fireEvent, installPointerEvent, pointerMap, triggerTouch} from '@react-spectrum/test-utils'; import {HidingColumns} from '../stories/HidingColumns'; +import {Key} from '@react-types/shared'; import {Provider} from '@react-spectrum/provider'; -import React, {Key} from 'react'; +import React from 'react'; import {resizingTests} from '@react-aria/table/test/tableResizingTests'; import {Scale} from '@react-types/provider'; import {setInteractionModality} from '@react-aria/interactions'; diff --git a/packages/@react-spectrum/tabs/docs/Tabs.mdx b/packages/@react-spectrum/tabs/docs/Tabs.mdx index eb10fe444d6..20e31311003 100644 --- a/packages/@react-spectrum/tabs/docs/Tabs.mdx +++ b/packages/@react-spectrum/tabs/docs/Tabs.mdx @@ -75,6 +75,7 @@ Each item accepts a key prop, which is passed to the `onSelectionChange` handler See the [Events](#events) section for more detail on selection. ```tsx example +import {Key} from '@react-types/shared'; function Example() { let tabs = [ {id: 1, name: 'Founding of Rome', children: 'Arma virumque cano, Troiae qui primus ab oris.'}, @@ -82,7 +83,7 @@ function Example() { {id: 3, name: 'Empire', children: 'Alea jacta est.'} ]; type Tab = typeof tabs[0]; - let [tabId, setTabId] = React.useState(1); + let [tabId, setTabId] = React.useState(1); return ( <> @@ -219,7 +220,7 @@ function Example() { {id: 3, name: 'Gamepad Settings', children: 'No gamepad detected'} ]; type Tab = typeof tabs[0]; - let [tab, setTab] = React.useState(2); + let [tab, setTab] = React.useState(2); return ( @@ -275,7 +276,7 @@ function Example() { {name: 'Cretaceous', children: 'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 million years ago.'} ]; type Tab = typeof tabs[0]; - let [timePeriod, setTimePeriod] = React.useState('Triassic'); + let [timePeriod, setTimePeriod] = React.useState('Triassic'); return ( <> diff --git a/packages/@react-spectrum/tabs/src/Tabs.tsx b/packages/@react-spectrum/tabs/src/Tabs.tsx index 2aa741b4f7e..5a0e869916f 100644 --- a/packages/@react-spectrum/tabs/src/Tabs.tsx +++ b/packages/@react-spectrum/tabs/src/Tabs.tsx @@ -12,13 +12,12 @@ import {AriaTabPanelProps, SpectrumTabListProps, SpectrumTabPanelsProps, SpectrumTabsProps} from '@react-types/tabs'; import {classNames, SlotProvider, unwrapDOMRef, useDOMRef, useStyleProps} from '@react-spectrum/utils'; -import {DOMProps, DOMRef, Node, Orientation, StyleProps} from '@react-types/shared'; +import {DOMProps, DOMRef, Key, Node, Orientation, StyleProps} from '@react-types/shared'; import {filterDOMProps, mergeProps, useId, useLayoutEffect, useResizeObserver} from '@react-aria/utils'; import {FocusRing} from '@react-aria/focus'; import {Item, Picker} from '@react-spectrum/picker'; import {ListCollection} from '@react-stately/list'; import React, { - Key, MutableRefObject, ReactElement, ReactNode, diff --git a/packages/@react-spectrum/tabs/stories/Tabs.stories.tsx b/packages/@react-spectrum/tabs/stories/Tabs.stories.tsx index 5e674103425..64b0e98e661 100644 --- a/packages/@react-spectrum/tabs/stories/Tabs.stories.tsx +++ b/packages/@react-spectrum/tabs/stories/Tabs.stories.tsx @@ -18,6 +18,7 @@ import {ButtonGroup} from '@react-spectrum/buttongroup'; import Calendar from '@spectrum-icons/workflow/Calendar'; import Dashboard from '@spectrum-icons/workflow/Dashboard'; import {Item, TabList, TabPanels, Tabs} from '..'; +import {Key} from '@react-types/shared'; import {Picker} from '@react-spectrum/picker'; import React, {ReactNode, useState} from 'react'; import {RouterProvider} from '@react-aria/utils'; @@ -857,7 +858,7 @@ let DynamicTabsWithDecoration = (props = {}) => { }; let ControlledSelection = () => { - let [selectedKey, setSelectedKey] = useState('Tab 1'); + let [selectedKey, setSelectedKey] = useState('Tab 1'); return (
    diff --git a/packages/@react-spectrum/tag/src/TagGroup.tsx b/packages/@react-spectrum/tag/src/TagGroup.tsx index f6c485d5dec..0541d774fac 100644 --- a/packages/@react-spectrum/tag/src/TagGroup.tsx +++ b/packages/@react-spectrum/tag/src/TagGroup.tsx @@ -45,7 +45,7 @@ export interface SpectrumTagGroupProps extends Omit, 'se /** Handler that is called when the action button is pressed. */ onAction?: () => void, /** Sets what the TagGroup should render when there are no tags to display. */ - renderEmptyState?: () => JSX.Element, + renderEmptyState?: () => React.JSX.Element, /** Limit the number of rows initially shown. This will render a button that allows the user to expand to show all tags. */ maxRows?: number } diff --git a/packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx b/packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx index d3815075327..0144be2e063 100644 --- a/packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx +++ b/packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx @@ -123,5 +123,5 @@ TooltipTrigger.getCollectionNode = function* (props: SpectrumTooltipTriggerProps * relative to the trigger. */ // We don't want getCollectionNode to show up in the type definition -let _TooltipTrigger = TooltipTrigger as (props: SpectrumTooltipTriggerProps) => JSX.Element; +let _TooltipTrigger = TooltipTrigger as (props: SpectrumTooltipTriggerProps) => React.JSX.Element; export {_TooltipTrigger as TooltipTrigger}; diff --git a/packages/@react-spectrum/tree/src/Tree.tsx b/packages/@react-spectrum/tree/src/Tree.tsx index c1823fd3471..8727b11bbe1 100644 --- a/packages/@react-spectrum/tree/src/Tree.tsx +++ b/packages/@react-spectrum/tree/src/Tree.tsx @@ -12,11 +12,11 @@ import ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium'; import {classNames} from '@react-spectrum/utils'; -import {CollectionBase, Expandable, MultipleSelection, Node} from '@react-types/shared'; +import {CollectionBase, Expandable, Key, MultipleSelection, Node} from '@react-types/shared'; import {FocusRing} from '@react-aria/focus'; import {Item, Section} from '@react-stately/collections'; import {ListLayout} from '@react-stately/layout'; -import React, {Key, useMemo, useRef} from 'react'; +import React, {useMemo, useRef} from 'react'; import styles from '@adobe/spectrum-css-temp/components/treeview/vars.css'; import {TreeState, useTreeState} from '@react-stately/tree'; import {useSelectableCollection, useSelectableItem} from '@react-aria/selection'; diff --git a/packages/@react-stately/collections/src/CollectionBuilder.ts b/packages/@react-stately/collections/src/CollectionBuilder.ts index d2de29f270f..3d7bae6c1e6 100644 --- a/packages/@react-stately/collections/src/CollectionBuilder.ts +++ b/packages/@react-stately/collections/src/CollectionBuilder.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {CollectionBase, CollectionElement, Node} from '@react-types/shared'; +import {CollectionBase, CollectionElement, Key, Node} from '@react-types/shared'; import {PartialNode} from './types'; -import React, {Key, ReactElement} from 'react'; +import React, {ReactElement} from 'react'; interface CollectionBuilderState { renderer?: (value: any) => ReactElement diff --git a/packages/@react-stately/collections/src/Item.ts b/packages/@react-stately/collections/src/Item.ts index 9b070c0813d..de9f2baf0f1 100644 --- a/packages/@react-stately/collections/src/Item.ts +++ b/packages/@react-stately/collections/src/Item.ts @@ -76,5 +76,5 @@ function hasChildItems(props: ItemProps) { } // We don't want getCollectionNode to show up in the type definition -let _Item = Item as (props: ItemProps) => JSX.Element; +let _Item = Item as (props: ItemProps) => React.JSX.Element; export {_Item as Item}; diff --git a/packages/@react-stately/collections/src/Section.ts b/packages/@react-stately/collections/src/Section.ts index 95ef0f3a65c..9c5201b1bab 100644 --- a/packages/@react-stately/collections/src/Section.ts +++ b/packages/@react-stately/collections/src/Section.ts @@ -55,5 +55,5 @@ Section.getCollectionNode = function* getCollectionNode(props: SectionProps(props: SectionProps) => JSX.Element; +let _Section = Section as (props: SectionProps) => React.JSX.Element; export {_Section as Section}; diff --git a/packages/@react-stately/collections/src/types.ts b/packages/@react-stately/collections/src/types.ts index 2038449c3f8..73436def7c8 100644 --- a/packages/@react-stately/collections/src/types.ts +++ b/packages/@react-stately/collections/src/types.ts @@ -10,7 +10,8 @@ * governing permissions and limitations under the License. */ -import {Key, ReactElement, ReactNode} from 'react'; +import {Key} from '@react-types/shared'; +import {ReactElement, ReactNode} from 'react'; export interface PartialNode { type?: string, diff --git a/packages/@react-stately/data/src/useAsyncList.ts b/packages/@react-stately/data/src/useAsyncList.ts index 9cc3bf253ec..a647cc52e83 100644 --- a/packages/@react-stately/data/src/useAsyncList.ts +++ b/packages/@react-stately/data/src/useAsyncList.ts @@ -11,8 +11,8 @@ */ import {createListActions, ListData, ListState} from './useListData'; -import {Key, Reducer, useEffect, useReducer, useRef} from 'react'; -import {LoadingState, Selection, SortDescriptor} from '@react-types/shared'; +import {Key, LoadingState, Selection, SortDescriptor} from '@react-types/shared'; +import {Reducer, useEffect, useReducer, useRef} from 'react'; export interface AsyncListOptions { /** The keys for the initially selected items. */ diff --git a/packages/@react-stately/data/src/useListData.ts b/packages/@react-stately/data/src/useListData.ts index c51448ed6d9..15718788887 100644 --- a/packages/@react-stately/data/src/useListData.ts +++ b/packages/@react-stately/data/src/useListData.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {Key, useMemo, useState} from 'react'; -import {Selection} from '@react-types/shared'; +import {Key, Selection} from '@react-types/shared'; +import {useMemo, useState} from 'react'; export interface ListOptions { /** Initial items in the list. */ diff --git a/packages/@react-stately/data/src/useTreeData.ts b/packages/@react-stately/data/src/useTreeData.ts index 8886cd6f1c4..09a846d1a05 100644 --- a/packages/@react-stately/data/src/useTreeData.ts +++ b/packages/@react-stately/data/src/useTreeData.ts @@ -10,7 +10,8 @@ * governing permissions and limitations under the License. */ -import {Key, useMemo, useState} from 'react'; +import {Key} from '@react-types/shared'; +import {useMemo, useState} from 'react'; export interface TreeOptions { /** Initial root items in the tree. */ diff --git a/packages/@react-stately/dnd/src/useDraggableCollectionState.ts b/packages/@react-stately/dnd/src/useDraggableCollectionState.ts index aa1a52941be..6ebc47ba92b 100644 --- a/packages/@react-stately/dnd/src/useDraggableCollectionState.ts +++ b/packages/@react-stately/dnd/src/useDraggableCollectionState.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Node} from '@react-types/shared'; -import {Key, RefObject, useRef, useState} from 'react'; +import {Collection, DraggableCollectionEndEvent, DraggableCollectionProps, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, Key, Node} from '@react-types/shared'; import {MultipleSelectionManager} from '@react-stately/selection'; +import {RefObject, useRef, useState} from 'react'; export interface DraggableCollectionStateOptions extends DraggableCollectionProps { /** A collection of items. */ diff --git a/packages/@react-stately/dnd/src/useDroppableCollectionState.ts b/packages/@react-stately/dnd/src/useDroppableCollectionState.ts index 7d4e0f302af..d613a1023fa 100644 --- a/packages/@react-stately/dnd/src/useDroppableCollectionState.ts +++ b/packages/@react-stately/dnd/src/useDroppableCollectionState.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {Collection, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Node} from '@react-types/shared'; -import {Key, useCallback, useRef, useState} from 'react'; +import {Collection, DragTypes, DropOperation, DroppableCollectionProps, DropTarget, ItemDropTarget, Key, Node} from '@react-types/shared'; import {MultipleSelectionManager} from '@react-stately/selection'; +import {useCallback, useRef, useState} from 'react'; interface DropOperationEvent { target: DropTarget, diff --git a/packages/@react-stately/grid/src/GridCollection.ts b/packages/@react-stately/grid/src/GridCollection.ts index 8f0462a56f0..6071e02d1d6 100644 --- a/packages/@react-stately/grid/src/GridCollection.ts +++ b/packages/@react-stately/grid/src/GridCollection.ts @@ -9,9 +9,9 @@ * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -import {GridNode, GridRow, GridCollection as IGridCollection} from '@react-types/grid'; -import {Key} from 'react'; +import {GridNode, GridRow, GridCollection as IGridCollection} from '@react-types/grid'; +import {Key} from '@react-types/shared'; interface GridCollectionOptions { columnCount: number, diff --git a/packages/@react-stately/grid/src/useGridState.ts b/packages/@react-stately/grid/src/useGridState.ts index 6686659fe7f..f716f9bb9bd 100644 --- a/packages/@react-stately/grid/src/useGridState.ts +++ b/packages/@react-stately/grid/src/useGridState.ts @@ -1,7 +1,8 @@ import {getChildNodes, getFirstItem, getLastItem} from '@react-stately/collections'; import {GridCollection, GridNode} from '@react-types/grid'; -import {Key, useEffect, useMemo, useRef} from 'react'; +import {Key} from '@react-types/shared'; import {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection'; +import {useEffect, useMemo, useRef} from 'react'; export interface GridState> { collection: C, diff --git a/packages/@react-stately/layout/src/ListLayout.ts b/packages/@react-stately/layout/src/ListLayout.ts index 8388b8dcf04..14823bd96ad 100644 --- a/packages/@react-stately/layout/src/ListLayout.ts +++ b/packages/@react-stately/layout/src/ListLayout.ts @@ -10,11 +10,9 @@ * governing permissions and limitations under the License. */ -import {Collection, DropTarget, DropTargetDelegate, KeyboardDelegate, Node} from '@react-types/shared'; +import {Collection, DropTarget, DropTargetDelegate, Key, KeyboardDelegate, Node} from '@react-types/shared'; import {getChildNodes} from '@react-stately/collections'; import {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer'; -import {Key} from 'react'; -// import { DragTarget, DropTarget, DropPosition } from '@react-types/shared'; export type ListLayoutOptions = { /** The height of a row in px. */ diff --git a/packages/@react-stately/layout/src/TableLayout.ts b/packages/@react-stately/layout/src/TableLayout.ts index fd15f170d3d..658dc5dcca1 100644 --- a/packages/@react-stately/layout/src/TableLayout.ts +++ b/packages/@react-stately/layout/src/TableLayout.ts @@ -11,11 +11,10 @@ */ import {ColumnSize, TableCollection} from '@react-types/table'; -import {DropTarget, Node} from '@react-types/shared'; +import {DropTarget, Key, Node} from '@react-types/shared'; import {getChildNodes} from '@react-stately/collections'; import {GridNode} from '@react-types/grid'; import {InvalidationContext, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer'; -import {Key} from 'react'; import {LayoutNode, ListLayout, ListLayoutOptions} from './ListLayout'; import {TableColumnLayout} from '@react-stately/table'; diff --git a/packages/@react-stately/list/src/ListCollection.ts b/packages/@react-stately/list/src/ListCollection.ts index b46083fe31f..63e477f182d 100644 --- a/packages/@react-stately/list/src/ListCollection.ts +++ b/packages/@react-stately/list/src/ListCollection.ts @@ -10,8 +10,7 @@ * governing permissions and limitations under the License. */ -import {Collection, Node} from '@react-types/shared'; -import {Key} from 'react'; +import {Collection, Key, Node} from '@react-types/shared'; export class ListCollection implements Collection> { private keyMap: Map> = new Map(); diff --git a/packages/@react-stately/list/src/useListState.ts b/packages/@react-stately/list/src/useListState.ts index 1fa64b75907..2505d4dc1f0 100644 --- a/packages/@react-stately/list/src/useListState.ts +++ b/packages/@react-stately/list/src/useListState.ts @@ -10,10 +10,10 @@ * governing permissions and limitations under the License. */ -import {Collection, CollectionStateBase, Node} from '@react-types/shared'; -import {Key, useCallback, useEffect, useMemo, useRef} from 'react'; +import {Collection, CollectionStateBase, Key, Node} from '@react-types/shared'; import {ListCollection} from './ListCollection'; import {MultipleSelectionStateProps, SelectionManager, useMultipleSelectionState} from '@react-stately/selection'; +import {useCallback, useEffect, useMemo, useRef} from 'react'; import {useCollection} from '@react-stately/collections'; export interface ListProps extends CollectionStateBase, MultipleSelectionStateProps { diff --git a/packages/@react-stately/list/src/useSingleSelectListState.ts b/packages/@react-stately/list/src/useSingleSelectListState.ts index f7f31e64647..af6637319c8 100644 --- a/packages/@react-stately/list/src/useSingleSelectListState.ts +++ b/packages/@react-stately/list/src/useSingleSelectListState.ts @@ -10,10 +10,10 @@ * governing permissions and limitations under the License. */ -import {CollectionStateBase, Node, SingleSelection} from '@react-types/shared'; -import {Key, useMemo} from 'react'; +import {CollectionStateBase, Key, Node, SingleSelection} from '@react-types/shared'; import {ListState, useListState} from './useListState'; import {useControlledState} from '@react-stately/utils'; +import {useMemo} from 'react'; export interface SingleSelectListProps extends CollectionStateBase, Omit { /** Filter function to generate a filtered list of nodes. */ diff --git a/packages/@react-stately/selection/src/Selection.ts b/packages/@react-stately/selection/src/Selection.ts index 3d1c3d36f3b..cd945149fa6 100644 --- a/packages/@react-stately/selection/src/Selection.ts +++ b/packages/@react-stately/selection/src/Selection.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; /** * A Selection is a special Set containing Keys, which also has an anchor diff --git a/packages/@react-stately/selection/src/SelectionManager.ts b/packages/@react-stately/selection/src/SelectionManager.ts index 5214db60fe9..ed193a629b3 100644 --- a/packages/@react-stately/selection/src/SelectionManager.ts +++ b/packages/@react-stately/selection/src/SelectionManager.ts @@ -11,10 +11,10 @@ */ import { - Collection, - DisabledBehavior, + Collection, DisabledBehavior, FocusStrategy, Selection as ISelection, + Key, LongPressEvent, Node, PressEvent, @@ -22,7 +22,6 @@ import { SelectionMode } from '@react-types/shared'; import {compareNodeOrder, getChildNodes, getFirstItem} from '@react-stately/collections'; -import {Key} from 'react'; import {MultipleSelectionManager, MultipleSelectionState} from './types'; import {Selection} from './Selection'; diff --git a/packages/@react-stately/selection/src/types.ts b/packages/@react-stately/selection/src/types.ts index c910ac2288c..5852bd9bef7 100644 --- a/packages/@react-stately/selection/src/types.ts +++ b/packages/@react-stately/selection/src/types.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {DisabledBehavior, FocusStrategy, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared'; -import {Key} from 'react'; +import {DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared'; + export interface FocusState { /** Whether the collection is currently focused. */ diff --git a/packages/@react-stately/selection/src/useMultipleSelectionState.ts b/packages/@react-stately/selection/src/useMultipleSelectionState.ts index b3a4f30b258..73320a05024 100644 --- a/packages/@react-stately/selection/src/useMultipleSelectionState.ts +++ b/packages/@react-stately/selection/src/useMultipleSelectionState.ts @@ -10,11 +10,11 @@ * governing permissions and limitations under the License. */ -import {DisabledBehavior, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared'; -import {Key, useEffect, useMemo, useRef, useState} from 'react'; +import {DisabledBehavior, Key, MultipleSelection, SelectionBehavior, SelectionMode} from '@react-types/shared'; import {MultipleSelectionState} from './types'; import {Selection} from './Selection'; import {useControlledState} from '@react-stately/utils'; +import {useEffect, useMemo, useRef, useState} from 'react'; function equalSets(setA, setB) { if (setA.size !== setB.size) { diff --git a/packages/@react-stately/steplist/src/useStepListState.ts b/packages/@react-stately/steplist/src/useStepListState.ts index bd9e4caa1e8..71cb69acf87 100644 --- a/packages/@react-stately/steplist/src/useStepListState.ts +++ b/packages/@react-stately/steplist/src/useStepListState.ts @@ -11,9 +11,9 @@ */ import {AriaStepListProps} from '@react-types/steplist'; -import {Collection, Node} from '@react-types/shared'; -import {Key, useCallback, useEffect, useMemo} from 'react'; +import {Collection, Key, Node} from '@react-types/shared'; import {SingleSelectListState, useSingleSelectListState} from '@react-stately/list'; +import {useCallback, useEffect, useMemo} from 'react'; import {useControlledState} from '@react-stately/utils'; export interface StepListState extends SingleSelectListState { @@ -48,7 +48,7 @@ export function useStepListState(props: AriaStepListProps): selectedKey = collection.getKeyAfter(selectedKey); } } - + return selectedKey; }, [isCompleted]); diff --git a/packages/@react-stately/table/src/Cell.ts b/packages/@react-stately/table/src/Cell.ts index 64ee306d81f..91da2f3856f 100644 --- a/packages/@react-stately/table/src/Cell.ts +++ b/packages/@react-stately/table/src/Cell.ts @@ -12,7 +12,7 @@ import {CellProps} from '@react-types/table'; import {PartialNode} from '@react-stately/collections'; -import {ReactElement} from 'react'; +import React, {ReactElement} from 'react'; function Cell(props: CellProps): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars return null; @@ -36,5 +36,5 @@ Cell.getCollectionNode = function* getCollectionNode(props: CellProps): Gener * A Cell represents the value of a single Column within a Table Row. */ // We don't want getCollectionNode to show up in the type definition -let _Cell = Cell as (props: CellProps) => JSX.Element; +let _Cell = Cell as (props: CellProps) => React.JSX.Element; export {_Cell as Cell}; diff --git a/packages/@react-stately/table/src/Column.ts b/packages/@react-stately/table/src/Column.ts index 6b4d845b7e4..f37421dccee 100644 --- a/packages/@react-stately/table/src/Column.ts +++ b/packages/@react-stately/table/src/Column.ts @@ -79,5 +79,5 @@ Column.getCollectionNode = function* getCollectionNode(props: ColumnProps, * children, or dynamically generated using a function based on the `childColumns` prop. */ // We don't want getCollectionNode to show up in the type definition -let _Column = Column as (props: ColumnProps) => JSX.Element; +let _Column = Column as (props: ColumnProps) => React.JSX.Element; export {_Column as Column}; diff --git a/packages/@react-stately/table/src/Row.ts b/packages/@react-stately/table/src/Row.ts index 5a73e136ec2..1f76adbe9c6 100644 --- a/packages/@react-stately/table/src/Row.ts +++ b/packages/@react-stately/table/src/Row.ts @@ -115,5 +115,5 @@ Row.getCollectionNode = function* getCollectionNode(props: RowProps, conte * based on the columns defined in the TableHeader. */ // We don't want getCollectionNode to show up in the type definition -let _Row = Row as (props: RowProps) => JSX.Element; +let _Row = Row as (props: RowProps) => React.JSX.Element; export {_Row as Row}; diff --git a/packages/@react-stately/table/src/TableBody.ts b/packages/@react-stately/table/src/TableBody.ts index e5d37f734d3..8ef3eaf5425 100644 --- a/packages/@react-stately/table/src/TableBody.ts +++ b/packages/@react-stately/table/src/TableBody.ts @@ -57,5 +57,5 @@ TableBody.getCollectionNode = function* getCollectionNode(props: TableBodyPro * as children, or generated dynamically using a function based on the data passed to the `items` prop. */ // We don't want getCollectionNode to show up in the type definition -let _TableBody = TableBody as (props: TableBodyProps) => JSX.Element; +let _TableBody = TableBody as (props: TableBodyProps) => React.JSX.Element; export {_TableBody as TableBody}; diff --git a/packages/@react-stately/table/src/TableCollection.ts b/packages/@react-stately/table/src/TableCollection.ts index 6e379581e76..3fcf419a01b 100644 --- a/packages/@react-stately/table/src/TableCollection.ts +++ b/packages/@react-stately/table/src/TableCollection.ts @@ -9,11 +9,12 @@ * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ + import {getFirstItem, getLastItem} from '@react-stately/collections'; import {GridCollection} from '@react-stately/grid'; import {GridNode} from '@react-types/grid'; import {TableCollection as ITableCollection} from '@react-types/table'; -import {Key} from 'react'; +import {Key} from '@react-types/shared'; interface GridCollectionOptions { showSelectionCheckboxes?: boolean, diff --git a/packages/@react-stately/table/src/TableColumnLayout.ts b/packages/@react-stately/table/src/TableColumnLayout.ts index fdb0c86d88e..81855ca1148 100644 --- a/packages/@react-stately/table/src/TableColumnLayout.ts +++ b/packages/@react-stately/table/src/TableColumnLayout.ts @@ -19,7 +19,7 @@ import { } from './TableUtils'; import {ColumnSize, TableCollection} from '@react-types/table'; import {GridNode} from '@react-types/grid'; -import {Key} from 'react'; +import {Key} from '@react-types/shared'; export interface TableColumnLayoutOptions { getDefaultWidth?: (column: GridNode) => ColumnSize | null | undefined, diff --git a/packages/@react-stately/table/src/TableHeader.ts b/packages/@react-stately/table/src/TableHeader.ts index bff2d613f04..bbf48b53e8b 100644 --- a/packages/@react-stately/table/src/TableHeader.ts +++ b/packages/@react-stately/table/src/TableHeader.ts @@ -55,5 +55,5 @@ TableHeader.getCollectionNode = function* getCollectionNode(props: TableHeade * as children, or generated dynamically using a function based on the data passed to the `columns` prop. */ // We don't want getCollectionNode to show up in the type definition -let _TableHeader = TableHeader as (props: TableHeaderProps) => JSX.Element; +let _TableHeader = TableHeader as (props: TableHeaderProps) => React.JSX.Element; export {_TableHeader as TableHeader}; diff --git a/packages/@react-stately/table/src/TableUtils.ts b/packages/@react-stately/table/src/TableUtils.ts index c57c4cf141b..4d359ebe16a 100644 --- a/packages/@react-stately/table/src/TableUtils.ts +++ b/packages/@react-stately/table/src/TableUtils.ts @@ -11,7 +11,7 @@ */ import {ColumnSize} from '@react-types/table'; -import {Key} from 'react'; +import {Key} from '@react-types/shared'; // numbers and percents are considered static. *fr units or a lack of units are considered dynamic. export function isStatic(width: number | string): boolean { diff --git a/packages/@react-stately/table/src/useTableColumnResizeState.ts b/packages/@react-stately/table/src/useTableColumnResizeState.ts index d3ad747bb51..81fb4709145 100644 --- a/packages/@react-stately/table/src/useTableColumnResizeState.ts +++ b/packages/@react-stately/table/src/useTableColumnResizeState.ts @@ -12,9 +12,10 @@ import {ColumnSize} from '@react-types/table'; import {GridNode} from '@react-types/grid'; -import {Key, useCallback, useMemo, useState} from 'react'; +import {Key} from '@react-types/shared'; import {TableColumnLayout} from './TableColumnLayout'; import {TableState} from './useTableState'; +import {useCallback, useMemo, useState} from 'react'; export interface TableColumnResizeStateProps { /** diff --git a/packages/@react-stately/table/src/useTableState.ts b/packages/@react-stately/table/src/useTableState.ts index 64b752ed775..7d6dbbef713 100644 --- a/packages/@react-stately/table/src/useTableState.ts +++ b/packages/@react-stately/table/src/useTableState.ts @@ -12,9 +12,9 @@ import {GridState, useGridState} from '@react-stately/grid'; import {TableCollection as ITableCollection, TableBodyProps, TableHeaderProps} from '@react-types/table'; -import {Key, ReactElement, useCallback, useMemo, useState} from 'react'; +import {Key, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared'; import {MultipleSelectionStateProps} from '@react-stately/selection'; -import {Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared'; +import {ReactElement, useCallback, useMemo, useState} from 'react'; import {TableCollection} from './TableCollection'; import {useCollection} from '@react-stately/collections'; diff --git a/packages/@react-stately/table/src/useTreeGridState.ts b/packages/@react-stately/table/src/useTreeGridState.ts index 7a9bcde836f..8f191dd1748 100644 --- a/packages/@react-stately/table/src/useTreeGridState.ts +++ b/packages/@react-stately/table/src/useTreeGridState.ts @@ -12,7 +12,8 @@ import {CollectionBuilder} from '@react-stately/collections'; import {GridNode} from '@react-types/grid'; -import {Key, ReactElement, useMemo} from 'react'; +import {Key} from '@react-types/shared'; +import {ReactElement, useMemo} from 'react'; import {TableCollection} from './TableCollection'; import {tableNestedRows} from '@react-stately/flags'; import {TableState, TableStateProps, useTableState} from './useTableState'; diff --git a/packages/@react-stately/tabs/src/useTabListState.ts b/packages/@react-stately/tabs/src/useTabListState.ts index 2033f86de45..c9d28f43c37 100644 --- a/packages/@react-stately/tabs/src/useTabListState.ts +++ b/packages/@react-stately/tabs/src/useTabListState.ts @@ -10,10 +10,10 @@ * governing permissions and limitations under the License. */ -import {Collection, CollectionStateBase} from '@react-types/shared'; -import {Key, useEffect, useRef} from 'react'; +import {Collection, CollectionStateBase, Key} from '@react-types/shared'; import {SingleSelectListState, useSingleSelectListState} from '@react-stately/list'; import {TabListProps} from '@react-types/tabs'; +import {useEffect, useRef} from 'react'; export interface TabListStateOptions extends Omit, 'children'>, CollectionStateBase {} diff --git a/packages/@react-stately/tree/src/TreeCollection.ts b/packages/@react-stately/tree/src/TreeCollection.ts index 84b37e5d544..e465bd0366e 100644 --- a/packages/@react-stately/tree/src/TreeCollection.ts +++ b/packages/@react-stately/tree/src/TreeCollection.ts @@ -10,8 +10,7 @@ * governing permissions and limitations under the License. */ -import {Collection, Node} from '@react-types/shared'; -import {Key} from 'react'; +import {Collection, Key, Node} from '@react-types/shared'; export class TreeCollection implements Collection> { private keyMap: Map> = new Map(); diff --git a/packages/@react-stately/tree/src/useTreeState.ts b/packages/@react-stately/tree/src/useTreeState.ts index f9eb5e48c13..f43dfbef2e1 100644 --- a/packages/@react-stately/tree/src/useTreeState.ts +++ b/packages/@react-stately/tree/src/useTreeState.ts @@ -10,10 +10,10 @@ * governing permissions and limitations under the License. */ -import {Collection, CollectionStateBase, Expandable, MultipleSelection, Node} from '@react-types/shared'; -import {Key, useCallback, useEffect, useMemo} from 'react'; +import {Collection, CollectionStateBase, Expandable, Key, MultipleSelection, Node} from '@react-types/shared'; import {SelectionManager, useMultipleSelectionState} from '@react-stately/selection'; import {TreeCollection} from './TreeCollection'; +import {useCallback, useEffect, useMemo} from 'react'; import {useCollection} from '@react-stately/collections'; import {useControlledState} from '@react-stately/utils'; diff --git a/packages/@react-stately/tree/stories/useTreeState.stories.tsx b/packages/@react-stately/tree/stories/useTreeState.stories.tsx index e84064e1983..bdba875aaac 100644 --- a/packages/@react-stately/tree/stories/useTreeState.stories.tsx +++ b/packages/@react-stately/tree/stories/useTreeState.stories.tsx @@ -11,8 +11,8 @@ */ import {Item} from '@react-stately/collections'; -import {Node} from '@react-types/shared'; -import React, {Key, useMemo, useRef} from 'react'; +import {Key, Node} from '@react-types/shared'; +import React, {useMemo, useRef} from 'react'; import {TreeCollection} from '../src/TreeCollection'; import {usePress} from '@react-aria/interactions'; import {useSelectableCollection, useSelectableItem} from '@react-aria/selection'; diff --git a/packages/@react-stately/virtualizer/src/Layout.ts b/packages/@react-stately/virtualizer/src/Layout.ts index 4375199cc1e..86bd557b31f 100644 --- a/packages/@react-stately/virtualizer/src/Layout.ts +++ b/packages/@react-stately/virtualizer/src/Layout.ts @@ -11,7 +11,7 @@ */ import {InvalidationContext} from './types'; -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {LayoutInfo} from './LayoutInfo'; // import {Point} from './Point'; import {Rect} from './Rect'; diff --git a/packages/@react-stately/virtualizer/src/LayoutInfo.ts b/packages/@react-stately/virtualizer/src/LayoutInfo.ts index 6983c8d1f3d..e6213dd7103 100644 --- a/packages/@react-stately/virtualizer/src/LayoutInfo.ts +++ b/packages/@react-stately/virtualizer/src/LayoutInfo.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {Rect} from './Rect'; /** diff --git a/packages/@react-stately/virtualizer/src/ReusableView.ts b/packages/@react-stately/virtualizer/src/ReusableView.ts index 8d032f489d0..f2bf03b7828 100644 --- a/packages/@react-stately/virtualizer/src/ReusableView.ts +++ b/packages/@react-stately/virtualizer/src/ReusableView.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {LayoutInfo} from './LayoutInfo'; import {Virtualizer} from './Virtualizer'; diff --git a/packages/@react-stately/virtualizer/src/Transaction.ts b/packages/@react-stately/virtualizer/src/Transaction.ts index e2994e18b68..76411f7ea41 100644 --- a/packages/@react-stately/virtualizer/src/Transaction.ts +++ b/packages/@react-stately/virtualizer/src/Transaction.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; import {LayoutInfo} from './LayoutInfo'; import {ReusableView} from './ReusableView'; diff --git a/packages/@react-stately/virtualizer/src/Virtualizer.ts b/packages/@react-stately/virtualizer/src/Virtualizer.ts index d4371a55965..232827a2dd4 100644 --- a/packages/@react-stately/virtualizer/src/Virtualizer.ts +++ b/packages/@react-stately/virtualizer/src/Virtualizer.ts @@ -11,7 +11,7 @@ */ import {CancelablePromise, easeOut, tween} from './tween'; -import {Collection} from '@react-types/shared'; +import {Collection, Key} from '@react-types/shared'; import {concatIterators, difference, isSetEqual} from './utils'; import { InvalidationContext, @@ -20,7 +20,6 @@ import { VirtualizerDelegate, VirtualizerOptions } from './types'; -import {Key} from 'react'; import {Layout} from './Layout'; import {LayoutInfo} from './LayoutInfo'; import {OverscanManager} from './OverscanManager'; diff --git a/packages/@react-stately/virtualizer/src/types.ts b/packages/@react-stately/virtualizer/src/types.ts index f44cd1f14d9..224c4199ce8 100644 --- a/packages/@react-stately/virtualizer/src/types.ts +++ b/packages/@react-stately/virtualizer/src/types.ts @@ -10,8 +10,7 @@ * governing permissions and limitations under the License. */ -import {Collection} from '@react-types/shared'; -import {Key} from 'react'; +import {Collection, Key} from '@react-types/shared'; import {Layout} from './Layout'; import {LayoutInfo} from './LayoutInfo'; import {Rect, RectCorner} from './Rect'; diff --git a/packages/@react-stately/virtualizer/src/useVirtualizerState.ts b/packages/@react-stately/virtualizer/src/useVirtualizerState.ts index 9332309627b..57f1cf493ae 100644 --- a/packages/@react-stately/virtualizer/src/useVirtualizerState.ts +++ b/packages/@react-stately/virtualizer/src/useVirtualizerState.ts @@ -10,12 +10,12 @@ * governing permissions and limitations under the License. */ -import {Collection} from '@react-types/shared'; -import {Key, useCallback, useEffect, useMemo, useState} from 'react'; +import {Collection, Key} from '@react-types/shared'; import {Layout} from './Layout'; import {Rect} from './Rect'; import {ReusableView} from './ReusableView'; import {Size} from './Size'; +import {useCallback, useEffect, useMemo, useState} from 'react'; import {useLayoutEffect} from '@react-aria/utils'; import {Virtualizer} from './Virtualizer'; diff --git a/packages/@react-types/actionbar/src/index.d.ts b/packages/@react-types/actionbar/src/index.d.ts index 995fd3c86b1..122cf23c7e8 100644 --- a/packages/@react-types/actionbar/src/index.d.ts +++ b/packages/@react-types/actionbar/src/index.d.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {DOMProps, ItemElement, ItemRenderer, StyleProps} from '@react-types/shared'; -import {Key, ReactNode} from 'react'; +import {DOMProps, ItemElement, ItemRenderer, Key, StyleProps} from '@react-types/shared'; +import {ReactNode} from 'react'; export interface ActionBarProps { /** An list of `Item` elements or a function. If the latter, a list of items must be provided using the `items` prop. */ diff --git a/packages/@react-types/actiongroup/src/index.d.ts b/packages/@react-types/actiongroup/src/index.d.ts index 13ef725b051..92ed5217fb2 100644 --- a/packages/@react-types/actiongroup/src/index.d.ts +++ b/packages/@react-types/actiongroup/src/index.d.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, DOMProps, ItemElement, ItemRenderer, MultipleSelection, Orientation, StyleProps} from '@react-types/shared'; -import {Key, ReactElement} from 'react'; +import {AriaLabelingProps, DOMProps, ItemElement, ItemRenderer, Key, MultipleSelection, Orientation, StyleProps} from '@react-types/shared'; +import {ReactElement} from 'react'; // Not extending CollectionBase to avoid async loading props export interface ActionGroupProps extends MultipleSelection { diff --git a/packages/@react-types/autocomplete/src/index.d.ts b/packages/@react-types/autocomplete/src/index.d.ts index 4f8a5e1ecdd..aa1397a0798 100644 --- a/packages/@react-types/autocomplete/src/index.d.ts +++ b/packages/@react-types/autocomplete/src/index.d.ts @@ -10,10 +10,10 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, AsyncLoadable, CollectionBase, DOMProps, LoadingState, SpectrumFieldValidation, SpectrumLabelableProps, SpectrumTextInputBase, StyleProps} from '@react-types/shared'; +import {AriaLabelingProps, AsyncLoadable, CollectionBase, DOMProps, Key, LoadingState, SpectrumFieldValidation, SpectrumLabelableProps, SpectrumTextInputBase, StyleProps} from '@react-types/shared'; import {AriaSearchFieldProps, SearchFieldProps} from '@react-types/searchfield'; -import {Key, ReactElement} from 'react'; import {MenuTriggerAction} from '@react-types/combobox'; +import {ReactElement} from 'react'; export interface SearchAutocompleteProps extends CollectionBase, Omit { /** The list of SearchAutocomplete items (uncontrolled). */ diff --git a/packages/@react-types/breadcrumbs/src/index.d.ts b/packages/@react-types/breadcrumbs/src/index.d.ts index 178e80b65a4..f3cd7b08064 100644 --- a/packages/@react-types/breadcrumbs/src/index.d.ts +++ b/packages/@react-types/breadcrumbs/src/index.d.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, DOMProps, ItemProps, LinkDOMProps, StyleProps} from '@react-types/shared'; +import {AriaLabelingProps, DOMProps, ItemProps, Key, LinkDOMProps, StyleProps} from '@react-types/shared'; import {AriaLinkProps} from '@react-types/link'; -import {Key, ReactElement, ReactNode} from 'react'; +import {ReactElement, ReactNode} from 'react'; export interface BreadcrumbItemProps extends AriaLinkProps, LinkDOMProps { /** Whether the breadcrumb item represents the current page. */ diff --git a/packages/@react-types/combobox/src/index.d.ts b/packages/@react-types/combobox/src/index.d.ts index 82442b88b6d..def488ddfa0 100644 --- a/packages/@react-types/combobox/src/index.d.ts +++ b/packages/@react-types/combobox/src/index.d.ts @@ -10,8 +10,26 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, AsyncLoadable, CollectionBase, DOMProps, FocusableProps, HelpTextProps, InputBase, InputDOMProps, LabelableProps, LoadingState, SingleSelection, SpectrumFieldValidation, SpectrumLabelableProps, SpectrumTextInputBase, StyleProps, TextInputBase, Validation} from '@react-types/shared'; -import {Key} from 'react'; +import { + AriaLabelingProps, + AsyncLoadable, + CollectionBase, + DOMProps, + FocusableProps, + HelpTextProps, + InputBase, + InputDOMProps, + Key, + LabelableProps, + LoadingState, + SingleSelection, + SpectrumFieldValidation, + SpectrumLabelableProps, + SpectrumTextInputBase, + StyleProps, + TextInputBase, + Validation +} from '@react-types/shared'; export type MenuTriggerAction = 'focus' | 'input' | 'manual'; diff --git a/packages/@react-types/grid/src/index.d.ts b/packages/@react-types/grid/src/index.d.ts index 1e7c26255c7..e56c3480bba 100644 --- a/packages/@react-types/grid/src/index.d.ts +++ b/packages/@react-types/grid/src/index.d.ts @@ -10,8 +10,7 @@ * governing permissions and limitations under the License. */ -import {Collection, Node} from '@react-types/shared'; -import {Key} from 'react'; +import {Collection, Key, Node} from '@react-types/shared'; export interface GridCollection extends Collection> { /** The number of columns in the grid. */ diff --git a/packages/@react-types/listbox/src/index.d.ts b/packages/@react-types/listbox/src/index.d.ts index ca5855684c0..ed887021781 100644 --- a/packages/@react-types/listbox/src/index.d.ts +++ b/packages/@react-types/listbox/src/index.d.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, AsyncLoadable, CollectionBase, DOMProps, FocusEvents, FocusStrategy, MultipleSelection, SelectionBehavior, StyleProps} from '@react-types/shared'; -import {Key, ReactNode} from 'react'; +import {AriaLabelingProps, AsyncLoadable, CollectionBase, DOMProps, FocusEvents, FocusStrategy, Key, MultipleSelection, SelectionBehavior, StyleProps} from '@react-types/shared'; +import {ReactNode} from 'react'; export interface ListBoxProps extends CollectionBase, MultipleSelection, FocusEvents { /** Whether to auto focus the listbox or an option. */ diff --git a/packages/@react-types/menu/src/index.d.ts b/packages/@react-types/menu/src/index.d.ts index 603fd338458..d2564749978 100644 --- a/packages/@react-types/menu/src/index.d.ts +++ b/packages/@react-types/menu/src/index.d.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {Alignment, AriaLabelingProps, CollectionBase, DOMProps, FocusStrategy, MultipleSelection, StyleProps} from '@react-types/shared'; -import {Key, ReactElement} from 'react'; +import {Alignment, AriaLabelingProps, CollectionBase, DOMProps, FocusStrategy, Key, MultipleSelection, StyleProps} from '@react-types/shared'; import {OverlayTriggerProps} from '@react-types/overlays'; +import {ReactElement} from 'react'; export type MenuTriggerType = 'press' | 'longPress'; diff --git a/packages/@react-types/select/src/index.d.ts b/packages/@react-types/select/src/index.d.ts index ae2587720ef..fe2320b357d 100644 --- a/packages/@react-types/select/src/index.d.ts +++ b/packages/@react-types/select/src/index.d.ts @@ -21,6 +21,7 @@ import { FocusableProps, HelpTextProps, InputBase, + Key, LabelableProps, SingleSelection, SpectrumLabelableProps, @@ -28,7 +29,6 @@ import { TextInputBase, Validation } from '@react-types/shared'; -import {Key} from 'react'; export interface SelectProps extends CollectionBase, Omit, Validation, HelpTextProps, LabelableProps, TextInputBase, Omit, FocusableProps { /** Sets the open state of the menu. */ diff --git a/packages/@react-types/shared/src/collections.d.ts b/packages/@react-types/shared/src/collections.d.ts index 188f4193be2..18d0be0093d 100644 --- a/packages/@react-types/shared/src/collections.d.ts +++ b/packages/@react-types/shared/src/collections.d.ts @@ -10,8 +10,9 @@ * governing permissions and limitations under the License. */ -import {Key, ReactElement, ReactNode} from 'react'; +import {Key} from '@react-types/shared'; import {LinkDOMProps} from './dom'; +import {ReactElement, ReactNode} from 'react'; export interface ItemProps extends LinkDOMProps { /** Rendered contents of the item or child items. */ diff --git a/packages/@react-types/shared/src/dnd.d.ts b/packages/@react-types/shared/src/dnd.d.ts index 2ac215d4acf..b9d8defdccf 100644 --- a/packages/@react-types/shared/src/dnd.d.ts +++ b/packages/@react-types/shared/src/dnd.d.ts @@ -10,7 +10,8 @@ * governing permissions and limitations under the License. */ -import {Key, RefObject} from 'react'; +import {Key} from '@react-types/shared'; +import {RefObject} from 'react'; export interface DragDropEvent { /** The x coordinate of the event, relative to the target element. */ diff --git a/packages/@react-types/shared/src/index.d.ts b/packages/@react-types/shared/src/index.d.ts index 4f3effca058..a03f171f718 100644 --- a/packages/@react-types/shared/src/index.d.ts +++ b/packages/@react-types/shared/src/index.d.ts @@ -23,3 +23,4 @@ export * from './refs'; export * from './labelable'; export * from './orientation'; export * from './locale'; +export * from './key'; diff --git a/packages/@react-types/shared/src/key.d.ts b/packages/@react-types/shared/src/key.d.ts new file mode 100644 index 00000000000..ef7ce0d22ce --- /dev/null +++ b/packages/@react-types/shared/src/key.d.ts @@ -0,0 +1,13 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +export type Key = string | number; diff --git a/packages/@react-types/shared/src/selection.d.ts b/packages/@react-types/shared/src/selection.d.ts index 63b3be18acd..46d0b9e0e0e 100644 --- a/packages/@react-types/shared/src/selection.d.ts +++ b/packages/@react-types/shared/src/selection.d.ts @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {Key} from 'react'; +import {Key} from '@react-types/shared'; export interface SingleSelection { /** Whether the collection allows empty selection. */ diff --git a/packages/@react-types/sidenav/src/index.d.ts b/packages/@react-types/sidenav/src/index.d.ts index a9dfc3c8388..542ec9903a2 100644 --- a/packages/@react-types/sidenav/src/index.d.ts +++ b/packages/@react-types/sidenav/src/index.d.ts @@ -10,8 +10,8 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, CollectionBase, DOMProps, Expandable, MultipleSelection, Node, StyleProps} from '@react-types/shared'; -import {HTMLAttributes, Key, ReactNode} from 'react'; +import {AriaLabelingProps, CollectionBase, DOMProps, Expandable, Key, MultipleSelection, Node, StyleProps} from '@react-types/shared'; +import {HTMLAttributes, ReactNode} from 'react'; import {LayoutInfo, Size} from '@react-stately/virtualizer'; export interface SideNavProps extends CollectionBase, Expandable, MultipleSelection { diff --git a/packages/@react-types/steplist/src/index.d.ts b/packages/@react-types/steplist/src/index.d.ts index 16badaf306c..b67f3e40f63 100644 --- a/packages/@react-types/steplist/src/index.d.ts +++ b/packages/@react-types/steplist/src/index.d.ts @@ -10,8 +10,15 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, CollectionBase, DOMProps, Orientation, SingleSelection, StyleProps} from '@react-types/shared'; -import {Key} from 'react'; +import { + AriaLabelingProps, + CollectionBase, + DOMProps, + Key, + Orientation, + SingleSelection, + StyleProps +} from '@react-types/shared'; interface StepListProps extends CollectionBase, SingleSelection { /** The key of the last completed step (controlled). */ diff --git a/packages/@react-types/table/src/index.d.ts b/packages/@react-types/table/src/index.d.ts index d7373928c95..16d21d12cb6 100644 --- a/packages/@react-types/table/src/index.d.ts +++ b/packages/@react-types/table/src/index.d.ts @@ -10,9 +10,9 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, AsyncLoadable, DOMProps, LinkDOMProps, LoadingState, MultipleSelection, Sortable, SpectrumSelectionProps, StyleProps} from '@react-types/shared'; +import {AriaLabelingProps, AsyncLoadable, DOMProps, Key, LinkDOMProps, LoadingState, MultipleSelection, Sortable, SpectrumSelectionProps, StyleProps} from '@react-types/shared'; import {GridCollection, GridNode} from '@react-types/grid'; -import {Key, ReactElement, ReactNode} from 'react'; +import React, {ReactElement, ReactNode} from 'react'; /** Widths that result in a constant pixel value for the same Table width. */ export type ColumnStaticSize = number | `${number}` | `${number}%`; // match regex: /^(\d+)(?=%$)/ @@ -49,7 +49,7 @@ export interface SpectrumTableProps extends TableProps, SpectrumSelectionP /** Whether the TableView should be displayed with a quiet style. */ isQuiet?: boolean, /** Sets what the TableView should render when there is no content to display. */ - renderEmptyState?: () => JSX.Element, + renderEmptyState?: () => React.JSX.Element, /** Handler that is called when a user performs an action on a row. */ onAction?: (key: Key) => void, /** diff --git a/packages/@react-types/tabs/src/index.d.ts b/packages/@react-types/tabs/src/index.d.ts index 7b970284869..ebd96c99934 100644 --- a/packages/@react-types/tabs/src/index.d.ts +++ b/packages/@react-types/tabs/src/index.d.ts @@ -11,15 +11,15 @@ */ import { - AriaLabelingProps, - CollectionBase, + AriaLabelingProps, CollectionBase, CollectionChildren, DOMProps, + Key, Orientation, SingleSelection, StyleProps } from '@react-types/shared'; -import {Key, ReactNode} from 'react'; +import {ReactNode} from 'react'; export interface AriaTabProps extends AriaLabelingProps { /** The key of the tab. */ diff --git a/packages/dev/docs/src/PropTable.js b/packages/dev/docs/src/PropTable.js index 0b2f5e6ebf8..d80c31907d1 100644 --- a/packages/dev/docs/src/PropTable.js +++ b/packages/dev/docs/src/PropTable.js @@ -76,7 +76,12 @@ const GROUPS = { }; export function PropTable({component, links, style}) { - let [ungrouped, groups] = groupProps(component.props.properties); + let ungrouped, groups; + if (!component.props) { + [ungrouped, groups] = groupProps(component.parameters[0].value.properties); + } else { + [ungrouped, groups] = groupProps(component.props.properties); + } return (
    diff --git a/packages/dev/eslint-plugin-rsp-rules/index.js b/packages/dev/eslint-plugin-rsp-rules/index.js index 6b664237fe6..d8fdae524f4 100644 --- a/packages/dev/eslint-plugin-rsp-rules/index.js +++ b/packages/dev/eslint-plugin-rsp-rules/index.js @@ -1,9 +1,13 @@ let noGetByRoleToThrow = require('./rules/no-getByRole-toThrow'); let actEventsTest = require('./rules/act-events-test'); +let noReactKey = require('./rules/no-react-key'); +let sortImports = require('./rules/sort-imports'); const rules = { 'act-events-test': actEventsTest, - 'no-getByRole-toThrow': noGetByRoleToThrow + 'no-getByRole-toThrow': noGetByRoleToThrow, + 'no-react-key': noReactKey, + 'sort-imports': sortImports }; diff --git a/packages/dev/eslint-plugin-rsp-rules/rules/no-react-key.js b/packages/dev/eslint-plugin-rsp-rules/rules/no-react-key.js new file mode 100644 index 00000000000..9cc1e22914b --- /dev/null +++ b/packages/dev/eslint-plugin-rsp-rules/rules/no-react-key.js @@ -0,0 +1,74 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +module.exports = { + meta: { + type: 'suggestion', + docs: { + description: 'Checks and fixes usage of React.Key' + }, + fixable: 'code', + schema: [] // no options + }, + create: function (context) { + return { + // Could be improved to look up the local name of Key and preserve it + ImportSpecifier(node) { + if (node.imported.name === 'Key' && node.parent.source.value === 'react') { + context.report({ + node, + message: 'Do not use React.Key. Instead, use ReactAria.Key.', + fix: (fixer) => { + let defaultSpecifier = node.parent.specifiers.find(node => node.type === 'ImportDefaultSpecifier'); + let fixes = []; + if (node.parent.specifiers.length === 1) { + // covers case 'import {Key} from 'react';' + fixes.push(fixer.remove(node.parent)); + } else if (node.parent.specifiers.filter(node => node.type === 'ImportSpecifier').length === 1) { + // covers case 'import React, {Key} from 'react';' + fixes.push(fixer.removeRange([defaultSpecifier.range[1], node.range[1] + 1])); + } else if (node.parent.specifiers.filter(node => node.type === 'ImportSpecifier').length > 1) { + // covers case 'import {Foo, Key} from 'react';' + if (node.parent.specifiers[node.parent.specifiers.length - 1] === node) { + fixes.push(fixer.removeRange([node.range[0] - 2, node.range[1]])); + } else { + // and case 'import {Key, ReactElement, ReactNode} from 'react';' + fixes.push(fixer.removeRange([node.range[0], node.range[1] + 2])); + } + } + let sharedImport = node.parent.parent.body.find(node => node.type === 'ImportDeclaration' && node.source.value === '@react-types/shared'); + if (sharedImport) { + // handles existing import from '@react-types/shared' + let firstSpecifier = sharedImport.specifiers.find(node => node.type === 'ImportSpecifier'); + fixes.push(fixer.insertTextAfter(firstSpecifier, ', Key')); + return fixes; + } + // handles no existing import from '@react-types/shared' + let lastImport = node.parent.parent.body.findLast(node => node.type === 'ImportDeclaration'); + fixes.push(fixer.insertTextAfter(lastImport, "\nimport {Key} from '@react-types/shared';")); + return fixes; + } + }); + } + }, + Identifier(node) { + // Could be improved by looking up the local name of React + if (node.name === 'Key' && (node.parent?.object?.name === 'React' || node.parent?.left?.name === 'React')) { + context.report({ + node, + message: 'Do not use React.Key. Instead, use ReactAria.Key.' + }); + } + } + }; + } +}; diff --git a/bin/sort-imports.js b/packages/dev/eslint-plugin-rsp-rules/rules/sort-imports.js similarity index 100% rename from bin/sort-imports.js rename to packages/dev/eslint-plugin-rsp-rules/rules/sort-imports.js diff --git a/packages/dev/eslint-plugin-rsp-rules/test/no-react-key.test.js b/packages/dev/eslint-plugin-rsp-rules/test/no-react-key.test.js new file mode 100644 index 00000000000..e5e38b462be --- /dev/null +++ b/packages/dev/eslint-plugin-rsp-rules/test/no-react-key.test.js @@ -0,0 +1,99 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import noReactKeyRule from '../rules/no-react-key'; +import {RuleTester} from 'eslint'; + + +const ruleTester = new RuleTester({ + // Must use at least ecmaVersion 2015 because + // that's when `const` variables were introduced. + parserOptions: { + ecmaVersion: 2015, + 'sourceType': 'module' + } +}); + +// Throws error if the tests in ruleTester.run() do not pass +ruleTester.run( + 'no-react-key', // rule name + noReactKeyRule, // rule code + { // checks + // 'valid' checks cases that should pass + valid: [{ + code: "import {Key} from '@react-types/shared';" + }], + // 'invalid' checks cases that should not pass + invalid: [{ + code: "import {Key} from 'react';", + output: ` +import {Key} from '@react-types/shared';`, + errors: 1 + }, { + code: "import React, {Key} from 'react';", + output: `import React from 'react'; +import {Key} from '@react-types/shared';`, + errors: 1 + }, { + code: `import React, {Key, useState} from 'react'; +import {Foo} from 'bar'; + +let a = 'a';`, + output: `import React, {useState} from 'react'; +import {Foo} from 'bar'; +import {Key} from '@react-types/shared'; + +let a = 'a';`, + errors: 1 + }, { + code: "import {Key, ReactElement, ReactNode} from 'react';", + output: `import {ReactElement, ReactNode} from 'react'; +import {Key} from '@react-types/shared';`, + errors: 1 + }, { + code: "import {HTMLAttributes, Key, RefObject} from 'react';", + output: `import {HTMLAttributes, RefObject} from 'react'; +import {Key} from '@react-types/shared';`, + errors: 1 + }, { + code: ` +import {foo} from '@react-types/shared'; +import {Key} from 'react';`, + output: ` +import {foo, Key} from '@react-types/shared'; +`, + errors: 1 + }, { + code: ` +import {Node} from '@react-types/shared'; +import React, {Fragment, Key} from 'react'; +`, + output: ` +import {Node, Key} from '@react-types/shared'; +import React, {Fragment} from 'react'; +`, + errors: 1 + }, { + code: ` +import React from 'react'; +let a = React.Key; +`, + errors: 1 + }, { + code: ` +import React from 'react'; +let a = useState(null); +`, + errors: 1 + }] + } +); diff --git a/packages/dev/eslint-plugin-rsp-rules/test/sort-imports.test.js b/packages/dev/eslint-plugin-rsp-rules/test/sort-imports.test.js new file mode 100644 index 00000000000..5d60fa9a713 --- /dev/null +++ b/packages/dev/eslint-plugin-rsp-rules/test/sort-imports.test.js @@ -0,0 +1,60 @@ +/* + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import {RuleTester} from 'eslint'; +import sortImportsRule from '../rules/sort-imports'; + + +const ruleTester = new RuleTester({ + // Must use at least ecmaVersion 2015 because + // that's when `const` variables were introduced. + parserOptions: { + ecmaVersion: 2015, + 'sourceType': 'module' + } +}); + +// Throws error if the tests in ruleTester.run() do not pass +ruleTester.run( + 'no-react-key', // rule name + sortImportsRule, // rule code + { // checks + // 'valid' checks cases that should pass + valid: [{ + code: "import {A, B} from 'foo';" + }, { + code: ` +import {A} from 'foo'; +import {B} from 'bar'; +` + }], + // 'invalid' checks cases that should not pass + invalid: [{ + code: "import {B, A} from 'foo';", + output: "import {A, B} from 'foo';", + errors: 1 + } + // we don't support this case yet +// { +// code: ` +// import {B} from 'bar'; +// import {A} from 'foo'; +// `, +// output: ` +// import {A} from 'foo'; +// import {B} from 'bar'; +// `, +// errors: 1 +// } + ] + } +); diff --git a/packages/dev/parcel-transformer-docs/DocsTransformer.js b/packages/dev/parcel-transformer-docs/DocsTransformer.js index 39af957a14f..bb48e794656 100644 --- a/packages/dev/parcel-transformer-docs/DocsTransformer.js +++ b/packages/dev/parcel-transformer-docs/DocsTransformer.js @@ -296,6 +296,12 @@ module.exports = new Transformer({ } } + if (left.name === undefined) { + return Object.assign(node, { + type: 'identifier', + name: path.node.left.name + '.' + path.node.right.name + }); + } return Object.assign(node, { type: 'identifier', name: left.name + '.' + path.node.right.name diff --git a/packages/dev/parcel-transformer-docs/__tests__/DocsTransformer.parceltest.tsx b/packages/dev/parcel-transformer-docs/__tests__/DocsTransformer.parceltest.tsx index 505950368ae..e17116d2a15 100644 --- a/packages/dev/parcel-transformer-docs/__tests__/DocsTransformer.parceltest.tsx +++ b/packages/dev/parcel-transformer-docs/__tests__/DocsTransformer.parceltest.tsx @@ -205,7 +205,7 @@ describe('DocsTransformer - API', () => { `); await writeSourceFile('index', ` import {Column, SpectrumColumnProps} from './column'; - const SpectrumColumn = Column as (props: SpectrumColumnProps) => JSX.Element; + const SpectrumColumn = Column as (props: SpectrumColumnProps) => React.JSX.Element; export {SpectrumColumn as Column}; `); let code = await runBuild(); diff --git a/packages/react-aria-components/docs/Breadcrumbs.mdx b/packages/react-aria-components/docs/Breadcrumbs.mdx index 6aa2e45d1d8..01dc3d85ae3 100644 --- a/packages/react-aria-components/docs/Breadcrumbs.mdx +++ b/packages/react-aria-components/docs/Breadcrumbs.mdx @@ -179,6 +179,7 @@ as shown below, can be used when the options come from an external data source s As seen below, an iterable list of options is passed to the Breadcrumbs using the `items` prop. A function provided as `children` of the `` is called to render each item. When a breadcrumb is pressed, the `onAction` event is triggered and the breadcrumbs array is updated. ```tsx example +import {Key} from '@react-types/shared'; function Example() { let [breadcrumbs, setBreadcrumbs] = React.useState([ {id: 1, label: 'Home'}, @@ -186,7 +187,7 @@ function Example() { {id: 3, label: 'March 2022 Assets'} ]); - let navigate = (id: React.Key) => { + let navigate = (id: Key) => { let i = breadcrumbs.findIndex(item => item.id === id); setBreadcrumbs(breadcrumbs.slice(0, i + 1)); }; @@ -378,7 +379,7 @@ function Router({children}) { ]); // Pop stack when a breadcrumb item is clicked. - let onAction = (id: React.Key) => { + let onAction = (id: Key) => { let i = items.findIndex(item => item.id === id); setItems(items.slice(0, i + 1)); }; diff --git a/packages/react-aria-components/docs/ComboBox.mdx b/packages/react-aria-components/docs/ComboBox.mdx index 227e6f967b6..6b0128bb6b3 100644 --- a/packages/react-aria-components/docs/ComboBox.mdx +++ b/packages/react-aria-components/docs/ComboBox.mdx @@ -413,6 +413,7 @@ is passed to the `onSelectionChange` handler to identify the selected item. Alte as shown in the example below, then this is used automatically and an `id` prop is not required. ```tsx example +import {Key} from '@react-types/shared'; function Example() { let options = [ {id: 1, name: 'Aerospace'}, @@ -425,7 +426,7 @@ function Example() { {id: 8, name: 'Agricultural'}, {id: 9, name: 'Electrical'} ]; - let [majorId, setMajorId] = React.useState(null); + let [majorId, setMajorId] = React.useState(null); return ( <> @@ -550,7 +551,7 @@ function Example() { {id: 8, name: 'Adobe Fresco'}, {id: 9, name: 'Adobe Dreamweaver'} ]; - let [productId, setProductId] = React.useState(9); + let [productId, setProductId] = React.useState(9); return (
    @@ -842,7 +843,7 @@ function ControlledComboBox() { inputValue: '' }); - let onSelectionChange = (id: React.Key) => { + let onSelectionChange = (id: Key) => { setFieldState({ inputValue: options.find(o => o.id === id)?.name ?? '', selectedKey: id @@ -1003,7 +1004,7 @@ The `description` slot can be used to associate additional help text with a Comb ```tsx example function Example() { - let [animalId, setAnimalId] = React.useState(null); + let [animalId, setAnimalId] = React.useState(null); let options = [ { id: 1, name: 'Aardvark' }, { id: 2, name: 'Cat' }, diff --git a/packages/react-aria-components/docs/Select.mdx b/packages/react-aria-components/docs/Select.mdx index bfca5882a0e..892123ef79b 100644 --- a/packages/react-aria-components/docs/Select.mdx +++ b/packages/react-aria-components/docs/Select.mdx @@ -447,6 +447,7 @@ When `Select` is used with a dynamic collection as described above, the id of ea See the `react-stately` [Selection docs](../react-stately/selection.html) for more details. ```tsx example +import {Key} from '@react-types/shared'; function Example() { let options = [ {name: 'Koala'}, @@ -456,7 +457,7 @@ function Example() { {name: 'Bison'}, {name: 'Skunk'} ]; - let [animal, setAnimal] = React.useState("Bison"); + let [animal, setAnimal] = React.useState("Bison"); return ( (null); + let [animalId, setAnimalId] = React.useState(null); let options = [ { id: 1, name: 'Aardvark' }, { id: 2, name: 'Cat' }, diff --git a/packages/react-aria-components/docs/Tabs.mdx b/packages/react-aria-components/docs/Tabs.mdx index dfae090be10..6196e619543 100644 --- a/packages/react-aria-components/docs/Tabs.mdx +++ b/packages/react-aria-components/docs/Tabs.mdx @@ -253,8 +253,9 @@ See the `react-stately` [Selection docs](../react-stately/selection.html) for mo Selection can be controlled using the `selectedKey` prop, paired with the `onSelectionChange` event. The `id` prop from the selected tab will be passed into the callback when the tab is selected, allowing you to update state accordingly. ```tsx example +import {Key} from '@react-types/shared'; function Example() { - let [timePeriod, setTimePeriod] = React.useState('triassic'); + let [timePeriod, setTimePeriod] = React.useState('triassic'); return ( <> diff --git a/packages/react-aria-components/src/Breadcrumbs.tsx b/packages/react-aria-components/src/Breadcrumbs.tsx index b3bea95cb39..6530eed75dc 100644 --- a/packages/react-aria-components/src/Breadcrumbs.tsx +++ b/packages/react-aria-components/src/Breadcrumbs.tsx @@ -14,8 +14,9 @@ import {Collection, Node} from 'react-stately'; import {CollectionProps, useCollection, useSSRCollectionNode} from './Collection'; import {ContextValue, forwardRefType, SlotProps, StyleProps, useContextProps} from './utils'; import {filterDOMProps} from '@react-aria/utils'; +import {Key} from '@react-types/shared'; import {LinkContext} from './Link'; -import React, {createContext, ForwardedRef, forwardRef, Key, ReactNode, RefObject} from 'react'; +import React, {createContext, ForwardedRef, forwardRef, ReactNode, RefObject} from 'react'; export interface BreadcrumbsProps extends Omit, 'disabledKeys'>, AriaBreadcrumbsProps, StyleProps, SlotProps { /** Whether the breadcrumbs are disabled. */ @@ -78,7 +79,7 @@ export interface BreadcrumbProps extends StyleProps { children: ReactNode } -function Breadcrumb(props: BreadcrumbProps, ref: ForwardedRef): JSX.Element | null { +function Breadcrumb(props: BreadcrumbProps, ref: ForwardedRef): React.JSX.Element | null { return useSSRCollectionNode('item', props, ref, props.children); } diff --git a/packages/react-aria-components/src/Collection.tsx b/packages/react-aria-components/src/Collection.tsx index b979fc7ab02..27ae5f02205 100644 --- a/packages/react-aria-components/src/Collection.tsx +++ b/packages/react-aria-components/src/Collection.tsx @@ -9,12 +9,12 @@ * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -import {CollectionBase} from '@react-types/shared'; +import {CollectionBase, Key} from '@react-types/shared'; import {createPortal} from 'react-dom'; import {forwardRefType, StyleProps} from './utils'; import {Collection as ICollection, Node, SelectionBehavior, SelectionMode, SectionProps as SharedSectionProps} from 'react-stately'; import {mergeProps, useIsSSR} from 'react-aria'; -import React, {cloneElement, createContext, ForwardedRef, forwardRef, Key, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef} from 'react'; +import React, {cloneElement, createContext, ForwardedRef, forwardRef, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef} from 'react'; import {useSyncExternalStore as useSyncExternalStoreShim} from 'use-sync-external-store/shim/index.js'; // This Collection implementation is perhaps a little unusual. It works by rendering the React tree into a @@ -892,7 +892,7 @@ export interface SectionProps extends Omit, 'children' children?: ReactNode | ((item: T) => ReactElement) } -function Section(props: SectionProps, ref: ForwardedRef): JSX.Element | null { +function Section(props: SectionProps, ref: ForwardedRef): React.JSX.Element | null { let children = useCollectionChildren(props); return useSSRCollectionNode('section', props, ref, null, children); } @@ -904,7 +904,7 @@ export const CollectionContext = createContext | export const CollectionRendererContext = createContext['children']>(null); /** A Collection renders a list of items, automatically managing caching and keys. */ -export function Collection(props: CollectionProps): JSX.Element { +export function Collection(props: CollectionProps): React.JSX.Element { let ctx = useContext(CollectionContext)!; props = mergeProps(ctx, props); let renderer = typeof props.children === 'function' ? props.children : null; diff --git a/packages/react-aria-components/src/DateField.tsx b/packages/react-aria-components/src/DateField.tsx index fd3f928008f..15d9a9378e2 100644 --- a/packages/react-aria-components/src/DateField.tsx +++ b/packages/react-aria-components/src/DateField.tsx @@ -201,7 +201,7 @@ export interface DateInputProps extends SlotProps, StyleRenderProps ReactElement } -function DateInput(props: DateInputProps, ref: ForwardedRef): JSX.Element { +function DateInput(props: DateInputProps, ref: ForwardedRef): React.JSX.Element { // If state is provided by DateField/TimeField, just render. // Otherwise (e.g. in DatePicker), we need to call hooks and create state ourselves. let dateFieldState = useContext(DateFieldStateContext); diff --git a/packages/react-aria-components/src/GridList.tsx b/packages/react-aria-components/src/GridList.tsx index 48c4346ece2..a6daa5b7ab7 100644 --- a/packages/react-aria-components/src/GridList.tsx +++ b/packages/react-aria-components/src/GridList.tsx @@ -17,9 +17,9 @@ import {CollectionProps, ItemRenderProps, useCachedChildren, useCollection, useS import {ContextValue, defaultSlot, forwardRefType, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps} from './utils'; import {DragAndDropContext, DragAndDropHooks, DropIndicator, DropIndicatorContext, DropIndicatorProps} from './useDragAndDrop'; import {filterDOMProps, useObjectRef} from '@react-aria/utils'; -import {LinkDOMProps} from '@react-types/shared'; +import {Key, LinkDOMProps} from '@react-types/shared'; import {ListStateContext} from './ListBox'; -import React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, Key, ReactNode, RefObject, useContext, useEffect, useRef} from 'react'; +import React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, ReactNode, RefObject, useContext, useEffect, useRef} from 'react'; import {TextContext} from './Text'; export interface GridListRenderProps { @@ -119,7 +119,7 @@ function GridListInner({props, collection, gridListRef: ref}: let dropState: DroppableCollectionState | undefined = undefined; let droppableCollection: DroppableCollectionResult | undefined = undefined; let isRootDropTarget = false; - let dragPreview: JSX.Element | null = null; + let dragPreview: React.JSX.Element | null = null; let preview = useRef(null); if (isListDraggable && dragAndDropHooks) { diff --git a/packages/react-aria-components/src/ListBox.tsx b/packages/react-aria-components/src/ListBox.tsx index d7009e5322b..c4ba450e028 100644 --- a/packages/react-aria-components/src/ListBox.tsx +++ b/packages/react-aria-components/src/ListBox.tsx @@ -17,8 +17,8 @@ import {DragAndDropContext, DragAndDropHooks, DropIndicator, DropIndicatorContex import {DraggableCollectionState, DroppableCollectionState, ListState, Node, Orientation, SelectionBehavior, useListState} from 'react-stately'; import {filterDOMProps, mergeRefs, useObjectRef} from '@react-aria/utils'; import {Header} from './Header'; -import {LinkDOMProps} from '@react-types/shared'; -import React, {createContext, ForwardedRef, forwardRef, Key, ReactNode, RefObject, useContext, useEffect, useMemo, useRef} from 'react'; +import {Key, LinkDOMProps} from '@react-types/shared'; +import React, {createContext, ForwardedRef, forwardRef, ReactNode, RefObject, useContext, useEffect, useMemo, useRef} from 'react'; import {Separator, SeparatorContext} from './Separator'; import {TextContext} from './Text'; @@ -137,7 +137,7 @@ function ListBoxInner({state, props, listBoxRef}: ListBoxInnerProps) { collection, collator, ref: listBoxRef, - disabledKeys: disabledBehavior === 'selection' ? new Set() : disabledKeys, + disabledKeys: disabledBehavior === 'selection' ? new Set() : disabledKeys, layout, orientation, direction @@ -181,7 +181,7 @@ function ListBoxInner({state, props, listBoxRef}: ListBoxInnerProps) { let dropState: DroppableCollectionState | undefined = undefined; let droppableCollection: DroppableCollectionResult | undefined = undefined; let isRootDropTarget = false; - let dragPreview: JSX.Element | null = null; + let dragPreview: React.JSX.Element | null = null; let preview = useRef(null); if (isListDraggable && dragAndDropHooks) { @@ -229,7 +229,7 @@ function ListBoxInner({state, props, listBoxRef}: ListBoxInnerProps) { values: renderValues }); - let emptyState: JSX.Element | null = null; + let emptyState: React.JSX.Element | null = null; if (state.collection.size === 0 && props.renderEmptyState) { emptyState = (
    (props: SelectValueProps, ref: Forwarde : null; let rendered = selectedItem?.rendered; if (typeof rendered === 'function') { - // If the selected item has a function as a child, we need to call it to render to JSX. + // If the selected item has a function as a child, we need to call it to render to React.JSX. let fn = rendered as (s: ItemRenderProps) => ReactNode; rendered = fn({ isHovered: false, diff --git a/packages/react-aria-components/src/Table.tsx b/packages/react-aria-components/src/Table.tsx index 965555c1bb8..99b223248bc 100644 --- a/packages/react-aria-components/src/Table.tsx +++ b/packages/react-aria-components/src/Table.tsx @@ -1,4 +1,4 @@ -import {AriaLabelingProps, LinkDOMProps} from '@react-types/shared'; +import {AriaLabelingProps, Key, LinkDOMProps} from '@react-types/shared'; import {BaseCollection, CollectionContext, CollectionProps, CollectionRendererContext, ItemRenderProps, NodeValue, useCachedChildren, useCollection, useCollectionChildren, useSSRCollectionNode} from './Collection'; import {buildHeaderRows, TableColumnResizeState} from '@react-stately/table'; import {ButtonContext} from './Button'; @@ -12,7 +12,7 @@ import {filterDOMProps, useLayoutEffect, useObjectRef, useResizeObserver} from ' import {GridNode} from '@react-types/grid'; // @ts-ignore import intlMessages from '../intl/*.json'; -import React, {createContext, ForwardedRef, forwardRef, Key, ReactElement, ReactNode, RefObject, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; +import React, {createContext, ForwardedRef, forwardRef, ReactElement, ReactNode, RefObject, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; import ReactDOM from 'react-dom'; class TableCollection extends BaseCollection implements ITableCollection { @@ -324,7 +324,7 @@ function Table(props: TableProps, ref: ForwardedRef) { let dropState: DroppableCollectionState | undefined = undefined; let droppableCollection: DroppableCollectionResult | undefined = undefined; let isRootDropTarget = false; - let dragPreview: JSX.Element | null = null; + let dragPreview: React.JSX.Element | null = null; let preview = useRef(null); if (isListDraggable && dragAndDropHooks) { @@ -547,7 +547,7 @@ export interface ColumnProps extends RenderProps maxWidth?: ColumnStaticSize | null } -function Column(props: ColumnProps, ref: ForwardedRef): JSX.Element | null { +function Column(props: ColumnProps, ref: ForwardedRef): React.JSX.Element | null { let render = useContext(CollectionRendererContext); let childColumns: ReactNode | ((item: T) => ReactNode); if (typeof render === 'function') { @@ -588,7 +588,7 @@ export interface TableBodyProps extends CollectionProps, StyleRenderProps< renderEmptyState?: (props: TableBodyRenderProps) => ReactNode } -function TableBody(props: TableBodyProps, ref: ForwardedRef): JSX.Element | null { +function TableBody(props: TableBodyProps, ref: ForwardedRef): React.JSX.Element | null { let children = useCollectionChildren(props); return useSSRCollectionNode('tablebody', props, ref, null, children); } @@ -611,7 +611,7 @@ export interface RowProps extends StyleRenderProps, LinkDOMPr textValue?: string } -function Row(props: RowProps, ref: ForwardedRef): JSX.Element | null { +function Row(props: RowProps, ref: ForwardedRef): React.JSX.Element | null { let children = useCollectionChildren({ children: props.children, items: props.columns, @@ -662,7 +662,7 @@ export interface CellProps extends RenderProps { textValue?: string } -function Cell(props: CellProps, ref: ForwardedRef): JSX.Element | null { +function Cell(props: CellProps, ref: ForwardedRef): React.JSX.Element | null { return useSSRCollectionNode('cell', props, ref, props.children); } diff --git a/packages/react-aria-components/src/Tabs.tsx b/packages/react-aria-components/src/Tabs.tsx index a92d40b139c..abdc03b8a40 100644 --- a/packages/react-aria-components/src/Tabs.tsx +++ b/packages/react-aria-components/src/Tabs.tsx @@ -10,13 +10,13 @@ * governing permissions and limitations under the License. */ -import {AriaLabelingProps, LinkDOMProps} from '@react-types/shared'; +import {AriaLabelingProps, Key, LinkDOMProps} from '@react-types/shared'; import {AriaTabListProps, AriaTabPanelProps, mergeProps, Orientation, useFocusRing, useHover, useTab, useTabList, useTabPanel} from 'react-aria'; import {Collection, Node, TabListState, useTabListState} from 'react-stately'; import {CollectionDocumentContext, CollectionPortal, CollectionProps, useCollectionDocument, useSSRCollectionNode} from './Collection'; import {ContextValue, createHideableComponent, forwardRefType, Hidden, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlottedContext} from './utils'; import {filterDOMProps, useObjectRef} from '@react-aria/utils'; -import React, {createContext, ForwardedRef, forwardRef, Key, RefObject, useContext, useMemo} from 'react'; +import React, {createContext, ForwardedRef, forwardRef, RefObject, useContext, useMemo} from 'react'; export interface TabsProps extends Omit, 'items' | 'children'>, RenderProps, SlotProps {} @@ -191,7 +191,7 @@ function TabsInner({props, tabsRef: ref, collection}: TabsInnerProps) { const _Tabs = /*#__PURE__*/ (forwardRef as forwardRefType)(Tabs); export {_Tabs as Tabs}; -function TabList(props: TabListProps, ref: ForwardedRef): JSX.Element { +function TabList(props: TabListProps, ref: ForwardedRef): React.JSX.Element { let document = useContext(CollectionDocumentContext); return document ? @@ -251,7 +251,7 @@ function TabListInner({props, forwardedRef: ref}: TabListInner const _TabList = /*#__PURE__*/ (forwardRef as forwardRefType)(TabList); export {_TabList as TabList}; -function Tab(props: TabProps, ref: ForwardedRef): JSX.Element | null { +function Tab(props: TabProps, ref: ForwardedRef): React.JSX.Element | null { return useSSRCollectionNode('item', props, ref, props.children); } diff --git a/packages/react-aria-components/src/TagGroup.tsx b/packages/react-aria-components/src/TagGroup.tsx index b7dd6f3e103..9f29af6198a 100644 --- a/packages/react-aria-components/src/TagGroup.tsx +++ b/packages/react-aria-components/src/TagGroup.tsx @@ -15,11 +15,11 @@ import {ButtonContext} from './Button'; import {CollectionDocumentContext, CollectionProps, ItemRenderProps, useCachedChildren, useCollectionDocument, useCollectionPortal, useSSRCollectionNode} from './Collection'; import {ContextValue, DOMProps, forwardRefType, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils'; import {filterDOMProps, mergeProps, useObjectRef} from '@react-aria/utils'; +import {Key, LinkDOMProps} from '@react-types/shared'; import {LabelContext} from './Label'; -import {LinkDOMProps} from '@react-types/shared'; import {ListState, Node, useListState} from 'react-stately'; import {ListStateContext} from './ListBox'; -import React, {createContext, ForwardedRef, forwardRef, Key, ReactNode, useContext, useEffect, useRef} from 'react'; +import React, {createContext, ForwardedRef, forwardRef, ReactNode, useContext, useEffect, useRef} from 'react'; import {TextContext} from './Text'; export interface TagGroupProps extends Omit, 'children' | 'items' | 'label' | 'description' | 'errorMessage' | 'keyboardDelegate'>, DOMProps, SlotProps {} @@ -196,7 +196,7 @@ export interface TagProps extends RenderProps, LinkDOMProps { textValue?: string } -function Tag(props: TagProps, ref: ForwardedRef): JSX.Element | null { +function Tag(props: TagProps, ref: ForwardedRef): React.JSX.Element | null { return useSSRCollectionNode('item', props, ref, props.children); } diff --git a/packages/react-aria-components/src/useDragAndDrop.tsx b/packages/react-aria-components/src/useDragAndDrop.tsx index ebabd4ff081..ff12dddfb58 100644 --- a/packages/react-aria-components/src/useDragAndDrop.tsx +++ b/packages/react-aria-components/src/useDragAndDrop.tsx @@ -31,7 +31,7 @@ import { useDroppableCollection, useDroppableItem } from 'react-aria'; -import {DraggableCollectionProps, DroppableCollectionProps} from '@react-types/shared'; +import {DraggableCollectionProps, DroppableCollectionProps, Key} from '@react-types/shared'; import { DraggableCollectionState, DraggableCollectionStateOptions, @@ -40,7 +40,7 @@ import { useDraggableCollectionState, useDroppableCollectionState } from 'react-stately'; -import React, {createContext, ForwardedRef, forwardRef, Key, ReactNode, RefObject, useContext, useMemo} from 'react'; +import React, {createContext, ForwardedRef, forwardRef, ReactNode, RefObject, useContext, useMemo} from 'react'; import {RenderProps} from './utils'; interface DraggableCollectionStateOpts extends Omit {} @@ -50,7 +50,7 @@ interface DragHooks { useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject) => void, useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult, DragPreview?: typeof DragPreview, - renderDragPreview?: (items: DragItem[]) => JSX.Element + renderDragPreview?: (items: DragItem[]) => React.JSX.Element } interface DropHooks { @@ -58,7 +58,7 @@ interface DropHooks { useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject) => DroppableCollectionResult, useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject) => DroppableItemResult, useDropIndicator?: (props: AriaDropIndicatorProps, state: DroppableCollectionState, ref: RefObject) => DropIndicatorAria, - renderDropIndicator?: (target: DropTarget) => JSX.Element, + renderDropIndicator?: (target: DropTarget) => React.JSX.Element, dropTargetDelegate?: DropTargetDelegate, ListDropTargetDelegate: typeof ListDropTargetDelegate } @@ -80,13 +80,13 @@ export interface DragAndDropOptions extends Omit JSX.Element, + renderDragPreview?: (items: DragItem[]) => React.JSX.Element, /** * A function that renders a drop indicator element between two items in a collection. * This should render a `` element. If this function is not provided, a * default DropIndicator is provided. */ - renderDropIndicator?: (target: DropTarget) => JSX.Element, + renderDropIndicator?: (target: DropTarget) => React.JSX.Element, /** A custom delegate object that provides drop targets for pointer coordinates within the collection. */ dropTargetDelegate?: DropTargetDelegate } @@ -160,7 +160,7 @@ interface DropIndicatorContextValue { render: (props: DropIndicatorProps, ref: ForwardedRef) => ReactNode } -function DropIndicator(props: DropIndicatorProps, ref: ForwardedRef): JSX.Element { +function DropIndicator(props: DropIndicatorProps, ref: ForwardedRef): React.JSX.Element { let {render} = useContext(DropIndicatorContext)!; return <>{render(props, ref)}; } diff --git a/packages/react-aria-components/src/utils.tsx b/packages/react-aria-components/src/utils.tsx index 9a44ca6fde3..4a344b407cb 100644 --- a/packages/react-aria-components/src/utils.tsx +++ b/packages/react-aria-components/src/utils.tsx @@ -53,13 +53,13 @@ interface ProviderProps { children: ReactNode } -export function Provider({values, children}: ProviderProps): JSX.Element { +export function Provider({values, children}: ProviderProps): React.JSX.Element { for (let [Context, value] of values) { // @ts-ignore children = {children}; } - return children as JSX.Element; + return children as React.JSX.Element; } export interface StyleProps { diff --git a/patches/@types+lodash+4.14.194.patch b/patches/@types+lodash+4.14.194.patch new file mode 100644 index 00000000000..3c1862c715f --- /dev/null +++ b/patches/@types+lodash+4.14.194.patch @@ -0,0 +1,20 @@ +diff --git a/node_modules/@types/lodash/index.d.ts b/node_modules/@types/lodash/index.d.ts +index 8d1ec9f..0d4b05f 100755 +--- a/node_modules/@types/lodash/index.d.ts ++++ b/node_modules/@types/lodash/index.d.ts +@@ -31,15 +31,3 @@ declare namespace _ { + // tslint:disable-next-line no-empty-interface (This will be augmented) + interface LoDashStatic {} + } +- +-// Backward compatibility with --target es5 +-declare global { +- // tslint:disable-next-line:no-empty-interface +- interface Set { } +- // tslint:disable-next-line:no-empty-interface +- interface Map { } +- // tslint:disable-next-line:no-empty-interface +- interface WeakSet { } +- // tslint:disable-next-line:no-empty-interface +- interface WeakMap { } +-} diff --git a/yarn.lock b/yarn.lock index c762004efd9..76886b11da9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2188,7 +2188,7 @@ esquery "^1.5.0" jsdoc-type-pratt-parser "~4.0.0" -"@eslint-community/eslint-utils@^4.2.0": +"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== @@ -2200,6 +2200,11 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== +"@eslint-community/regexpp@^4.5.1": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" + integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== + "@eslint/eslintrc@^2.0.2": version "2.0.3" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.3.tgz#4910db5505f4d503f27774bf356e3704818a0331" @@ -6239,6 +6244,11 @@ "@types/tough-cookie" "*" parse5 "^7.0.0" +"@types/json-schema@^7.0.12": + version "7.0.14" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.14.tgz#74a97a5573980802f32c8e47b663530ab3b6b7d1" + integrity sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw== + "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" @@ -6351,10 +6361,10 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@>=16", "@types/react@^18.2.7": - version "18.2.7" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.7.tgz#dfb4518042a3117a045b8c222316f83414a783b3" - integrity sha512-ojrXpSH2XFCmHm7Jy3q44nXDyN54+EYKP2lBhJ2bqfyPj6cIUW/FZW/Csdia34NQgq7KYcAlHi5184m4X88+yw== +"@types/react@*", "@types/react@18.2.28", "@types/react@>=16", "@types/react@^18.2.28": + version "18.2.28" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.28.tgz#86877465c0fcf751659a36c769ecedfcfacee332" + integrity sha512-ad4aa/RaaJS3hyGz0BGegdnSRXQBkd1CCYDCdNjBPg90UUpLgo+WlJqb9fMYUxtehmzF3PJaTWqRZjko6BRzBg== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -6365,6 +6375,11 @@ resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== +"@types/semver@^7.5.0": + version "7.5.4" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.4.tgz#0a41252ad431c473158b22f9bfb9a63df7541cff" + integrity sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ== + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" @@ -6475,28 +6490,32 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^5.40.0": - version "5.40.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.40.0.tgz#0159bb71410eec563968288a17bd4478cdb685bd" - integrity sha512-FIBZgS3DVJgqPwJzvZTuH4HNsZhHMa9SjxTKAZTlMsPw/UzpEjcf9f4dfgDJEHjK+HboUJo123Eshl6niwEm/Q== +"@typescript-eslint/eslint-plugin@^6.7.5": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz#fdb6f3821c0167e3356e9d89c80e8230b2e401f4" + integrity sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA== dependencies: - "@typescript-eslint/scope-manager" "5.40.0" - "@typescript-eslint/type-utils" "5.40.0" - "@typescript-eslint/utils" "5.40.0" + "@eslint-community/regexpp" "^4.5.1" + "@typescript-eslint/scope-manager" "6.9.0" + "@typescript-eslint/type-utils" "6.9.0" + "@typescript-eslint/utils" "6.9.0" + "@typescript-eslint/visitor-keys" "6.9.0" debug "^4.3.4" - ignore "^5.2.0" - regexpp "^3.2.0" - semver "^7.3.7" - tsutils "^3.21.0" - -"@typescript-eslint/parser@^5.40.0": - version "5.40.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.40.0.tgz#432bddc1fe9154945660f67c1ba6d44de5014840" - integrity sha512-Ah5gqyX2ySkiuYeOIDg7ap51/b63QgWZA7w6AHtFrag7aH0lRQPbLzUjk0c9o5/KZ6JRkTTDKShL4AUrQa6/hw== - dependencies: - "@typescript-eslint/scope-manager" "5.40.0" - "@typescript-eslint/types" "5.40.0" - "@typescript-eslint/typescript-estree" "5.40.0" + graphemer "^1.4.0" + ignore "^5.2.4" + natural-compare "^1.4.0" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/parser@^6.7.5": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.9.0.tgz#2b402cadeadd3f211c25820e5433413347b27391" + integrity sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw== + dependencies: + "@typescript-eslint/scope-manager" "6.9.0" + "@typescript-eslint/types" "6.9.0" + "@typescript-eslint/typescript-estree" "6.9.0" + "@typescript-eslint/visitor-keys" "6.9.0" debug "^4.3.4" "@typescript-eslint/scope-manager@5.40.0": @@ -6507,21 +6526,34 @@ "@typescript-eslint/types" "5.40.0" "@typescript-eslint/visitor-keys" "5.40.0" -"@typescript-eslint/type-utils@5.40.0": - version "5.40.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.40.0.tgz#4964099d0158355e72d67a370249d7fc03331126" - integrity sha512-nfuSdKEZY2TpnPz5covjJqav+g5qeBqwSHKBvz7Vm1SAfy93SwKk/JeSTymruDGItTwNijSsno5LhOHRS1pcfw== +"@typescript-eslint/scope-manager@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz#2626e9a7fe0e004c3e25f3b986c75f584431134e" + integrity sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw== dependencies: - "@typescript-eslint/typescript-estree" "5.40.0" - "@typescript-eslint/utils" "5.40.0" + "@typescript-eslint/types" "6.9.0" + "@typescript-eslint/visitor-keys" "6.9.0" + +"@typescript-eslint/type-utils@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz#23923c8c9677c2ad41457cf8e10a5f2946be1b04" + integrity sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ== + dependencies: + "@typescript-eslint/typescript-estree" "6.9.0" + "@typescript-eslint/utils" "6.9.0" debug "^4.3.4" - tsutils "^3.21.0" + ts-api-utils "^1.0.1" "@typescript-eslint/types@5.40.0": version "5.40.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.40.0.tgz#8de07e118a10b8f63c99e174a3860f75608c822e" integrity sha512-V1KdQRTXsYpf1Y1fXCeZ+uhjW48Niiw0VGt4V8yzuaDTU8Z1Xl7yQDyQNqyAFcVhpYXIVCEuxSIWTsLDpHgTbw== +"@typescript-eslint/types@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.9.0.tgz#86a0cbe7ac46c0761429f928467ff3d92f841098" + integrity sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw== + "@typescript-eslint/typescript-estree@5.40.0": version "5.40.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.40.0.tgz#e305e6a5d65226efa5471ee0f12e0ffaab6d3075" @@ -6535,7 +6567,33 @@ semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/utils@5.40.0", "@typescript-eslint/utils@^5.10.0": +"@typescript-eslint/typescript-estree@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz#d0601b245be873d8fe49f3737f93f8662c8693d4" + integrity sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ== + dependencies: + "@typescript-eslint/types" "6.9.0" + "@typescript-eslint/visitor-keys" "6.9.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/utils@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.9.0.tgz#5bdac8604fca4823f090e4268e681c84d3597c9f" + integrity sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ== + dependencies: + "@eslint-community/eslint-utils" "^4.4.0" + "@types/json-schema" "^7.0.12" + "@types/semver" "^7.5.0" + "@typescript-eslint/scope-manager" "6.9.0" + "@typescript-eslint/types" "6.9.0" + "@typescript-eslint/typescript-estree" "6.9.0" + semver "^7.5.4" + +"@typescript-eslint/utils@^5.10.0": version "5.40.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.40.0.tgz#647f56a875fd09d33c6abd70913c3dd50759b772" integrity sha512-MO0y3T5BQ5+tkkuYZJBjePewsY+cQnfkYeRqS6tPh28niiIwPnQ1t59CSRcs1ZwJJNOdWw7rv9pF8aP58IMihA== @@ -6556,6 +6614,14 @@ "@typescript-eslint/types" "5.40.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz#cc69421c10c4ac997ed34f453027245988164e80" + integrity sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg== + dependencies: + "@typescript-eslint/types" "6.9.0" + eslint-visitor-keys "^3.4.1" + "@verdaccio/commons-api@10.2.0": version "10.2.0" resolved "https://registry.yarnpkg.com/@verdaccio/commons-api/-/commons-api-10.2.0.tgz#3b684c31749837b0574375bb2e10644ecea9fcca" @@ -13303,6 +13369,11 @@ grapheme-splitter@^1.0.4: resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== + gulp-awspublish@^0.0.23: version "0.0.23" resolved "https://registry.yarnpkg.com/gulp-awspublish/-/gulp-awspublish-0.0.23.tgz#4c07741f76f568992ba431189f11f7ddecbc9f80" @@ -14081,6 +14152,11 @@ ignore@^5.1.1, ignore@^5.2.0: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== +ignore@^5.2.4: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== + immutable@^3: version "3.8.2" resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3" @@ -21424,11 +21500,6 @@ regexparam@^1.3.0: resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f" integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g== -regexpp@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== - regexpu-core@^4.7.1: version "4.7.1" resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.1.tgz#2dea5a9a07233298fbf0db91fa9abc4c6e0f8ad6" @@ -22154,7 +22225,7 @@ semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8: dependencies: lru-cache "^6.0.0" -semver@^7.5.2: +semver@^7.5.2, semver@^7.5.4: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== @@ -23952,6 +24023,11 @@ trough@^2.0.0: resolved "https://registry.yarnpkg.com/trough/-/trough-2.0.2.tgz#94a3aa9d5ce379fc561f6244905b3f36b7458d96" integrity sha512-FnHq5sTMxC0sk957wHDzRnemFnNBvt/gSY99HzK8F7UP5WAbvP70yX5bd7CjEQkN+TjdxwI7g7lJ6podqrG2/w== +ts-api-utils@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" + integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg== + ts-dedent@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.0.0.tgz#47c5eb23d9096f3237cc413bc82d387d36dbe690" @@ -24129,10 +24205,10 @@ typescript-strict-plugin@^2.0.0: ora "^5.4.1" yargs "^16.2.0" -typescript@5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typescript@5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" + integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== ua-parser-js@0.7.17: version "0.7.17"