@react-stately/selection
Advanced tools
Comparing version
@@ -306,2 +306,8 @@ var $21c847070f1f9569$exports = require("./Selection.main.js"); | ||
} | ||
withCollection(collection) { | ||
return new $8112da6fa5bbc322$export$6c8a5aaad13c9852(collection, this.state, { | ||
allowsCellSelection: this.allowsCellSelection, | ||
layoutDelegate: this.layoutDelegate || undefined | ||
}); | ||
} | ||
constructor(collection, state, options){ | ||
@@ -308,0 +314,0 @@ this.collection = collection; |
@@ -300,2 +300,8 @@ import {Selection as $e40ea825a81a3709$export$52baac22726c72bf} from "./Selection.module.js"; | ||
} | ||
withCollection(collection) { | ||
return new $d496c0a20b6e58ec$export$6c8a5aaad13c9852(collection, this.state, { | ||
allowsCellSelection: this.allowsCellSelection, | ||
layoutDelegate: this.layoutDelegate || undefined | ||
}); | ||
} | ||
constructor(collection, state, options){ | ||
@@ -302,0 +308,0 @@ this.collection = collection; |
@@ -1,2 +0,2 @@ | ||
import { DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode, MultipleSelection, Collection, LayoutDelegate, Node } from "@react-types/shared"; | ||
import { Collection, DisabledBehavior, FocusStrategy, Key, LongPressEvent, Node, PressEvent, Selection, SelectionBehavior, SelectionMode, MultipleSelection, LayoutDelegate } from "@react-types/shared"; | ||
export interface FocusState { | ||
@@ -94,2 +94,4 @@ /** Whether the collection is currently focused. */ | ||
getItemProps(key: Key): any; | ||
/** The collection of nodes that the selection manager handles. */ | ||
collection: Collection<Node<unknown>>; | ||
} | ||
@@ -214,4 +216,5 @@ export interface MultipleSelectionStateProps extends MultipleSelection { | ||
getItemProps(key: Key): any; | ||
withCollection(collection: Collection<Node<unknown>>): SelectionManager; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-stately/selection", | ||
"version": "3.0.0-nightly-326f48154-241216", | ||
"version": "3.0.0-nightly-341ae3f8a-250822", | ||
"description": "Spectrum UI components in React", | ||
@@ -9,3 +9,7 @@ "license": "Apache-2.0", | ||
"exports": { | ||
"types": "./dist/types.d.ts", | ||
"source": "./src/index.ts", | ||
"types": [ | ||
"./dist/types.d.ts", | ||
"./src/index.ts" | ||
], | ||
"import": "./dist/import.mjs", | ||
@@ -26,5 +30,5 @@ "require": "./dist/main.js" | ||
"dependencies": { | ||
"@react-stately/collections": "3.0.0-nightly-326f48154-241216", | ||
"@react-stately/utils": "3.0.0-nightly-326f48154-241216", | ||
"@react-types/shared": "3.0.0-nightly-326f48154-241216", | ||
"@react-stately/collections": "3.0.0-nightly-341ae3f8a-250822", | ||
"@react-stately/utils": "3.0.0-nightly-341ae3f8a-250822", | ||
"@react-types/shared": "3.0.0-nightly-341ae3f8a-250822", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -31,0 +35,0 @@ }, |
@@ -76,3 +76,3 @@ /* | ||
*/ | ||
setSelectionBehavior(selectionBehavior: SelectionBehavior) { | ||
setSelectionBehavior(selectionBehavior: SelectionBehavior): void { | ||
this.state.setSelectionBehavior(selectionBehavior); | ||
@@ -91,3 +91,3 @@ } | ||
*/ | ||
setFocused(isFocused: boolean) { | ||
setFocused(isFocused: boolean): void { | ||
this.state.setFocused(isFocused); | ||
@@ -111,3 +111,3 @@ } | ||
*/ | ||
setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy) { | ||
setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void { | ||
if (key == null || this.collection.getItem(key)) { | ||
@@ -138,3 +138,3 @@ this.state.setFocusedKey(key, childFocusStrategy); | ||
*/ | ||
isSelected(key: Key) { | ||
isSelected(key: Key): boolean { | ||
if (this.state.selectionMode === 'none') { | ||
@@ -217,3 +217,3 @@ return false; | ||
*/ | ||
extendSelection(toKey: Key) { | ||
extendSelection(toKey: Key): void { | ||
if (this.selectionMode === 'none') { | ||
@@ -320,3 +320,3 @@ return; | ||
*/ | ||
toggleSelection(key: Key) { | ||
toggleSelection(key: Key): void { | ||
if (this.selectionMode === 'none') { | ||
@@ -357,3 +357,3 @@ return; | ||
*/ | ||
replaceSelection(key: Key) { | ||
replaceSelection(key: Key): void { | ||
if (this.selectionMode === 'none') { | ||
@@ -378,3 +378,3 @@ return; | ||
*/ | ||
setSelectedKeys(keys: Iterable<Key>) { | ||
setSelectedKeys(keys: Iterable<Key>): void { | ||
if (this.selectionMode === 'none') { | ||
@@ -425,3 +425,3 @@ return; | ||
*/ | ||
selectAll() { | ||
selectAll(): void { | ||
if (!this.isSelectAll && this.selectionMode === 'multiple') { | ||
@@ -435,3 +435,3 @@ this.state.setSelectedKeys('all'); | ||
*/ | ||
clearSelection() { | ||
clearSelection(): void { | ||
if (!this.disallowEmptySelection && (this.state.selectedKeys === 'all' || this.state.selectedKeys.size > 0)) { | ||
@@ -445,3 +445,3 @@ this.state.setSelectedKeys(new Selection()); | ||
*/ | ||
toggleSelectAll() { | ||
toggleSelectAll(): void { | ||
if (this.isSelectAll) { | ||
@@ -454,3 +454,3 @@ this.clearSelection(); | ||
select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent) { | ||
select(key: Key, e?: PressEvent | LongPressEvent | PointerEvent): void { | ||
if (this.selectionMode === 'none') { | ||
@@ -477,3 +477,3 @@ return; | ||
*/ | ||
isSelectionEqual(selection: Set<Key>) { | ||
isSelectionEqual(selection: Set<Key>): boolean { | ||
if (selection === this.state.selectedKeys) { | ||
@@ -504,3 +504,3 @@ return true; | ||
canSelectItem(key: Key) { | ||
canSelectItem(key: Key): boolean { | ||
if (this.state.selectionMode === 'none' || this.state.disabledKeys.has(key)) { | ||
@@ -518,13 +518,20 @@ return false; | ||
isDisabled(key: Key) { | ||
isDisabled(key: Key): boolean { | ||
return this.state.disabledBehavior === 'all' && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled); | ||
} | ||
isLink(key: Key) { | ||
isLink(key: Key): boolean { | ||
return !!this.collection.getItem(key)?.props?.href; | ||
} | ||
getItemProps(key: Key) { | ||
getItemProps(key: Key): any { | ||
return this.collection.getItem(key)?.props; | ||
} | ||
withCollection(collection: Collection<Node<unknown>>): SelectionManager { | ||
return new SelectionManager(collection, this.state, { | ||
allowsCellSelection: this.allowsCellSelection, | ||
layoutDelegate: this.layoutDelegate || undefined | ||
}); | ||
} | ||
} |
@@ -13,3 +13,3 @@ /* | ||
import {DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared'; | ||
import {Collection, DisabledBehavior, FocusStrategy, Key, LongPressEvent, Node, PressEvent, Selection, SelectionBehavior, SelectionMode} from '@react-types/shared'; | ||
@@ -111,3 +111,5 @@ | ||
/** Returns the props for the given item. */ | ||
getItemProps(key: Key): any | ||
getItemProps(key: Key): any, | ||
/** The collection of nodes that the selection manager handles. */ | ||
collection: Collection<Node<unknown>> | ||
} |
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
Sorry, the diff of this file is not supported yet
174642
1.68%2281
1.29%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated