@react-aria/selection 3.9.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,14 +10,14 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Collection, FocusStrategy, KeyboardDelegate, Node} from '@react-types/shared';
14
- import {HTMLAttributes, Key, RefObject, useMemo} from 'react';
13
+ import {Collection, DOMAttributes, FocusStrategy, KeyboardDelegate, Node} from '@react-types/shared';
14
+ import {Key, RefObject, useMemo} from 'react';
15
15
  import {ListKeyboardDelegate} from './ListKeyboardDelegate';
16
16
  import {MultipleSelectionManager} from '@react-stately/selection';
17
17
  import {useCollator} from '@react-aria/i18n';
18
18
  import {useSelectableCollection} from './useSelectableCollection';
19
19
 
20
- interface SelectableListOptions {
20
+ export interface AriaSelectableListOptions {
21
21
  /**
22
22
  * An interface for reading and updating multiple selection state.
23
23
  */
@@ -77,17 +77,17 @@ interface SelectableListOptions {
77
77
  allowsTabNavigation?: boolean
78
78
  }
79
79
 
80
- interface SelectableListAria {
80
+ export interface SelectableListAria {
81
81
  /**
82
82
  * Props for the option element.
83
83
  */
84
- listProps: HTMLAttributes<HTMLElement>
84
+ listProps: DOMAttributes
85
85
  }
86
86
 
87
87
  /**
88
88
  * Handles interactions with a selectable list.
89
89
  */
90
- export function useSelectableList(props: SelectableListOptions): SelectableListAria {
90
+ export function useSelectableList(props: AriaSelectableListOptions): SelectableListAria {
91
91
  let {
92
92
  selectionManager,
93
93
  collection,
@@ -98,7 +98,7 @@ export function useSelectableList(props: SelectableListOptions): SelectableListA
98
98
  shouldFocusWrap,
99
99
  isVirtualized,
100
100
  disallowEmptySelection,
101
- selectOnFocus = false,
101
+ selectOnFocus = selectionManager.selectionBehavior === 'replace',
102
102
  disallowTypeAhead,
103
103
  shouldUseVirtualFocus,
104
104
  allowsTabNavigation
@@ -107,7 +107,10 @@ export function useSelectableList(props: SelectableListOptions): SelectableListA
107
107
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
108
108
  // When virtualized, the layout object will be passed in as a prop and override this.
109
109
  let collator = useCollator({usage: 'search', sensitivity: 'base'});
110
- let delegate = useMemo(() => keyboardDelegate || new ListKeyboardDelegate(collection, disabledKeys, ref, collator), [keyboardDelegate, collection, disabledKeys, ref, collator]);
110
+ let disabledBehavior = selectionManager.disabledBehavior;
111
+ let delegate = useMemo(() => (
112
+ keyboardDelegate || new ListKeyboardDelegate(collection, disabledBehavior === 'selection' ? new Set() : disabledKeys, ref, collator)
113
+ ), [keyboardDelegate, collection, disabledKeys, ref, collator, disabledBehavior]);
111
114
 
112
115
  let {collectionProps} = useSelectableCollection({
113
116
  ref,
@@ -10,11 +10,11 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {HTMLAttributes, Key, KeyboardEvent, useRef} from 'react';
14
- import {KeyboardDelegate} from '@react-types/shared';
13
+ import {DOMAttributes, KeyboardDelegate} from '@react-types/shared';
14
+ import {Key, KeyboardEvent, useRef} from 'react';
15
15
  import {MultipleSelectionManager} from '@react-stately/selection';
16
16
 
17
- interface TypeSelectOptions {
17
+ export interface AriaTypeSelectOptions {
18
18
  /**
19
19
  * A delegate that returns collection item keys with respect to visual layout.
20
20
  */
@@ -29,17 +29,17 @@ interface TypeSelectOptions {
29
29
  onTypeSelect?: (key: Key) => void
30
30
  }
31
31
 
32
- interface TypeSelectAria {
32
+ export interface TypeSelectAria {
33
33
  /**
34
34
  * Props to be spread on the owner of the options.
35
35
  */
36
- typeSelectProps: HTMLAttributes<HTMLElement>
36
+ typeSelectProps: DOMAttributes
37
37
  }
38
38
 
39
39
  /**
40
40
  * Handles typeahead interactions with collections.
41
41
  */
42
- export function useTypeSelect(options: TypeSelectOptions): TypeSelectAria {
42
+ export function useTypeSelect(options: AriaTypeSelectOptions): TypeSelectAria {
43
43
  let {keyboardDelegate, selectionManager, onTypeSelect} = options;
44
44
  let state = useRef({
45
45
  search: '',