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

@react-stately/grid

Package Overview
Dependencies
Maintainers
2
Versions
755
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/grid - npm Package Compare versions

Comparing version 3.0.0-nightly-7aa6265a2-241113 to 3.0.0-nightly-7eae25e12-241205

24

dist/GridCollection.main.js

@@ -81,3 +81,3 @@

let childKeys = new Set();
let last;
let last = null;
for (let child of node.childNodes){

@@ -104,9 +104,11 @@ if (child.type === 'cell' && child.parentKey == null) // if child is a cell parent key isn't already established by the collection, match child node to parent row

};
let last;
opts.items.forEach((node, i)=>{
let last = null;
for (let [i, node] of opts.items.entries()){
var _node_level, _node_key, _node_type, _node_value, _node_textValue, _node_index;
let rowNode = {
level: 0,
key: 'row-' + i,
type: 'row',
value: undefined,
...node,
level: (_node_level = node.level) !== null && _node_level !== void 0 ? _node_level : 0,
key: (_node_key = node.key) !== null && _node_key !== void 0 ? _node_key : 'row-' + i,
type: (_node_type = node.type) !== null && _node_type !== void 0 ? _node_type : 'row',
value: (_node_value = node.value) !== null && _node_value !== void 0 ? _node_value : null,
hasChildNodes: true,

@@ -116,5 +118,5 @@ childNodes: [

],
rendered: undefined,
textValue: undefined,
...node
rendered: node.rendered,
textValue: (_node_textValue = node.textValue) !== null && _node_textValue !== void 0 ? _node_textValue : '',
index: (_node_index = node.index) !== null && _node_index !== void 0 ? _node_index : i
};

@@ -128,3 +130,3 @@ if (last) {

last = rowNode;
});
}
if (last) last.nextKey = null;

@@ -131,0 +133,0 @@ }

