@react-stately/selection
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -213,2 +213,34 @@ var { | ||
} | ||
get firstSelectedKey() { | ||
var _first; | ||
let first = null; | ||
for (let key of this.state.selectedKeys) { | ||
let item = this.collection.getItem(key); | ||
if (!first || (item == null ? void 0 : item.index) < first.index) { | ||
first = item; | ||
} | ||
} | ||
return (_first = first) == null ? void 0 : _first.key; | ||
} | ||
get lastSelectedKey() { | ||
var _last; | ||
let last = null; | ||
for (let key of this.state.selectedKeys) { | ||
let item = this.collection.getItem(key); | ||
if (!last || (item == null ? void 0 : item.index) > last.index) { | ||
last = item; | ||
} | ||
} | ||
return (_last = last) == null ? void 0 : _last.key; | ||
} | ||
/** | ||
@@ -215,0 +247,0 @@ * Extends the selection to the given key. |
@@ -204,2 +204,34 @@ import { useControlledState } from "@react-stately/utils"; | ||
} | ||
get firstSelectedKey() { | ||
var _first; | ||
let first = null; | ||
for (let key of this.state.selectedKeys) { | ||
let item = this.collection.getItem(key); | ||
if (!first || (item == null ? void 0 : item.index) < first.index) { | ||
first = item; | ||
} | ||
} | ||
return (_first = first) == null ? void 0 : _first.key; | ||
} | ||
get lastSelectedKey() { | ||
var _last; | ||
let last = null; | ||
for (let key of this.state.selectedKeys) { | ||
let item = this.collection.getItem(key); | ||
if (!last || (item == null ? void 0 : item.index) > last.index) { | ||
last = item; | ||
} | ||
} | ||
return (_last = last) == null ? void 0 : _last.key; | ||
} | ||
/** | ||
@@ -206,0 +238,0 @@ * Extends the selection to the given key. |
@@ -42,2 +42,6 @@ import { Key } from "react"; | ||
readonly isSelectAll: boolean; | ||
/** The first selected key in the collection. */ | ||
readonly firstSelectedKey: Key | null; | ||
/** The last selected key in the collection. */ | ||
readonly lastSelectedKey: Key | null; | ||
/** Returns whether a key is selected. */ | ||
@@ -110,2 +114,4 @@ isSelected(key: Key): boolean; | ||
get isSelectAll(): boolean; | ||
get firstSelectedKey(): Key | null; | ||
get lastSelectedKey(): Key | null; | ||
/** | ||
@@ -112,0 +118,0 @@ * Extends the selection to the given key. |
{ | ||
"name": "@react-stately/selection", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,5 +21,5 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-stately/collections": "^3.1.0", | ||
"@react-stately/collections": "^3.2.0", | ||
"@react-stately/utils": "^3.1.0", | ||
"@react-types/shared": "^3.1.0" | ||
"@react-types/shared": "^3.2.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "211099972fe75ee581892efd01a7f89dfb9cdf69" | ||
"gitHead": "661f0f2e3b8648a75aae83043267954700059fe0" | ||
} |
@@ -129,2 +129,26 @@ /* | ||
get firstSelectedKey(): Key | null { | ||
let first: Node<unknown> | null = null; | ||
for (let key of this.state.selectedKeys) { | ||
let item = this.collection.getItem(key); | ||
if (!first || item?.index < first.index) { | ||
first = item; | ||
} | ||
} | ||
return first?.key; | ||
} | ||
get lastSelectedKey(): Key | null { | ||
let last: Node<unknown> | null = null; | ||
for (let key of this.state.selectedKeys) { | ||
let item = this.collection.getItem(key); | ||
if (!last || item?.index > last.index) { | ||
last = item; | ||
} | ||
} | ||
return last?.key; | ||
} | ||
/** | ||
@@ -131,0 +155,0 @@ * Extends the selection to the given key. |
@@ -58,2 +58,6 @@ /* | ||
readonly isSelectAll: boolean, | ||
/** The first selected key in the collection. */ | ||
readonly firstSelectedKey: Key | null, | ||
/** The last selected key in the collection. */ | ||
readonly lastSelectedKey: Key | null, | ||
/** Returns whether a key is selected. */ | ||
@@ -60,0 +64,0 @@ isSelected(key: Key): boolean, |
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
99054
1250