@react-stately/selection
Advanced tools
Comparing version 3.0.0-nightly.3114 to 3.0.0-nightly-07431f4b1-241030
@@ -21,4 +21,4 @@ | ||
if (keys instanceof $21c847070f1f9569$export$52baac22726c72bf) { | ||
this.anchorKey = anchorKey || keys.anchorKey; | ||
this.currentKey = currentKey || keys.currentKey; | ||
this.anchorKey = anchorKey !== null && anchorKey !== void 0 ? anchorKey : keys.anchorKey; | ||
this.currentKey = currentKey !== null && currentKey !== void 0 ? currentKey : keys.currentKey; | ||
} else { | ||
@@ -25,0 +25,0 @@ this.anchorKey = anchorKey; |
@@ -15,4 +15,4 @@ /* | ||
if (keys instanceof $e40ea825a81a3709$export$52baac22726c72bf) { | ||
this.anchorKey = anchorKey || keys.anchorKey; | ||
this.currentKey = currentKey || keys.currentKey; | ||
this.anchorKey = anchorKey !== null && anchorKey !== void 0 ? anchorKey : keys.anchorKey; | ||
this.currentKey = currentKey !== null && currentKey !== void 0 ? currentKey : keys.currentKey; | ||
} else { | ||
@@ -19,0 +19,0 @@ this.anchorKey = anchorKey; |
@@ -138,5 +138,7 @@ var $21c847070f1f9569$exports = require("./Selection.main.js"); | ||
let selectedKeys = this.state.selectedKeys; | ||
let anchorKey = selectedKeys.anchorKey || toKey; | ||
var _selectedKeys_anchorKey; | ||
let anchorKey = (_selectedKeys_anchorKey = selectedKeys.anchorKey) !== null && _selectedKeys_anchorKey !== void 0 ? _selectedKeys_anchorKey : toKey; | ||
selection = new (0, $21c847070f1f9569$exports.Selection)(selectedKeys, anchorKey, toKey); | ||
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))selection.delete(key); | ||
var _selectedKeys_currentKey; | ||
for (let key of this.getKeyRange(anchorKey, (_selectedKeys_currentKey = selectedKeys.currentKey) !== null && _selectedKeys_currentKey !== void 0 ? _selectedKeys_currentKey : toKey))selection.delete(key); | ||
for (let key of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key)) selection.add(key); | ||
@@ -156,5 +158,7 @@ } | ||
getKeyRangeInternal(from, to) { | ||
var _this_layoutDelegate; | ||
if ((_this_layoutDelegate = this.layoutDelegate) === null || _this_layoutDelegate === void 0 ? void 0 : _this_layoutDelegate.getKeyRange) return this.layoutDelegate.getKeyRange(from, to); | ||
let keys = []; | ||
let key = from; | ||
while(key){ | ||
while(key != null){ | ||
let item = this.collection.getItem(key); | ||
@@ -304,2 +308,3 @@ if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key); | ||
this._isSelectAll = null; | ||
this.layoutDelegate = (options === null || options === void 0 ? void 0 : options.layoutDelegate) || null; | ||
} | ||
@@ -306,0 +311,0 @@ } |
@@ -132,5 +132,7 @@ import {Selection as $e40ea825a81a3709$export$52baac22726c72bf} from "./Selection.module.js"; | ||
let selectedKeys = this.state.selectedKeys; | ||
let anchorKey = selectedKeys.anchorKey || toKey; | ||
var _selectedKeys_anchorKey; | ||
let anchorKey = (_selectedKeys_anchorKey = selectedKeys.anchorKey) !== null && _selectedKeys_anchorKey !== void 0 ? _selectedKeys_anchorKey : toKey; | ||
selection = new (0, $e40ea825a81a3709$export$52baac22726c72bf)(selectedKeys, anchorKey, toKey); | ||
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey))selection.delete(key); | ||
var _selectedKeys_currentKey; | ||
for (let key of this.getKeyRange(anchorKey, (_selectedKeys_currentKey = selectedKeys.currentKey) !== null && _selectedKeys_currentKey !== void 0 ? _selectedKeys_currentKey : toKey))selection.delete(key); | ||
for (let key of this.getKeyRange(toKey, anchorKey))if (this.canSelectItem(key)) selection.add(key); | ||
@@ -150,5 +152,7 @@ } | ||
getKeyRangeInternal(from, to) { | ||
var _this_layoutDelegate; | ||
if ((_this_layoutDelegate = this.layoutDelegate) === null || _this_layoutDelegate === void 0 ? void 0 : _this_layoutDelegate.getKeyRange) return this.layoutDelegate.getKeyRange(from, to); | ||
let keys = []; | ||
let key = from; | ||
while(key){ | ||
while(key != null){ | ||
let item = this.collection.getItem(key); | ||
@@ -298,2 +302,3 @@ if (item && item.type === 'item' || item.type === 'cell' && this.allowsCellSelection) keys.push(key); | ||
this._isSelectAll = null; | ||
this.layoutDelegate = (options === null || options === void 0 ? void 0 : options.layoutDelegate) || null; | ||
} | ||
@@ -300,0 +305,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode, MultipleSelection, Collection, Node } from "@react-types/shared"; | ||
import { DisabledBehavior, FocusStrategy, Key, LongPressEvent, PressEvent, Selection, SelectionBehavior, SelectionMode, MultipleSelection, Collection, LayoutDelegate, Node } from "@react-types/shared"; | ||
export interface FocusState { | ||
@@ -109,2 +109,3 @@ /** Whether the collection is currently focused. */ | ||
allowsCellSelection?: boolean; | ||
layoutDelegate?: LayoutDelegate; | ||
} | ||
@@ -111,0 +112,0 @@ /** |
{ | ||
"name": "@react-stately/selection", | ||
"version": "3.0.0-nightly.3114+68403fe55", | ||
"version": "3.0.0-nightly-07431f4b1-241030", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,5 +25,5 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-stately/collections": "3.0.0-nightly.3114+68403fe55", | ||
"@react-stately/utils": "3.0.0-nightly.3114+68403fe55", | ||
"@react-types/shared": "3.0.0-nightly.3114+68403fe55", | ||
"@react-stately/collections": "^3.0.0-nightly-07431f4b1-241030", | ||
"@react-stately/utils": "^3.0.0-nightly-07431f4b1-241030", | ||
"@react-types/shared": "^3.0.0-nightly-07431f4b1-241030", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -37,3 +37,3 @@ }, | ||
}, | ||
"gitHead": "68403fe55489dce3de1b3094c957d598ad719861" | ||
} | ||
"stableVersion": "3.17.0" | ||
} |
@@ -26,4 +26,4 @@ /* | ||
if (keys instanceof Selection) { | ||
this.anchorKey = anchorKey || keys.anchorKey; | ||
this.currentKey = currentKey || keys.currentKey; | ||
this.anchorKey = anchorKey ?? keys.anchorKey; | ||
this.currentKey = currentKey ?? keys.currentKey; | ||
} else { | ||
@@ -30,0 +30,0 @@ this.anchorKey = anchorKey; |
@@ -18,2 +18,3 @@ /* | ||
Key, | ||
LayoutDelegate, | ||
LongPressEvent, | ||
@@ -30,3 +31,4 @@ Node, | ||
interface SelectionManagerOptions { | ||
allowsCellSelection?: boolean | ||
allowsCellSelection?: boolean, | ||
layoutDelegate?: LayoutDelegate | ||
} | ||
@@ -42,2 +44,3 @@ | ||
private _isSelectAll: boolean; | ||
private layoutDelegate: LayoutDelegate | null; | ||
@@ -49,2 +52,3 @@ constructor(collection: Collection<Node<unknown>>, state: MultipleSelectionState, options?: SelectionManagerOptions) { | ||
this._isSelectAll = null; | ||
this.layoutDelegate = options?.layoutDelegate || null; | ||
} | ||
@@ -229,5 +233,5 @@ | ||
let selectedKeys = this.state.selectedKeys as Selection; | ||
let anchorKey = selectedKeys.anchorKey || toKey; | ||
let anchorKey = selectedKeys.anchorKey ?? toKey; | ||
selection = new Selection(selectedKeys, anchorKey, toKey); | ||
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey || toKey)) { | ||
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? toKey)) { | ||
selection.delete(key); | ||
@@ -261,5 +265,9 @@ } | ||
private getKeyRangeInternal(from: Key, to: Key) { | ||
if (this.layoutDelegate?.getKeyRange) { | ||
return this.layoutDelegate.getKeyRange(from, to); | ||
} | ||
let keys: Key[] = []; | ||
let key = from; | ||
while (key) { | ||
while (key != null) { | ||
let item = this.collection.getItem(key); | ||
@@ -266,0 +274,0 @@ if (item && item.type === 'item' || (item.type === 'cell' && this.allowsCellSelection)) { |
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
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
2224
0
166750
29
+ Added@react-stately/collections@3.12.0(transitive)
+ Added@react-stately/utils@3.10.5(transitive)
+ Added@react-types/shared@3.26.0(transitive)
Updated@react-stately/collections@^3.0.0-nightly-07431f4b1-241030