@@ -75,3 +75,3 @@ /*

let childKeys = new Set();
let last;
let last = null;
for (let child of node.childNodes){

@@ -98,9 +98,11 @@ if (child.type === 'cell' && child.parentKey == null) // if child is a cell parent key isn't already established by the collection, match child node to parent row

};
let last;
opts.items.forEach((node, i)=>{
let last = null;
for (let [i, node] of opts.items.entries()){
var _node_level, _node_key, _node_type, _node_value, _node_textValue, _node_index;
let rowNode = {
level: 0,
key: 'row-' + i,
type: 'row',
value: undefined,
...node,
level: (_node_level = node.level) !== null && _node_level !== void 0 ? _node_level : 0,
key: (_node_key = node.key) !== null && _node_key !== void 0 ? _node_key : 'row-' + i,
type: (_node_type = node.type) !== null && _node_type !== void 0 ? _node_type : 'row',
value: (_node_value = node.value) !== null && _node_value !== void 0 ? _node_value : null,
hasChildNodes: true,

@@ -110,5 +112,5 @@ childNodes: [

],
rendered: undefined,
textValue: undefined,
...node
rendered: node.rendered,
textValue: (_node_textValue = node.textValue) !== null && _node_textValue !== void 0 ? _node_textValue : '',
index: (_node_index = node.index) !== null && _node_index !== void 0 ? _node_index : i
};

@@ -122,3 +124,3 @@ if (last) {

last = rowNode;
});
}
if (last) last.nextKey = null;

@@ -125,0 +127,0 @@ }

@@ -33,12 +33,12 @@ import { GridCollection as _GridCollection1, GridNode, GridRow } from "@react-types/grid";

rows: GridNode<T>[];
constructor(opts?: GridCollectionOptions<T>);
constructor(opts: GridCollectionOptions<T>);
[Symbol.iterator](): Generator<GridNode<T>, void, undefined>;
get size(): number;
getKeys(): IterableIterator<Key>;
getKeyBefore(key: Key): Key;
getKeyAfter(key: Key): Key;
getFirstKey(): Key;
getLastKey(): Key;
getItem(key: Key): GridNode<T>;
at(idx: number): GridNode<T>;
getKeyBefore(key: Key): Key | null;
getKeyAfter(key: Key): Key | null;
getFirstKey(): Key | null;
getLastKey(): Key | null;
getItem(key: Key): GridNode<T> | null;
at(idx: number): GridNode<T> | null;
getChildren(key: Key): Iterable<GridNode<T>>;

@@ -45,0 +45,0 @@ }

@@ -29,4 +29,5 @@ var $5Cus8$reactstatelycollections = require("@react-stately/collections");

let children = (0, $5Cus8$reactstatelycollections.getChildNodes)(item, collection);
if (child === 'last') key = (_getLastItem = (0, $5Cus8$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key;
else key = (_getFirstItem = (0, $5Cus8$reactstatelycollections.getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
var _getLastItem_key, _getFirstItem_key;
if (child === 'last') key = (_getLastItem_key = (_getLastItem = (0, $5Cus8$reactstatelycollections.getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
else key = (_getFirstItem_key = (_getFirstItem = (0, $5Cus8$reactstatelycollections.getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
}

@@ -43,5 +44,9 @@ }

(0, $5Cus8$react.useEffect)(()=>{
if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
if (selectionState.focusedKey != null && cachedCollection.current && !collection.getItem(selectionState.focusedKey)) {
const node = cachedCollection.current.getItem(selectionState.focusedKey);
const parentNode = node.parentKey != null && (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column') ? cachedCollection.current.getItem(node.parentKey) : node;
const parentNode = (node === null || node === void 0 ? void 0 : node.parentKey) != null && (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column') ? cachedCollection.current.getItem(node.parentKey) : node;
if (!parentNode) {
selectionState.setFocusedKey(null);
return;
}
const cachedRows = cachedCollection.current.rows;

@@ -51,3 +56,3 @@ const rows = collection.rows;

let index = Math.min(diff > 1 ? Math.max(parentNode.index - diff + 1, 0) : parentNode.index, rows.length - 1);
let newRow;
let newRow = null;
while(index >= 0){

@@ -69,3 +74,3 @@ if (!selectionManager.isDisabled(rows[index].key) && rows[index].type !== 'headerrow') {

] : [];
const keyToFocus = newRow.hasChildNodes && parentNode !== node && node.index < childNodes.length ? childNodes[node.index].key : newRow.key;
const keyToFocus = newRow.hasChildNodes && parentNode !== node && node && node.index < childNodes.length ? childNodes[node.index].key : newRow.key;
selectionState.setFocusedKey(keyToFocus);

@@ -72,0 +77,0 @@ } else selectionState.setFocusedKey(null);

@@ -23,4 +23,5 @@ import {getChildNodes as $7nPCv$getChildNodes, getLastItem as $7nPCv$getLastItem, getFirstItem as $7nPCv$getFirstItem} from "@react-stately/collections";

let children = (0, $7nPCv$getChildNodes)(item, collection);
if (child === 'last') key = (_getLastItem = (0, $7nPCv$getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key;
else key = (_getFirstItem = (0, $7nPCv$getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
var _getLastItem_key, _getFirstItem_key;
if (child === 'last') key = (_getLastItem_key = (_getLastItem = (0, $7nPCv$getLastItem)(children)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
else key = (_getFirstItem_key = (_getFirstItem = (0, $7nPCv$getFirstItem)(children)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
}

@@ -37,5 +38,9 @@ }

(0, $7nPCv$useEffect)(()=>{
if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
if (selectionState.focusedKey != null && cachedCollection.current && !collection.getItem(selectionState.focusedKey)) {
const node = cachedCollection.current.getItem(selectionState.focusedKey);
const parentNode = node.parentKey != null && (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column') ? cachedCollection.current.getItem(node.parentKey) : node;
const parentNode = (node === null || node === void 0 ? void 0 : node.parentKey) != null && (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column') ? cachedCollection.current.getItem(node.parentKey) : node;
if (!parentNode) {
selectionState.setFocusedKey(null);
return;
}
const cachedRows = cachedCollection.current.rows;

@@ -45,3 +50,3 @@ const rows = collection.rows;

let index = Math.min(diff > 1 ? Math.max(parentNode.index - diff + 1, 0) : parentNode.index, rows.length - 1);
let newRow;
let newRow = null;
while(index >= 0){

@@ -63,3 +68,3 @@ if (!selectionManager.isDisabled(rows[index].key) && rows[index].type !== 'headerrow') {

] : [];
const keyToFocus = newRow.hasChildNodes && parentNode !== node && node.index < childNodes.length ? childNodes[node.index].key : newRow.key;
const keyToFocus = newRow.hasChildNodes && parentNode !== node && node && node.index < childNodes.length ? childNodes[node.index].key : newRow.key;
selectionState.setFocusedKey(keyToFocus);

@@ -66,0 +71,0 @@ } else selectionState.setFocusedKey(null);

{
"name": "@react-stately/grid",
"version": "3.0.0-nightly-7aa6265a2-241113",
"version": "3.0.0-nightly-7eae25e12-241205",
"description": "Spectrum UI components in React",

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

"dependencies": {
"@react-stately/collections": "^3.0.0-nightly-7aa6265a2-241113",
"@react-stately/selection": "^3.0.0-nightly-7aa6265a2-241113",
"@react-types/grid": "^3.0.0-nightly-7aa6265a2-241113",
"@react-types/shared": "^3.0.0-nightly-7aa6265a2-241113",
"@react-stately/collections": "^3.0.0-nightly-7eae25e12-241205",
"@react-stately/selection": "^3.0.0-nightly-7eae25e12-241205",
"@react-types/grid": "^3.0.0-nightly-7eae25e12-241205",
"@react-types/shared": "^3.0.0-nightly-7eae25e12-241205",
"@swc/helpers": "^0.5.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},

@@ -38,3 +38,3 @@ "publishConfig": {

},
"stableVersion": "3.9.3"
"stableVersion": "3.10.0"
}

@@ -27,3 +27,3 @@ /*

constructor(opts?: GridCollectionOptions<T>) {
constructor(opts: GridCollectionOptions<T>) {
this.keyMap = new Map();

@@ -45,3 +45,3 @@ this.columnCount = opts?.columnCount;

let childKeys = new Set();
let last: GridNode<T>;
let last: GridNode<T> | null = null;
for (let child of node.childNodes) {

@@ -88,15 +88,16 @@ if (child.type === 'cell' && child.parentKey == null) {

let last: GridNode<T>;
opts.items.forEach((node, i) => {
let rowNode = {
level: 0,
key: 'row-' + i,
type: 'row',
value: undefined,
let last: GridNode<T> | null = null;
for (let [i, node] of opts.items.entries()) {
let rowNode: GridNode<T> = {
...node,
level: node.level ?? 0,
key: node.key ?? 'row-' + i,
type: node.type ?? 'row',
value: node.value ?? null,
hasChildNodes: true,
childNodes: [...node.childNodes],
rendered: undefined,
textValue: undefined,
...node
} as GridNode<T>;
rendered: node.rendered,
textValue: node.textValue ?? '',
index: node.index ?? i
};

@@ -114,3 +115,3 @@ if (last) {

last = rowNode;
});
}

@@ -144,7 +145,7 @@ if (last) {

getFirstKey() {
getFirstKey(): Key | null {
return [...this.rows][0]?.key;
}
getLastKey() {
getLastKey(): Key | null {
let rows = [...this.rows];

@@ -151,0 +152,0 @@ return rows[rows.length - 1]?.key;

@@ -44,5 +44,5 @@ import {getChildNodes, getFirstItem, getLastItem} from '@react-stately/collections';

if (child === 'last') {
key = getLastItem(children)?.key;
key = getLastItem(children)?.key ?? null;
} else {
key = getFirstItem(children)?.key;
key = getFirstItem(children)?.key ?? null;
}

@@ -61,10 +61,14 @@ }

// Reset focused key if that item is deleted from the collection.
const cachedCollection = useRef(null);
const cachedCollection = useRef<C | null>(null);
useEffect(() => {
if (selectionState.focusedKey != null && !collection.getItem(selectionState.focusedKey)) {
if (selectionState.focusedKey != null && cachedCollection.current && !collection.getItem(selectionState.focusedKey)) {
const node = cachedCollection.current.getItem(selectionState.focusedKey);
const parentNode =
node.parentKey != null && (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column') ?
node?.parentKey != null && (node.type === 'cell' || node.type === 'rowheader' || node.type === 'column') ?
cachedCollection.current.getItem(node.parentKey) :
node;
if (!parentNode) {
selectionState.setFocusedKey(null);
return;
}
const cachedRows = cachedCollection.current.rows;

@@ -80,3 +84,3 @@ const rows = collection.rows;

rows.length - 1);
let newRow:GridNode<T>;
let newRow: GridNode<T> | null = null;
while (index >= 0) {

@@ -103,2 +107,3 @@ if (!selectionManager.isDisabled(rows[index].key) && rows[index].type !== 'headerrow') {

parentNode !== node &&
node &&
node.index < childNodes.length ?

@@ -105,0 +110,0 @@ childNodes[node.index].key :

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

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