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

@react-stately/tabs

Package Overview
Dependencies
Maintainers
2
Versions
768
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/tabs - npm Package Compare versions

Comparing version 3.0.0-nightly-a98da553e-241116 to 3.0.0-nightly-ab9fd5c68-241122

10

dist/useTabListState.main.js

@@ -23,7 +23,7 @@ var $3yB4p$reactstatelylist = require("@react-stately/list");

function $817f925d289daf81$export$4ba071daf4e486(props) {
var _props_defaultSelectedKey;
var _props_defaultSelectedKey, _ref;
let state = (0, $3yB4p$reactstatelylist.useSingleSelectListState)({
...props,
suppressTextValueWarning: true,
defaultSelectedKey: (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : $817f925d289daf81$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : new Set())
defaultSelectedKey: (_ref = (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : $817f925d289daf81$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : new Set())) !== null && _ref !== void 0 ? _ref : undefined
});

@@ -35,3 +35,3 @@ let { selectionManager: selectionManager, collection: collection, selectedKey: currentSelectedKey } = state;

let selectedKey = currentSelectedKey;
if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
if (selectionManager.isEmpty || selectedKey == null || !collection.getItem(selectedKey)) {
selectedKey = $817f925d289daf81$var$findDefaultSelectedKey(collection, state.disabledKeys);

@@ -58,5 +58,5 @@ if (selectedKey != null) // directly set selection because replace/toggle selection won't consider disabled keys

// loop over tabs until we find one that isn't disabled and select that
while((disabledKeys.has(selectedKey) || ((_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : (_collection_getItem_props = _collection_getItem.props) === null || _collection_getItem_props === void 0 ? void 0 : _collection_getItem_props.isDisabled)) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
while(selectedKey != null && (disabledKeys.has(selectedKey) || ((_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : (_collection_getItem_props = _collection_getItem.props) === null || _collection_getItem_props === void 0 ? void 0 : _collection_getItem_props.isDisabled)) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
// if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
if ((disabledKeys.has(selectedKey) || ((_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : (_collection_getItem_props1 = _collection_getItem1.props) === null || _collection_getItem_props1 === void 0 ? void 0 : _collection_getItem_props1.isDisabled)) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
if (selectedKey != null && (disabledKeys.has(selectedKey) || ((_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : (_collection_getItem_props1 = _collection_getItem1.props) === null || _collection_getItem_props1 === void 0 ? void 0 : _collection_getItem_props1.isDisabled)) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
}

@@ -63,0 +63,0 @@ return selectedKey;

@@ -17,7 +17,7 @@ import {useSingleSelectListState as $fgY1A$useSingleSelectListState} from "@react-stately/list";

function $76f919a04c5a7d14$export$4ba071daf4e486(props) {
var _props_defaultSelectedKey;
var _props_defaultSelectedKey, _ref;
let state = (0, $fgY1A$useSingleSelectListState)({
...props,
suppressTextValueWarning: true,
defaultSelectedKey: (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : $76f919a04c5a7d14$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : new Set())
defaultSelectedKey: (_ref = (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : $76f919a04c5a7d14$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : new Set())) !== null && _ref !== void 0 ? _ref : undefined
});

@@ -29,3 +29,3 @@ let { selectionManager: selectionManager, collection: collection, selectedKey: currentSelectedKey } = state;

let selectedKey = currentSelectedKey;
if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
if (selectionManager.isEmpty || selectedKey == null || !collection.getItem(selectedKey)) {
selectedKey = $76f919a04c5a7d14$var$findDefaultSelectedKey(collection, state.disabledKeys);

@@ -52,5 +52,5 @@ if (selectedKey != null) // directly set selection because replace/toggle selection won't consider disabled keys

// loop over tabs until we find one that isn't disabled and select that
while((disabledKeys.has(selectedKey) || ((_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : (_collection_getItem_props = _collection_getItem.props) === null || _collection_getItem_props === void 0 ? void 0 : _collection_getItem_props.isDisabled)) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
while(selectedKey != null && (disabledKeys.has(selectedKey) || ((_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : (_collection_getItem_props = _collection_getItem.props) === null || _collection_getItem_props === void 0 ? void 0 : _collection_getItem_props.isDisabled)) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
// if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
if ((disabledKeys.has(selectedKey) || ((_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : (_collection_getItem_props1 = _collection_getItem1.props) === null || _collection_getItem_props1 === void 0 ? void 0 : _collection_getItem_props1.isDisabled)) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
if (selectedKey != null && (disabledKeys.has(selectedKey) || ((_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : (_collection_getItem_props1 = _collection_getItem1.props) === null || _collection_getItem_props1 === void 0 ? void 0 : _collection_getItem_props1.isDisabled)) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
}

@@ -57,0 +57,0 @@ return selectedKey;

{
"name": "@react-stately/tabs",
"version": "3.0.0-nightly-a98da553e-241116",
"version": "3.0.0-nightly-ab9fd5c68-241122",
"description": "Spectrum UI components in React",

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

"dependencies": {
"@react-stately/list": "^3.0.0-nightly-a98da553e-241116",
"@react-types/shared": "^3.0.0-nightly-a98da553e-241116",
"@react-types/tabs": "^3.0.0-nightly-a98da553e-241116",
"@react-stately/list": "^3.0.0-nightly-ab9fd5c68-241122",
"@react-types/shared": "^3.0.0-nightly-ab9fd5c68-241122",
"@react-types/tabs": "^3.0.0-nightly-ab9fd5c68-241122",
"@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"
},

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

},
"stableVersion": "3.6.10"
"stableVersion": "3.7.0"
}

@@ -33,3 +33,3 @@ /*

suppressTextValueWarning: true,
defaultSelectedKey: props.defaultSelectedKey ?? findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : new Set())
defaultSelectedKey: props.defaultSelectedKey ?? findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : new Set()) ?? undefined
});

@@ -47,3 +47,3 @@

let selectedKey = currentSelectedKey;
if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
if (selectionManager.isEmpty || selectedKey == null || !collection.getItem(selectedKey)) {
selectedKey = findDefaultSelectedKey(collection, state.disabledKeys);

@@ -69,12 +69,12 @@ if (selectedKey != null) {

function findDefaultSelectedKey<T>(collection: Collection<Node<T>> | null, disabledKeys: Set<Key>) {
let selectedKey = null;
function findDefaultSelectedKey<T>(collection: Collection<Node<T>> | undefined, disabledKeys: Set<Key>) {
let selectedKey: Key | null = null;
if (collection) {
selectedKey = collection.getFirstKey();
// loop over tabs until we find one that isn't disabled and select that
while ((disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey !== collection.getLastKey()) {
while (selectedKey != null && (disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey !== collection.getLastKey()) {
selectedKey = collection.getKeyAfter(selectedKey);
}
// if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
if ((disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey === collection.getLastKey()) {
if (selectedKey != null && (disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey === collection.getLastKey()) {
selectedKey = collection.getFirstKey();

@@ -81,0 +81,0 @@ }

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