Skip to content

Commit 8046a8b

Browse files
committed
Merge branch 'main' of github.com:adobe/react-spectrum
2 parents 6efe0ee + b5a193a commit 8046a8b

File tree

17 files changed

+622
-129
lines changed

17 files changed

+622
-129
lines changed

packages/@react-aria/tag/docs/useTagGroup.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Each individual tag should use `rowProps` on its outer container, and use `gridC
7777

7878
```tsx example export=true
7979
import {useTag, useTagGroup} from '@react-aria/tag';
80-
import {useTagGroupState} from '@react-stately/tag';
80+
import {useListState} from '@react-stately/list';
8181
import {Item} from '@react-stately/collections';
8282
import {useFocusRing} from '@react-aria/focus';
8383

@@ -88,7 +88,7 @@ function TagGroup(props) {
8888
let { label, description, errorMessage, validationState, allowsRemoving, onRemove } = props;
8989
let ref = React.useRef(null);
9090

91-
let state = useTagGroupState(props);
91+
let state = useListState(props);
9292
let {
9393
gridProps,
9494
labelProps,

packages/@react-aria/tag/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"@react-aria/label": "^3.5.1",
2929
"@react-aria/utils": "^3.16.0",
3030
"@react-stately/list": "^3.8.0",
31-
"@react-stately/tag": "3.0.0-rc.0",
3231
"@react-types/button": "^3.7.2",
3332
"@react-types/shared": "^3.18.0",
3433
"@react-types/tag": "3.0.0-rc.0",

packages/@react-aria/tag/src/useTag.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
import {AriaButtonProps} from '@react-types/button';
1414
import {AriaLabelingProps, DOMAttributes, DOMProps, FocusableElement} from '@react-types/shared';
15-
import {chain, filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
15+
import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
1616
// @ts-ignore
1717
import intlMessages from '../intl/*.json';
1818
import {KeyboardEvent, RefObject} from 'react';
19-
import type {TagGroupState} from '@react-stately/tag';
19+
import type {ListState} from '@react-stately/list';
2020
import {TagProps} from '@react-types/tag';
2121
import {useGridListItem} from '@react-aria/gridlist';
2222
import {useInteractionModality} from '@react-aria/interactions';
@@ -39,13 +39,14 @@ export interface AriaTagProps<T> extends TagProps<T>, DOMProps, AriaLabelingProp
3939
/**
4040
* Provides the behavior and accessibility implementation for a tag component.
4141
* @param props - Props to be applied to the tag.
42-
* @param state - State for the tag group, as returned by `useTagGroupState`.
42+
* @param state - State for the tag group, as returned by `useListState`.
4343
* @param ref - A ref to a DOM element for the tag.
4444
*/
45-
export function useTag<T>(props: AriaTagProps<T>, state: TagGroupState<T>, ref: RefObject<FocusableElement>): TagAria {
45+
export function useTag<T>(props: AriaTagProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): TagAria {
4646
let {
4747
allowsRemoving,
48-
item
48+
item,
49+
onRemove
4950
} = props;
5051
let stringFormatter = useLocalizedStringFormatter(intlMessages);
5152
let labelId = useId();
@@ -58,8 +59,6 @@ export function useTag<T>(props: AriaTagProps<T>, state: TagGroupState<T>, ref:
5859
// We want the group to handle keyboard navigation between tags.
5960
delete rowProps.onKeyDownCapture;
6061

61-
let onRemove = chain(props.onRemove, state.onRemove);
62-
6362
let onKeyDown = (e: KeyboardEvent) => {
6463
if (e.key === 'Delete' || e.key === 'Backspace') {
6564
onRemove(item.key);

packages/@react-aria/tag/src/useTagGroup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import {AriaLabelingProps, DOMAttributes, DOMProps, Validation} from '@react-types/shared';
1414
import {filterDOMProps, mergeProps} from '@react-aria/utils';
15+
import type {ListState} from '@react-stately/list';
1516
import {RefObject, useState} from 'react';
1617
import {TagGroupProps} from '@react-types/tag';
17-
import type {TagGroupState} from '@react-stately/tag';
1818
import {TagKeyboardDelegate} from './TagKeyboardDelegate';
1919
import {useField} from '@react-aria/label';
2020
import {useFocusWithin} from '@react-aria/interactions';
@@ -44,10 +44,10 @@ export interface AriaTagGroupProps<T> extends TagGroupProps<T>, DOMProps, AriaLa
4444
* Provides the behavior and accessibility implementation for a tag group component.
4545
* A tag group is a focusable list of labels, categories, keywords, or other items, with support for keyboard navigation and removal.
4646
* @param props - Props to be applied to the tag group.
47-
* @param state - State for the tag group, as returned by `useTagGroupState`.
47+
* @param state - State for the tag group, as returned by `useListState`.
4848
* @param ref - A ref to a DOM element for the tag group.
4949
*/
50-
export function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState<T>, ref: RefObject<HTMLElement>): TagGroupAria {
50+
export function useTagGroup<T>(props: AriaTagGroupProps<T>, state: ListState<T>, ref: RefObject<HTMLElement>): TagGroupAria {
5151
let {direction} = useLocale();
5252
let keyboardDelegate = props.keyboardDelegate || new TagKeyboardDelegate(state.collection, direction);
5353
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField(props);

packages/@react-spectrum/tag/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@react-spectrum/utils": "^3.9.1",
4949
"@react-stately/collections": "^3.7.0",
5050
"@react-stately/list": "^3.8.0",
51-
"@react-stately/tag": "3.0.0-rc.0",
5251
"@react-types/shared": "^3.18.0",
5352
"@react-types/tag": "3.0.0-rc.0",
5453
"@swc/helpers": "^0.4.14"

packages/@react-spectrum/tag/src/Tag.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
import {classNames, ClearSlots, SlotProvider, useStyleProps} from '@react-spectrum/utils';
1414
import {ClearButton} from '@react-spectrum/button';
15+
import type {ListState} from '@react-stately/list';
1516
import {mergeProps} from '@react-aria/utils';
1617
import React, {useRef} from 'react';
1718
import styles from '@adobe/spectrum-css-temp/components/tags/vars.css';
18-
import type {TagGroupState} from '@react-stately/tag';
1919
import {TagProps} from '@react-types/tag';
2020
import {Text} from '@react-spectrum/text';
2121
import {useFocusRing} from '@react-aria/focus';
2222
import {useHover} from '@react-aria/interactions';
2323
import {useTag} from '@react-aria/tag';
2424

2525
export interface SpectrumTagProps<T> extends TagProps<T> {
26-
state: TagGroupState<T>
26+
state: ListState<T>
2727
}
2828

2929
export function Tag<T>(props: SpectrumTagProps<T>) {

packages/@react-spectrum/tag/src/TagGroup.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ import {Field} from '@react-spectrum/label';
1818
import {FocusScope} from '@react-aria/focus';
1919
// @ts-ignore
2020
import intlMessages from '../intl/*.json';
21-
import {ListCollection} from '@react-stately/list';
21+
import {ListCollection, useListState} from '@react-stately/list';
2222
import {Provider, useProviderProps} from '@react-spectrum/provider';
2323
import React, {ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react';
2424
import styles from '@adobe/spectrum-css-temp/components/tags/vars.css';
2525
import {Tag} from './Tag';
2626
import {useFormProps} from '@react-spectrum/form';
2727
import {useId, useLayoutEffect, useResizeObserver, useValueEffect} from '@react-aria/utils';
2828
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
29-
import {useTagGroupState} from '@react-stately/tag';
3029

3130
export interface SpectrumTagGroupProps<T> extends AriaTagGroupProps<T>, StyleProps, SpectrumLabelableProps, Omit<SpectrumHelpTextProps, 'showErrorIcon'> {
3231
/** The label to display on the action button. */
@@ -53,7 +52,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
5352
let {direction} = useLocale();
5453
let stringFormatter = useLocalizedStringFormatter(intlMessages);
5554
let [isCollapsed, setIsCollapsed] = useState(maxRows != null);
56-
let state = useTagGroupState(props);
55+
let state = useListState(props);
5756
let [tagState, setTagState] = useValueEffect({visibleTagCount: state.collection.size, showCollapseButton: false, maxHeight: undefined});
5857
let keyboardDelegate = useMemo(() => (
5958
isCollapsed

packages/@react-stately/tag/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/@react-stately/tag/index.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/@react-stately/tag/package.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)