@react-aria/selection 3.27.2 → 3.28.0

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.
Files changed (52) hide show
  1. package/dist/import.mjs +7 -7
  2. package/dist/main.js +12 -12
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +7 -7
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +10 -0
  7. package/package.json +15 -17
  8. package/src/index.ts +10 -10
  9. package/dist/DOMLayoutDelegate.main.js +0 -59
  10. package/dist/DOMLayoutDelegate.main.js.map +0 -1
  11. package/dist/DOMLayoutDelegate.mjs +0 -54
  12. package/dist/DOMLayoutDelegate.module.js +0 -54
  13. package/dist/DOMLayoutDelegate.module.js.map +0 -1
  14. package/dist/ListKeyboardDelegate.main.js +0 -197
  15. package/dist/ListKeyboardDelegate.main.js.map +0 -1
  16. package/dist/ListKeyboardDelegate.mjs +0 -192
  17. package/dist/ListKeyboardDelegate.module.js +0 -192
  18. package/dist/ListKeyboardDelegate.module.js.map +0 -1
  19. package/dist/types.d.ts +0 -258
  20. package/dist/types.d.ts.map +0 -1
  21. package/dist/useSelectableCollection.main.js +0 -404
  22. package/dist/useSelectableCollection.main.js.map +0 -1
  23. package/dist/useSelectableCollection.mjs +0 -399
  24. package/dist/useSelectableCollection.module.js +0 -399
  25. package/dist/useSelectableCollection.module.js.map +0 -1
  26. package/dist/useSelectableItem.main.js +0 -263
  27. package/dist/useSelectableItem.main.js.map +0 -1
  28. package/dist/useSelectableItem.mjs +0 -258
  29. package/dist/useSelectableItem.module.js +0 -258
  30. package/dist/useSelectableItem.module.js.map +0 -1
  31. package/dist/useSelectableList.main.js +0 -63
  32. package/dist/useSelectableList.main.js.map +0 -1
  33. package/dist/useSelectableList.mjs +0 -58
  34. package/dist/useSelectableList.module.js +0 -58
  35. package/dist/useSelectableList.module.js.map +0 -1
  36. package/dist/useTypeSelect.main.js +0 -77
  37. package/dist/useTypeSelect.main.js.map +0 -1
  38. package/dist/useTypeSelect.mjs +0 -72
  39. package/dist/useTypeSelect.module.js +0 -72
  40. package/dist/useTypeSelect.module.js.map +0 -1
  41. package/dist/utils.main.js +0 -46
  42. package/dist/utils.main.js.map +0 -1
  43. package/dist/utils.mjs +0 -38
  44. package/dist/utils.module.js +0 -38
  45. package/dist/utils.module.js.map +0 -1
  46. package/src/DOMLayoutDelegate.ts +0 -61
  47. package/src/ListKeyboardDelegate.ts +0 -291
  48. package/src/useSelectableCollection.ts +0 -594
  49. package/src/useSelectableItem.ts +0 -422
  50. package/src/useSelectableList.ts +0 -85
  51. package/src/useTypeSelect.ts +0 -117
  52. package/src/utils.ts +0 -47
