@react-aria/selection
Advanced tools
Comparing version 3.0.2 to 3.1.0
@@ -20,2 +20,5 @@ var { | ||
/** | ||
* Handles typeahead interactions with collections. | ||
*/ | ||
function useTypeSelect(options) { | ||
@@ -91,2 +94,5 @@ let { | ||
/** | ||
* Handles interactions with selectable collections. | ||
*/ | ||
function useSelectableCollection(options) { | ||
@@ -391,2 +397,5 @@ let { | ||
/** | ||
* Handles interactions with an item in a selectable collection. | ||
*/ | ||
function useSelectableItem(options) { | ||
@@ -446,3 +455,3 @@ let { | ||
// the pointer up on the menu item rather than requiring a separate press. | ||
// For keyboard events, selection still occurrs on key down. | ||
// For keyboard events, selection still occurs on key down. | ||
@@ -632,2 +641,5 @@ if (shouldSelectOnPressUp) { | ||
/** | ||
* Handles interactions with a selectable list. | ||
*/ | ||
function useSelectableList(props) { | ||
@@ -676,5 +688,8 @@ let { | ||
}; | ||
} // Scrolls `scrollView` so that `element` is visible. | ||
// Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge), | ||
// but doesn't affect parents above `scrollView`. | ||
} | ||
/** | ||
* Scrolls `scrollView` so that `element` is visible. | ||
* Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge), | ||
* but doesn't affect parents above `scrollView`. | ||
*/ | ||
@@ -681,0 +696,0 @@ |
@@ -5,2 +5,6 @@ import { useCollator } from "@react-aria/i18n"; | ||
import { useEffect, useRef, useMemo } from "react"; | ||
/** | ||
* Handles typeahead interactions with collections. | ||
*/ | ||
export function useTypeSelect(options) { | ||
@@ -74,2 +78,5 @@ let { | ||
/** | ||
* Handles interactions with selectable collections. | ||
*/ | ||
export function useSelectableCollection(options) { | ||
@@ -371,2 +378,6 @@ let { | ||
} | ||
/** | ||
* Handles interactions with an item in a selectable collection. | ||
*/ | ||
export function useSelectableItem(options) { | ||
@@ -426,3 +437,3 @@ let { | ||
// the pointer up on the menu item rather than requiring a separate press. | ||
// For keyboard events, selection still occurrs on key down. | ||
// For keyboard events, selection still occurs on key down. | ||
@@ -607,2 +618,6 @@ if (shouldSelectOnPressUp) { | ||
} | ||
/** | ||
* Handles interactions with a selectable list. | ||
*/ | ||
export function useSelectableList(props) { | ||
@@ -651,5 +666,8 @@ let { | ||
}; | ||
} // Scrolls `scrollView` so that `element` is visible. | ||
// Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge), | ||
// but doesn't affect parents above `scrollView`. | ||
} | ||
/** | ||
* Scrolls `scrollView` so that `element` is visible. | ||
* Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge), | ||
* but doesn't affect parents above `scrollView`. | ||
*/ | ||
@@ -656,0 +674,0 @@ function $a09ba753e08b703267f2392f7fc8e96$var$scrollIntoView(scrollView, element) { |
@@ -6,9 +6,24 @@ import { HTMLAttributes, Key, RefObject } from "react"; | ||
interface TypeSelectOptions { | ||
/** | ||
* A delegate that returns collection item keys with respect to visual layout. | ||
*/ | ||
keyboardDelegate: KeyboardDelegate; | ||
/** | ||
* An interface for reading and updating multiple selection state. | ||
*/ | ||
selectionManager: MultipleSelectionManager; | ||
/** | ||
* Called when an item is focused by typing. | ||
*/ | ||
onTypeSelect?: (key: Key) => void; | ||
} | ||
interface TypeSelectAria { | ||
/** | ||
* Props to be spread on the owner of the options. | ||
*/ | ||
typeSelectProps: HTMLAttributes<HTMLElement>; | ||
} | ||
/** | ||
* Handles typeahead interactions with collections. | ||
*/ | ||
export function useTypeSelect(options: TypeSelectOptions): TypeSelectAria; | ||
@@ -53,14 +68,42 @@ interface SelectableCollectionOptions { | ||
} | ||
/** | ||
* Handles interactions with selectable collections. | ||
*/ | ||
export function useSelectableCollection(options: SelectableCollectionOptions): SelectableCollectionAria; | ||
interface SelectableItemOptions { | ||
/** | ||
* An interface for reading and updating multiple selection state. | ||
*/ | ||
selectionManager: MultipleSelectionManager; | ||
/** | ||
* A unique key for the item. | ||
*/ | ||
key: Key; | ||
/** | ||
* Ref to the item. | ||
*/ | ||
ref: RefObject<HTMLElement>; | ||
/** | ||
* By default, selection occurs on pointer down. This can be strange if selecting an | ||
* item causes the UI to disappear immediately (e.g. menus). | ||
*/ | ||
shouldSelectOnPressUp?: boolean; | ||
/** | ||
* Whether the option is contained in a virtual scroller. | ||
*/ | ||
isVirtualized?: boolean; | ||
/** | ||
* Function to focus the item. | ||
*/ | ||
focus?: () => void; | ||
} | ||
interface SelectableItemAria { | ||
/** | ||
* Props to be spread on the item root node. | ||
*/ | ||
itemProps: HTMLAttributes<HTMLElement> & PressProps; | ||
} | ||
/** | ||
* Handles interactions with an item in a selectable collection. | ||
*/ | ||
export function useSelectableItem(options: SelectableItemOptions): SelectableItemAria; | ||
@@ -78,17 +121,53 @@ export class ListKeyboardDelegate<T> implements KeyboardDelegate { | ||
interface SelectableListOptions { | ||
/** | ||
* An interface for reading and updating multiple selection state. | ||
*/ | ||
selectionManager: MultipleSelectionManager; | ||
/** | ||
* State of the collection. | ||
*/ | ||
collection: Collection<Node<unknown>>; | ||
/** | ||
* The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. | ||
*/ | ||
disabledKeys: Set<Key>; | ||
/** | ||
* A ref to the item. | ||
*/ | ||
ref?: RefObject<HTMLElement>; | ||
/** | ||
* A delegate that returns collection item keys with respect to visual layout. | ||
*/ | ||
keyboardDelegate?: KeyboardDelegate; | ||
/** | ||
* Whether the collection or one of its items should be automatically focused upon render. | ||
* @default false | ||
*/ | ||
autoFocus?: boolean | FocusStrategy; | ||
/** | ||
* Whether focus should wrap around when the end/start is reached. | ||
* @default false | ||
*/ | ||
shouldFocusWrap?: boolean; | ||
/** | ||
* Whether the option is contained in a virtual scroller. | ||
*/ | ||
isVirtualized?: boolean; | ||
/** | ||
* Whether the collection allows empty selection. | ||
* @default false | ||
*/ | ||
disallowEmptySelection?: boolean; | ||
} | ||
interface SelectableListAria { | ||
/** | ||
* Props for the option element. | ||
*/ | ||
listProps: HTMLAttributes<HTMLElement>; | ||
} | ||
/** | ||
* Handles interactions with a selectable list. | ||
*/ | ||
export function useSelectableList(props: SelectableListOptions): SelectableListAria; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-aria/selection", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,9 +21,9 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/focus": "^3.0.2", | ||
"@react-aria/i18n": "^3.0.2", | ||
"@react-aria/interactions": "^3.0.2", | ||
"@react-aria/utils": "^3.0.2", | ||
"@react-stately/collections": "^3.0.2", | ||
"@react-stately/selection": "^3.0.2", | ||
"@react-types/shared": "^3.0.2" | ||
"@react-aria/focus": "^3.1.0", | ||
"@react-aria/i18n": "^3.1.0", | ||
"@react-aria/interactions": "^3.1.0", | ||
"@react-aria/utils": "^3.1.0", | ||
"@react-stately/collections": "^3.1.0", | ||
"@react-stately/selection": "^3.1.0", | ||
"@react-types/shared": "^3.1.0" | ||
}, | ||
@@ -36,3 +36,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "05003506f02a0ec173f3448f1801cbdf12b47bc7" | ||
"gitHead": "211099972fe75ee581892efd01a7f89dfb9cdf69" | ||
} |
@@ -74,2 +74,5 @@ /* | ||
/** | ||
* Handles interactions with selectable collections. | ||
*/ | ||
export function useSelectableCollection(options: SelectableCollectionOptions): SelectableCollectionAria { | ||
@@ -76,0 +79,0 @@ let { |
@@ -20,7 +20,26 @@ /* | ||
interface SelectableItemOptions { | ||
/** | ||
* An interface for reading and updating multiple selection state. | ||
*/ | ||
selectionManager: MultipleSelectionManager, | ||
/** | ||
* A unique key for the item. | ||
*/ | ||
key: Key, | ||
/** | ||
* Ref to the item. | ||
*/ | ||
ref: RefObject<HTMLElement>, | ||
/** | ||
* By default, selection occurs on pointer down. This can be strange if selecting an | ||
* item causes the UI to disappear immediately (e.g. menus). | ||
*/ | ||
shouldSelectOnPressUp?: boolean, | ||
/** | ||
* Whether the option is contained in a virtual scroller. | ||
*/ | ||
isVirtualized?: boolean, | ||
/** | ||
* Function to focus the item. | ||
*/ | ||
focus?: () => void | ||
@@ -30,5 +49,11 @@ } | ||
interface SelectableItemAria { | ||
/** | ||
* Props to be spread on the item root node. | ||
*/ | ||
itemProps: HTMLAttributes<HTMLElement> & PressProps | ||
} | ||
/** | ||
* Handles interactions with an item in a selectable collection. | ||
*/ | ||
export function useSelectableItem(options: SelectableItemOptions): SelectableItemAria { | ||
@@ -89,3 +114,3 @@ let { | ||
// the pointer up on the menu item rather than requiring a separate press. | ||
// For keyboard events, selection still occurrs on key down. | ||
// For keyboard events, selection still occurs on key down. | ||
if (shouldSelectOnPressUp) { | ||
@@ -92,0 +117,0 @@ itemProps.onPressStart = (e) => { |
@@ -21,10 +21,40 @@ /* | ||
interface SelectableListOptions { | ||
/** | ||
* An interface for reading and updating multiple selection state. | ||
*/ | ||
selectionManager: MultipleSelectionManager, | ||
/** | ||
* State of the collection. | ||
*/ | ||
collection: Collection<Node<unknown>>, | ||
/** | ||
* The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. | ||
*/ | ||
disabledKeys: Set<Key>, | ||
/** | ||
* A ref to the item. | ||
*/ | ||
ref?: RefObject<HTMLElement>, | ||
/** | ||
* A delegate that returns collection item keys with respect to visual layout. | ||
*/ | ||
keyboardDelegate?: KeyboardDelegate, | ||
/** | ||
* Whether the collection or one of its items should be automatically focused upon render. | ||
* @default false | ||
*/ | ||
autoFocus?: boolean | FocusStrategy, | ||
/** | ||
* Whether focus should wrap around when the end/start is reached. | ||
* @default false | ||
*/ | ||
shouldFocusWrap?: boolean, | ||
/** | ||
* Whether the option is contained in a virtual scroller. | ||
*/ | ||
isVirtualized?: boolean, | ||
/** | ||
* Whether the collection allows empty selection. | ||
* @default false | ||
*/ | ||
disallowEmptySelection?: boolean | ||
@@ -34,5 +64,11 @@ } | ||
interface SelectableListAria { | ||
/** | ||
* Props for the option element. | ||
*/ | ||
listProps: HTMLAttributes<HTMLElement> | ||
} | ||
/** | ||
* Handles interactions with a selectable list. | ||
*/ | ||
export function useSelectableList(props: SelectableListOptions): SelectableListAria { | ||
@@ -81,5 +117,7 @@ let { | ||
// Scrolls `scrollView` so that `element` is visible. | ||
// Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge), | ||
// but doesn't affect parents above `scrollView`. | ||
/** | ||
* Scrolls `scrollView` so that `element` is visible. | ||
* Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge), | ||
* but doesn't affect parents above `scrollView`. | ||
*/ | ||
function scrollIntoView(scrollView: HTMLElement, element: HTMLElement) { | ||
@@ -86,0 +124,0 @@ let offsetX = element.offsetLeft - scrollView.offsetLeft; |
@@ -18,4 +18,13 @@ /* | ||
interface TypeSelectOptions { | ||
/** | ||
* A delegate that returns collection item keys with respect to visual layout. | ||
*/ | ||
keyboardDelegate: KeyboardDelegate, | ||
/** | ||
* An interface for reading and updating multiple selection state. | ||
*/ | ||
selectionManager: MultipleSelectionManager, | ||
/** | ||
* Called when an item is focused by typing. | ||
*/ | ||
onTypeSelect?: (key: Key) => void | ||
@@ -25,5 +34,11 @@ } | ||
interface TypeSelectAria { | ||
/** | ||
* Props to be spread on the owner of the options. | ||
*/ | ||
typeSelectProps: HTMLAttributes<HTMLElement> | ||
} | ||
/** | ||
* Handles typeahead interactions with collections. | ||
*/ | ||
export function useTypeSelect(options: TypeSelectOptions): TypeSelectAria { | ||
@@ -30,0 +45,0 @@ let {keyboardDelegate, selectionManager, onTypeSelect} = options; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176881
2086
Updated@react-aria/focus@^3.1.0
Updated@react-aria/i18n@^3.1.0
Updated@react-aria/utils@^3.1.0
Updated@react-types/shared@^3.1.0