New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@react-stately/data

Package Overview
Dependencies
Maintainers
2
Versions
902
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/data - npm Package Compare versions

Comparing version 3.0.0-nightly-c53ab48ec-250115 to 3.0.0-nightly-c78b24831-250206

14

dist/types.d.ts

@@ -248,2 +248,16 @@ import { Key, Selection, LoadingState, SortDescriptor } from "@react-types/shared";

/**
* Moves an item before a node within the tree.
* @param key - The key of the item to move.
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
* @param index - The index within the new parent to insert before.
*/
moveBefore(key: Key, toParentKey: Key | null, index: number): void;
/**
* Moves an item after a node within the tree.
* @param key - The key of the item to move.
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
* @param index - The index within the new parent to insert after.
*/
moveAfter(key: Key, toParentKey: Key | null, index: number): void;
/**
* Updates an item in the tree.

@@ -250,0 +264,0 @@ * @param key - The key of the item to update.

@@ -212,2 +212,46 @@ var $aMaLn$react = require("react");

},
moveBefore (key, toParentKey, index) {
this.move(key, toParentKey, index);
},
moveAfter (key, toParentKey, index) {
setItems(({ items: items, nodeMap: originalMap })=>{
let node = originalMap.get(key);
if (!node) return {
items: items,
nodeMap: originalMap
};
let { items: newItems, nodeMap: newMap } = updateTree(items, key, ()=>null, originalMap);
const movedNode = {
...node,
parentKey: toParentKey
};
const afterIndex = items.length === index ? index : index + 1;
// If parentKey is null, insert into the root.
if (toParentKey == null) {
newMap.set(movedNode.key, movedNode);
return {
items: [
...newItems.slice(0, afterIndex),
movedNode,
...newItems.slice(afterIndex)
],
nodeMap: newMap
};
}
// Otherwise, update the parent node and its ancestors.
return updateTree(newItems, toParentKey, (parentNode)=>{
const c = [
...parentNode.children.slice(0, afterIndex),
movedNode,
...parentNode.children.slice(afterIndex)
];
return {
key: parentNode.key,
parentKey: parentNode.parentKey,
value: parentNode.value,
children: c
};
}, newMap);
});
},
update (oldKey, newValue) {

@@ -214,0 +258,0 @@ setItems(({ items: items, nodeMap: originalMap })=>updateTree(items, oldKey, (oldNode)=>{

@@ -206,2 +206,46 @@ import {useState as $3pPTd$useState} from "react";

},
moveBefore (key, toParentKey, index) {
this.move(key, toParentKey, index);
},
moveAfter (key, toParentKey, index) {
setItems(({ items: items, nodeMap: originalMap })=>{
let node = originalMap.get(key);
if (!node) return {
items: items,
nodeMap: originalMap
};
let { items: newItems, nodeMap: newMap } = updateTree(items, key, ()=>null, originalMap);
const movedNode = {
...node,
parentKey: toParentKey
};
const afterIndex = items.length === index ? index : index + 1;
// If parentKey is null, insert into the root.
if (toParentKey == null) {
newMap.set(movedNode.key, movedNode);
return {
items: [
...newItems.slice(0, afterIndex),
movedNode,
...newItems.slice(afterIndex)
],
nodeMap: newMap
};
}
// Otherwise, update the parent node and its ancestors.
return updateTree(newItems, toParentKey, (parentNode)=>{
const c = [
...parentNode.children.slice(0, afterIndex),
movedNode,
...parentNode.children.slice(afterIndex)
];
return {
key: parentNode.key,
parentKey: parentNode.parentKey,
value: parentNode.value,
children: c
};
}, newMap);
});
},
update (oldKey, newValue) {

@@ -208,0 +252,0 @@ setItems(({ items: items, nodeMap: originalMap })=>updateTree(items, oldKey, (oldNode)=>{

4

package.json
{
"name": "@react-stately/data",
"version": "3.0.0-nightly-c53ab48ec-250115",
"version": "3.0.0-nightly-c78b24831-250206",
"description": "Spectrum UI components in React",

@@ -25,3 +25,3 @@ "license": "Apache-2.0",

"dependencies": {
"@react-types/shared": "3.0.0-nightly-c53ab48ec-250115",
"@react-types/shared": "3.0.0-nightly-c78b24831-250206",
"@swc/helpers": "^0.5.0"

@@ -28,0 +28,0 @@ },

@@ -111,2 +111,18 @@ /*

/**
* Moves an item before a node within the tree.
* @param key - The key of the item to move.
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
* @param index - The index within the new parent to insert before.
*/
moveBefore(key: Key, toParentKey: Key | null, index: number): void,
/**
* Moves an item after a node within the tree.
* @param key - The key of the item to move.
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
* @param index - The index within the new parent to insert after.
*/
moveAfter(key: Key, toParentKey: Key | null, index: number): void,
/**
* Updates an item in the tree.

@@ -377,2 +393,46 @@ * @param key - The key of the item to update.

},
moveBefore(key: Key, toParentKey: Key | null, index: number) {
this.move(key, toParentKey, index);
},
moveAfter(key: Key, toParentKey: Key | null, index: number) {
setItems(({items, nodeMap: originalMap}) => {
let node = originalMap.get(key);
if (!node) {
return {items, nodeMap: originalMap};
}
let {items: newItems, nodeMap: newMap} = updateTree(items, key, () => null, originalMap);
const movedNode = {
...node,
parentKey: toParentKey
};
const afterIndex = items.length === index ? index : index + 1;
// If parentKey is null, insert into the root.
if (toParentKey == null) {
newMap.set(movedNode.key, movedNode);
return {items: [
...newItems.slice(0, afterIndex),
movedNode,
...newItems.slice(afterIndex)
], nodeMap: newMap};
}
// Otherwise, update the parent node and its ancestors.
return updateTree(newItems, toParentKey, parentNode => {
const c = [
...parentNode.children!.slice(0, afterIndex),
movedNode,
...parentNode.children!.slice(afterIndex)
];
return {
key: parentNode.key,
parentKey: parentNode.parentKey,
value: parentNode.value,
children: c
};
}, newMap);
});
},
update(oldKey: Key, newValue: T) {

@@ -379,0 +439,0 @@ setItems(({items, nodeMap: originalMap}) => updateTree(items, oldKey, oldNode => {

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

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