10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
+ import { AriaGridListProps , useGridList } from '@react-aria/gridlist' ;
13
14
import { AriaLabelingProps , CollectionBase , DOMAttributes , DOMProps , HelpTextProps , Key , KeyboardDelegate , LabelableProps , MultipleSelection , RefObject , SelectionBehavior } from '@react-types/shared' ;
14
15
import { filterDOMProps , mergeProps } from '@react-aria/utils' ;
15
16
import { ListKeyboardDelegate } from '@react-aria/selection' ;
16
17
import type { ListState } from '@react-stately/list' ;
17
18
import { ReactNode , useEffect , useRef , useState } from 'react' ;
18
19
import { useField } from '@react-aria/label' ;
19
20
import { useFocusWithin } from '@react-aria/interactions' ;
20
- import { useGridList } from '@react-aria/gridlist' ;
21
21
import { useLocale } from '@react-aria/i18n' ;
22
22
23
23
export interface TagGroupAria {
@@ -31,15 +31,24 @@ export interface TagGroupAria {
31
31
errorMessageProps : DOMAttributes
32
32
}
33
33
34
- export interface AriaTagGroupProps < T > extends CollectionBase < T > , MultipleSelection , DOMProps , LabelableProps , AriaLabelingProps , Omit < HelpTextProps , 'errorMessage' > {
34
+ export interface AriaTagGroupProps < T > extends CollectionBase < T > , MultipleSelection , Pick < AriaGridListProps < T > , 'escapeKeyBehavior' > , DOMProps , LabelableProps , AriaLabelingProps , Omit < HelpTextProps , 'errorMessage' > {
35
35
/** How multiple selection should behave in the collection. */
36
36
selectionBehavior ?: SelectionBehavior ,
37
37
/** Whether selection should occur on press up instead of press down. */
38
38
shouldSelectOnPressUp ?: boolean ,
39
39
/** Handler that is called when a user deletes a tag. */
40
40
onRemove ?: ( keys : Set < Key > ) => void ,
41
41
/** An error message for the field. */
42
- errorMessage ?: ReactNode
42
+ errorMessage ?: ReactNode ,
43
+ /**
44
+ * Whether pressing the escape key should clear selection in the TagGroup or not.
45
+ *
46
+ * Most experiences should not modify this option as it eliminates a keyboard user's ability to
47
+ * easily clear selection. Only use if the escape key is being handled externally or should not
48
+ * trigger selection clearing contextually.
49
+ * @default 'clearSelection'
50
+ */
51
+ escapeKeyBehavior ?: 'clearSelection' | 'none'
43
52
}
44
53
45
54
export interface AriaTagGroupOptions < T > extends Omit < AriaTagGroupProps < T > , 'children' > {
0 commit comments