Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/@react-spectrum/s2/exports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export {
isFileDropItem,
isTextDropItem
} from 'react-aria/useDrop';
export {useDragAndDrop} from 'react-aria-components/useDragAndDrop';
export {useDragAndDrop} from './useDragAndDrop';

export type {
AccordionProps,
Expand Down Expand Up @@ -315,7 +315,8 @@ export type {
AsyncListLoadOptions,
AsyncListStateUpdate
} from 'react-stately/useAsyncList';
export type {DragAndDropHooks, DragAndDropOptions} from 'react-aria-components/useDragAndDrop';
export type {DragAndDropHooks} from 'react-aria-components/useDragAndDrop';
export type {DragAndDropOptions} from './useDragAndDrop';
export type {
DirectoryDropItem,
DraggableCollectionEndEvent,
Expand Down
6 changes: 4 additions & 2 deletions packages/@react-spectrum/s2/exports/useDragAndDrop.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export {useDragAndDrop} from 'react-aria-components/useDragAndDrop';
export {useDragAndDrop} from '../src/useDragAndDrop';
export {
DIRECTORY_DRAG_TYPE,
isDirectoryDropItem,
isFileDropItem,
isTextDropItem
} from 'react-aria/useDrop';
export type {DragAndDropHooks, DragAndDropOptions} from 'react-aria-components/useDragAndDrop';
export type {DragAndDropHooks} from 'react-aria-components/useDragAndDrop';
export type {
DirectoryDropItem,
DraggableCollectionEndEvent,
Expand All @@ -30,3 +30,5 @@ export type {
RootDropTarget,
TextDropItem
} from '@react-types/shared';
export type {DragAndDropOptions} from '../src/useDragAndDrop';
export type {DragAndDrop} from 'react-aria-components/useDragAndDrop';
32 changes: 32 additions & 0 deletions packages/@react-spectrum/s2/src/useDragAndDrop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2026 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 type {
DragAndDrop,
DragAndDropOptions as RACDragAndDropOptions
} from 'react-aria-components/useDragAndDrop';
import {useDragAndDrop as useRACDragAndDrop} from 'react-aria-components/useDragAndDrop';

export type {DragAndDrop};

export interface DragAndDropOptions<T = object> extends Omit<
RACDragAndDropOptions<T>,
'renderDropIndicator'
> {}

/**
* Provides the hooks required to enable drag and drop behavior for a drag and drop compatible
* collection component.
*/
export function useDragAndDrop<T = object>(options: DragAndDropOptions<T>): DragAndDrop<T> {
return useRACDragAndDrop(options);
}
12 changes: 10 additions & 2 deletions packages/dev/codemods/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const {parseArgs} = require('node:util');
import {s1_to_s2} from './s1-to-s2/src';
import {test_utils_rc_update} from './test-utils-rc-update/src';
import {use_monopackages} from './use-monopackages/src';
import {use_subpaths} from './use-subpaths/src';

Expand Down Expand Up @@ -57,15 +58,22 @@ export interface UseMonopackagesCodemodOptions extends JSCodeshiftOptions {

export interface UseSubpathsCodemodOptions extends JSCodeshiftOptions {}

export interface TestUtilsRcUpdateOptions extends JSCodeshiftOptions {}

const codemods: Record<
string,
(
options: S1ToS2CodemodOptions | UseMonopackagesCodemodOptions | UseSubpathsCodemodOptions
options:
| S1ToS2CodemodOptions
| UseMonopackagesCodemodOptions
| UseSubpathsCodemodOptions
| TestUtilsRcUpdateOptions
) => void
> = {
's1-to-s2': s1_to_s2,
'use-monopackages': use_monopackages,
'use-subpaths': use_subpaths
'use-subpaths': use_subpaths,
'test-utils-rc-update': test_utils_rc_update
};

// https://github.com/facebook/jscodeshift?tab=readme-ov-file#usage-cli
Expand Down
30 changes: 30 additions & 0 deletions packages/dev/codemods/src/test-utils-rc-update/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Codemod for @react-aria/test-utils RC API update

Updates test files that use the `@react-aria/test-utils` or `@react-spectrum/test-utils` testers when upgrading the test utils from beta to RC. This updates your tests to use the
renamed getters alongside other changes.

```diff
- tester.listbox;
+ tester.getListbox();

- tester.options();
+ tester.getOptions();

- await tester.selectOption({option: 'Save'});
+ await tester.toggleOptionSelection({option: 'Save'});

- tester.findOption({optionIndexOrText: 'Save'});
+ tester.findOption({indexOrText: 'Save'});
```

Handles all tester types: `ListBox`, `ComboBox`, `Select`, `Menu`, `Table`, `GridList`, `Tree`, `Tabs`, `RadioGroup`, `CheckboxGroup`, and `Dialog`.

## Usage

Run `npx @react-spectrum/codemods test-utils-rc-update` from the directory you want to update test files in.

### Options

- `--ignore-pattern` - A [glob pattern](https://github.com/facebook/jscodeshift?tab=readme-ov-file#ignoring-files-and-directories) of files to ignore. Defaults to `**/node_modules/**`.
- `--dry` - Run the codemod without making changes to the files.
- `--path` - The path to the directory to run the codemod in. Defaults to the current directory.
Loading