package/dist/types.d.ts DELETED
@@ -1,258 +0,0 @@
1
- import { DOMAttributes, Key, KeyboardDelegate, FocusStrategy, RefObject, DOMProps, FocusableElement, LayoutDelegate, Rect, Size, Collection, Direction, DisabledBehavior, Node, Orientation } from "@react-types/shared";
2
- import { MultipleSelectionManager } from "@react-stately/selection";
3
- export interface AriaTypeSelectOptions {
4
- /**
5
- * A delegate that returns collection item keys with respect to visual layout.
6
- */
7
- keyboardDelegate: KeyboardDelegate;
8
- /**
9
- * An interface for reading and updating multiple selection state.
10
- */
11
- selectionManager: MultipleSelectionManager;
12
- /**
13
- * Called when an item is focused by typing.
14
- */
15
- onTypeSelect?: (key: Key) => void;
16
- }
17
- export interface TypeSelectAria {
18
- /**
19
- * Props to be spread on the owner of the options.
20
- */
21
- typeSelectProps: DOMAttributes;
22
- }
23
- /**
24
- * Handles typeahead interactions with collections.
25
- */
26
- export function useTypeSelect(options: AriaTypeSelectOptions): TypeSelectAria;
27
- export interface AriaSelectableCollectionOptions {
28
- /**
29
- * An interface for reading and updating multiple selection state.
30
- */
31
- selectionManager: MultipleSelectionManager;
32
- /**
33
- * A delegate object that implements behavior for keyboard focus movement.
34
- */
35
- keyboardDelegate: KeyboardDelegate;
36
- /**
37
- * The ref attached to the element representing the collection.
38
- */
39
- ref: RefObject<HTMLElement | null>;
40
- /**
41
- * Whether the collection or one of its items should be automatically focused upon render.
42
- * @default false
43
- */
44
- autoFocus?: boolean | FocusStrategy;
45
- /**
46
- * Whether focus should wrap around when the end/start is reached.
47
- * @default false
48
- */
49
- shouldFocusWrap?: boolean;
50
- /**
51
- * Whether the collection allows empty selection.
52
- * @default false
53
- */
54
- disallowEmptySelection?: boolean;
55
- /**
56
- * Whether the collection allows the user to select all items via keyboard shortcut.
57
- * @default false
58
- */
59
- disallowSelectAll?: boolean;
60
- /**
61
- * Whether pressing the Escape should clear selection in the collection or not.
62
- * @default 'clearSelection'
63
- */
64
- escapeKeyBehavior?: 'clearSelection' | 'none';
65
- /**
66
- * Whether selection should occur automatically on focus.
67
- * @default false
68
- */
69
- selectOnFocus?: boolean;
70
- /**
71
- * Whether typeahead is disabled.
72
- * @default false
73
- */
74
- disallowTypeAhead?: boolean;
75
- /**
76
- * Whether the collection items should use virtual focus instead of being focused directly.
77
- */
78
- shouldUseVirtualFocus?: boolean;
79
- /**
80
- * Whether navigation through tab key is enabled.
81
- */
82
- allowsTabNavigation?: boolean;
83
- /**
84
- * Whether the collection items are contained in a virtual scroller.
85
- */
86
- isVirtualized?: boolean;
87
- /**
88
- * The ref attached to the scrollable body. Used to provide automatic scrolling on item focus for non-virtualized collections.
89
- * If not provided, defaults to the collection ref.
90
- */
91
- scrollRef?: RefObject<HTMLElement | null>;
92
- /**
93
- * The behavior of links in the collection.
94
- * - 'action': link behaves like onAction.
95
- * - 'selection': link follows selection interactions (e.g. if URL drives selection).
96
- * - 'override': links override all other interactions (link items are not selectable).
97
- * @default 'action'
98
- */
99
- linkBehavior?: 'action' | 'selection' | 'override';
100
- }
101
- export interface SelectableCollectionAria {
102
- /** Props for the collection element. */
103
- collectionProps: DOMAttributes;
104
- }
105
- /**
106
- * Handles interactions with selectable collections.
107
- */
108
- export function useSelectableCollection(options: AriaSelectableCollectionOptions): SelectableCollectionAria;
109
- export interface SelectableItemOptions extends DOMProps {
110
- /**
111
- * An interface for reading and updating multiple selection state.
112
- */
113
- selectionManager: MultipleSelectionManager;
114
- /**
115
- * A unique key for the item.
116
- */
117
- key: Key;
118
- /**
119
- * Ref to the item.
120
- */
121
- ref: RefObject<FocusableElement | null>;
122
- /**
123
- * By default, selection occurs on pointer down. This can be strange if selecting an
124
- * item causes the UI to disappear immediately (e.g. menus).
125
- */
126
- shouldSelectOnPressUp?: boolean;
127
- /**
128
- * Whether selection requires the pointer/mouse down and up events to occur on the same target or triggers selection on
129
- * the target of the pointer/mouse up event.
130
- */
131
- allowsDifferentPressOrigin?: boolean;
132
- /**
133
- * Whether the option is contained in a virtual scroller.
134
- */
135
- isVirtualized?: boolean;
136
- /**
137
- * Function to focus the item.
138
- */
139
- focus?: () => void;
140
- /**
141
- * Whether the option should use virtual focus instead of being focused directly.
142
- */
143
- shouldUseVirtualFocus?: boolean;
144
- /** Whether the item is disabled. */
145
- isDisabled?: boolean;
146
- /**
147
- * Handler that is called when a user performs an action on the item. The exact user event depends on
148
- * the collection's `selectionBehavior` prop and the interaction modality.
149
- */
150
- onAction?: () => void;
151
- /**
152
- * The behavior of links in the collection.
153
- * - 'action': link behaves like onAction.
154
- * - 'selection': link follows selection interactions (e.g. if URL drives selection).
155
- * - 'override': links override all other interactions (link items are not selectable).
156
- * - 'none': links are disabled for both selection and actions (e.g. handled elsewhere).
157
- * @default 'action'
158
- */
159
- linkBehavior?: 'action' | 'selection' | 'override' | 'none';
160
- }
161
- export interface SelectableItemStates {
162
- /** Whether the item is currently in a pressed state. */
163
- isPressed: boolean;
164
- /** Whether the item is currently selected. */
165
- isSelected: boolean;
166
- /** Whether the item is currently focused. */
167
- isFocused: boolean;
168
- /**
169
- * Whether the item is non-interactive, i.e. both selection and actions are disabled and the item may
170
- * not be focused. Dependent on `disabledKeys` and `disabledBehavior`.
171
- */
172
- isDisabled: boolean;
173
- /**
174
- * Whether the item may be selected, dependent on `selectionMode`, `disabledKeys`, and `disabledBehavior`.
175
- */
176
- allowsSelection: boolean;
177
- /**
178
- * Whether the item has an action, dependent on `onAction`, `disabledKeys`,
179
- * and `disabledBehavior`. It may also change depending on the current selection state
180
- * of the list (e.g. when selection is primary). This can be used to enable or disable hover
181
- * styles or other visual indications of interactivity.
182
- */
183
- hasAction: boolean;
184
- }
185
- export interface SelectableItemAria extends SelectableItemStates {
186
- /**
187
- * Props to be spread on the item root node.
188
- */
189
- itemProps: DOMAttributes;
190
- }
191
- /**
192
- * Handles interactions with an item in a selectable collection.
193
- */
194
- export function useSelectableItem(options: SelectableItemOptions): SelectableItemAria;
195
- export class DOMLayoutDelegate implements LayoutDelegate {
196
- constructor(ref: RefObject<HTMLElement | null>);
197
- getItemRect(key: Key): Rect | null;
198
- getContentSize(): Size;
199
- getVisibleRect(): Rect;
200
- }
201
- interface ListKeyboardDelegateOptions<T> {
202
- collection: Collection<Node<T>>;
203
- ref: RefObject<HTMLElement | null>;
204
- collator?: Intl.Collator;
205
- layout?: 'stack' | 'grid';
206
- orientation?: Orientation;
207
- direction?: Direction;
208
- disabledKeys?: Set<Key>;
209
- disabledBehavior?: DisabledBehavior;
210
- layoutDelegate?: LayoutDelegate;
211
- }
212
- export class ListKeyboardDelegate<T> implements KeyboardDelegate {
213
- constructor(collection: Collection<Node<T>>, disabledKeys: Set<Key>, ref: RefObject<HTMLElement | null>, collator?: Intl.Collator, expandedKeys?: Set<Key>);
214
- constructor(options: ListKeyboardDelegateOptions<T>);
215
- getNextKey(key: Key): Key | null;
216
- getPreviousKey(key: Key): Key | null;
217
- getKeyBelow(key: Key): Key | null;
218
- getKeyAbove(key: Key): Key | null;
219
- getKeyRightOf?(key: Key): Key | null;
220
- getKeyLeftOf?(key: Key): Key | null;
221
- getFirstKey(): Key | null;
222
- getLastKey(): Key | null;
223
- getKeyPageAbove(key: Key): Key | null;
224
- getKeyPageBelow(key: Key): Key | null;
225
- getKeyForSearch(search: string, fromKey?: Key): Key | null;
226
- }
227
- export interface AriaSelectableListOptions extends Omit<AriaSelectableCollectionOptions, 'keyboardDelegate'> {
228
- /**
229
- * State of the collection.
230
- */
231
- collection: Collection<Node<unknown>>;
232
- /**
233
- * A delegate object that implements behavior for keyboard focus movement.
234
- */
235
- keyboardDelegate?: KeyboardDelegate;
236
- /**
237
- * A delegate object that provides layout information for items in the collection.
238
- * By default this uses the DOM, but this can be overridden to implement things like
239
- * virtualized scrolling.
240
- */
241
- layoutDelegate?: LayoutDelegate;
242
- /**
243
- * The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.
244
- */
245
- disabledKeys: Set<Key>;
246
- }
247
- export interface SelectableListAria {
248
- /**
249
- * Props for the option element.
250
- */
251
- listProps: DOMAttributes;
252
- }
253
- /**
254
- * Handles interactions with a selectable list.
255
- */
256
- export function useSelectableList(props: AriaSelectableListOptions): SelectableListAria;
257
-
258
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;ACsBA;IACE;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAClC;AAED;IACE;;OAEG;IACH,eAAe,EAAE,aAAa,CAAA;CAC/B;AAED;;GAEG;AACH,8BAA8B,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAyD5E;ACjFD;IACE;;OAEG;IACH,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC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yB,GAAG,kBAAkB,CAmCtF","sources":["packages/@react-aria/selection/src/packages/@react-aria/selection/src/utils.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useTypeSelect.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableCollection.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableItem.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/DOMLayoutDelegate.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/ListKeyboardDelegate.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/useSelectableList.ts","packages/@react-aria/selection/src/packages/@react-aria/selection/src/index.ts","packages/@react-aria/selection/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useSelectableCollection} from './useSelectableCollection';\nexport {useSelectableItem} from './useSelectableItem';\nexport {useSelectableList} from './useSelectableList';\nexport {ListKeyboardDelegate} from './ListKeyboardDelegate';\nexport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nexport {useTypeSelect} from './useTypeSelect';\n\nexport type {AriaSelectableCollectionOptions, SelectableCollectionAria} from './useSelectableCollection';\nexport type {AriaSelectableListOptions, SelectableListAria} from './useSelectableList';\nexport type {SelectableItemOptions, SelectableItemStates, SelectableItemAria} from './useSelectableItem';\nexport type {AriaTypeSelectOptions, TypeSelectAria} from './useTypeSelect';\n"],"names":[],"version":3,"file":"types.d.ts.map"}