Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-stately/selection

Package Overview
Dependencies
Maintainers
2
Versions
812
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/selection - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

57

dist/main.js

@@ -396,3 +396,29 @@ var {

}
/**
* Replaces the selection with the given keys.
*/
setSelectedKeys(keys) {
if (this.selectionMode === 'none') {
return;
}
let selection = new $cc81f14158b02e1e259a5a46d24f0c$export$Selection();
for (let key of keys) {
key = this.getKey(key);
if (key != null) {
selection.add(key);
if (this.selectionMode === 'single') {
break;
}
}
}
this.state.setSelectedKeys(selection);
}
getSelectAllKeys() {

@@ -473,3 +499,34 @@ let keys = [];

}
/**
* Returns whether the current selection is equal to the given selection.
*/
isSelectionEqual(selection) {
if (selection === this.state.selectedKeys) {
return true;
} // Check if the set of keys match.
let selectedKeys = this.selectedKeys;
if (selection.size !== selectedKeys.size) {
return false;
}
for (let key of selection) {
if (!selectedKeys.has(key)) {
return false;
}
}
for (let key of selectedKeys) {
if (!selection.has(key)) {
return false;
}
}
return true;
}
}

@@ -476,0 +533,0 @@

@@ -387,3 +387,29 @@ import { useControlledState } from "@react-stately/utils";

}
/**
* Replaces the selection with the given keys.
*/
setSelectedKeys(keys) {
if (this.selectionMode === 'none') {
return;
}
let selection = new $c91e86e24f2dc9a2182dcc2674c58c$export$Selection();
for (let key of keys) {
key = this.getKey(key);
if (key != null) {
selection.add(key);
if (this.selectionMode === 'single') {
break;
}
}
}
this.state.setSelectedKeys(selection);
}
getSelectAllKeys() {

@@ -464,4 +490,35 @@ let keys = [];

}
/**
* Returns whether the current selection is equal to the given selection.
*/
isSelectionEqual(selection) {
if (selection === this.state.selectedKeys) {
return true;
} // Check if the set of keys match.
let selectedKeys = this.selectedKeys;
if (selection.size !== selectedKeys.size) {
return false;
}
for (let key of selection) {
if (!selectedKeys.has(key)) {
return false;
}
}
for (let key of selectedKeys) {
if (!selection.has(key)) {
return false;
}
}
return true;
}
}
//# sourceMappingURL=module.js.map

@@ -52,2 +52,4 @@ import { FocusStrategy, PressEvent, Selection, SelectionMode, MultipleSelection, Collection, Node } from "@react-types/shared";

isSelected(key: Key): boolean;
/** Returns whether the current selection is equal to the given selection. */
isSelectionEqual(selection: Set<Key>): boolean;
/** Extends the selection to the given key. */

@@ -59,2 +61,4 @@ extendSelection(toKey: Key): void;

replaceSelection(key: Key): void;
/** Replaces the selection with the given keys. */
setSelectedKeys(keys: Iterable<Key>): void;
/** Selects all items in the collection. */

@@ -141,2 +145,6 @@ selectAll(): void;

/**
* Replaces the selection with the given keys.
*/
setSelectedKeys(keys: Iterable<Key>): void;
/**
* Selects all items in the collection.

@@ -154,4 +162,8 @@ */

select(key: Key, e?: PressEvent | PointerEvent): void;
/**
* Returns whether the current selection is equal to the given selection.
*/
isSelectionEqual(selection: Set<Key>): boolean;
}
//# sourceMappingURL=types.d.ts.map

10

package.json
{
"name": "@react-stately/selection",
"version": "3.4.0",
"version": "3.5.0",
"description": "Spectrum UI components in React",

@@ -21,5 +21,5 @@ "license": "Apache-2.0",

"@babel/runtime": "^7.6.2",
"@react-stately/collections": "^3.3.1",
"@react-stately/utils": "^3.1.1",
"@react-types/shared": "^3.5.0"
"@react-stately/collections": "^3.3.2",
"@react-stately/utils": "^3.2.1",
"@react-types/shared": "^3.6.0"
},

@@ -32,3 +32,3 @@ "peerDependencies": {

},
"gitHead": "9920ffaa2596a03c4498a15cb940bd2f4ba5cd6a"
"gitHead": "3aae08e7d8a75382bedcddac7c86107e40db9296"
}

@@ -281,2 +281,24 @@ /*

/**
* Replaces the selection with the given keys.
*/
setSelectedKeys(keys: Iterable<Key>) {
if (this.selectionMode === 'none') {
return;
}
let selection = new Selection();
for (let key of keys) {
key = this.getKey(key);
if (key != null) {
selection.add(key);
if (this.selectionMode === 'single') {
break;
}
}
}
this.state.setSelectedKeys(selection);
}
private getSelectAllKeys() {

@@ -352,2 +374,31 @@ let keys: Key[] = [];

}
/**
* Returns whether the current selection is equal to the given selection.
*/
isSelectionEqual(selection: Set<Key>) {
if (selection === this.state.selectedKeys) {
return true;
}
// Check if the set of keys match.
let selectedKeys = this.selectedKeys;
if (selection.size !== selectedKeys.size) {
return false;
}
for (let key of selection) {
if (!selectedKeys.has(key)) {
return false;
}
}
for (let key of selectedKeys) {
if (!selection.has(key)) {
return false;
}
}
return true;
}
}

@@ -68,2 +68,4 @@ /*

isSelected(key: Key): boolean,
/** Returns whether the current selection is equal to the given selection. */
isSelectionEqual(selection: Set<Key>): boolean,
/** Extends the selection to the given key. */

@@ -75,2 +77,4 @@ extendSelection(toKey: Key): void,

replaceSelection(key: Key): void,
/** Replaces the selection with the given keys. */
setSelectedKeys(keys: Iterable<Key>): void,
/** Selects all items in the collection. */

@@ -77,0 +81,0 @@ selectAll(): void,

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc