@react-stately/tabs
Advanced tools
Comparing version 3.0.0-nightly-e37ad74f5-241101 to 3.0.0-nightly-e4497fdb6-250110
@@ -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-e37ad74f5-241101", | ||
"version": "3.0.0-nightly-e4497fdb6-250110", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,14 +25,13 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-stately/list": "^3.0.0-nightly-e37ad74f5-241101", | ||
"@react-types/shared": "^3.0.0-nightly-e37ad74f5-241101", | ||
"@react-types/tabs": "^3.0.0-nightly-e37ad74f5-241101", | ||
"@react-stately/list": "3.0.0-nightly-e4497fdb6-250110", | ||
"@react-types/shared": "3.0.0-nightly-e4497fdb6-250110", | ||
"@react-types/tabs": "3.0.0-nightly-e4497fdb6-250110", | ||
"@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" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"stableVersion": "3.6.10" | ||
} | ||
} |
@@ -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
35785
+ Added@react-stately/collections@3.0.0-nightly-e4497fdb6-250110(transitive)
+ Added@react-stately/list@3.0.0-nightly-e4497fdb6-250110(transitive)
+ Added@react-stately/selection@3.0.0-nightly-e4497fdb6-250110(transitive)
+ Added@react-stately/utils@3.0.0-nightly-e4497fdb6-250110(transitive)
+ Added@react-types/shared@3.0.0-nightly-e4497fdb6-250110(transitive)
+ Added@react-types/tabs@3.0.0-nightly-e4497fdb6-250110(transitive)
- Removed@react-stately/collections@3.12.1(transitive)
- Removed@react-stately/list@3.11.2(transitive)
- Removed@react-stately/selection@3.19.0(transitive)
- Removed@react-stately/utils@3.10.5(transitive)
- Removed@react-types/shared@3.27.0(transitive)
- Removed@react-types/tabs@3.3.12(transitive)