Socket
Socket
Sign inDemoInstall

@react-stately/selection

Package Overview
Dependencies
Maintainers
2
Versions
764
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.0.0-nightly.994 to 3.0.0-nightly.997

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.0.0-nightly.994+faa93480",
"version": "3.0.0-nightly.997+1e2b7f28",
"description": "Spectrum UI components in React",

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

"@babel/runtime": "^7.6.2",
"@react-stately/collections": "3.0.0-nightly.994+faa93480",
"@react-stately/utils": "3.0.0-nightly.994+faa93480",
"@react-types/shared": "3.0.0-nightly.994+faa93480"
"@react-stately/collections": "3.0.0-nightly.997+1e2b7f28",
"@react-stately/utils": "3.0.0-nightly.997+1e2b7f28",
"@react-types/shared": "3.0.0-nightly.997+1e2b7f28"
},

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

},
"gitHead": "faa9348097bf62403e37e32daf897cdad5512e09"
"gitHead": "1e2b7f280a04ead83e21b27fa580eb189e5f4186"
}

@@ -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