@react-stately/tabs 3.0.5 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -36,7 +36,14 @@ function $817f925d289daf81$export$4ba071daf4e486(props) {
36
36
  let selectedKey = currentSelectedKey;
37
37
  if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
38
38
  selectedKey = collection.getFirstKey();
39
- selectionManager.replaceSelection(selectedKey);
39
+ // loop over tabs until we find one that isn't disabled and select that
40
+ while(state.disabledKeys.has(selectedKey) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
41
+ // if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
42
+ if (state.disabledKeys.has(selectedKey) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
43
+ // directly set selection because replace/toggle selection won't consider disabled keys
44
+ selectionManager.setSelectedKeys([
45
+ selectedKey
46
+ ]);
40
47
  }
41
48
  // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.
42
49
  if (selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;SCuBgB,uCAAe,CAAmB,KAAsB,EAAmB,CAAC;IAC1F,GAAG,CAAC,KAAK,GAAG,gDAAwB,CAAI,CAAC;WACpC,KAAK;QACR,wBAAwB,EAAE,IAAI;IAChC,CAAC;IAED,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,GACV,WAAW,EAAE,kBAAkB,EACjC,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,eAAe,GAAG,mBAAM,CAAC,kBAAkB;IAC/C,EAA0H,AAA1H,wHAA0H;IAC1H,GAAG,CAAC,WAAW,GAAG,kBAAkB;IACpC,EAAE,EAAE,gBAAgB,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC;QACjE,WAAW,GAAG,UAAU,CAAC,WAAW;QACpC,gBAAgB,CAAC,gBAAgB,CAAC,WAAW;IAC/C,CAAC;IAED,EAA2J,AAA3J,yJAA2J;IAC3J,EAAE,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI,KAAM,gBAAgB,CAAC,SAAS,IAAI,WAAW,KAAK,eAAe,CAAC,OAAO,EAChH,gBAAgB,CAAC,aAAa,CAAC,WAAW;IAE5C,eAAe,CAAC,OAAO,GAAG,WAAW;IAErC,MAAM,CAAC,KAAK;AACd,CAAC","sources":["packages/@react-stately/tabs/src/index.ts","packages/@react-stately/tabs/src/useTabListState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTabListState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {TabListProps} from '@react-types/tabs';\nimport {useRef} from 'react';\n\n\nexport interface TabListState<T> extends SingleSelectListState<T> {}\n\n/**\n * Provides state management for a Tabs component. Tabs include a TabList which tracks\n * which tab is currently selected and displays the content associated with that Tab in a TabPanel.\n */\nexport function useTabListState<T extends object>(props: TabListProps<T>): TabListState<T> {\n let state = useSingleSelectListState<T>({\n ...props,\n suppressTextValueWarning: true\n });\n\n let {\n selectionManager,\n collection,\n selectedKey: currentSelectedKey\n } = state;\n\n let lastSelectedKey = useRef(currentSelectedKey);\n // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)\n let selectedKey = currentSelectedKey;\n if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {\n selectedKey = collection.getFirstKey();\n selectionManager.replaceSelection(selectedKey);\n }\n\n // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.\n if (selectionManager.focusedKey == null || (!selectionManager.isFocused && selectedKey !== lastSelectedKey.current)) {\n selectionManager.setFocusedKey(selectedKey);\n }\n lastSelectedKey.current = selectedKey;\n\n return state;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;SCuBgB,uCAAe,CAAmB,KAAsB,EAAmB,CAAC;IAC1F,GAAG,CAAC,KAAK,GAAG,gDAAwB,CAAI,CAAC;WACpC,KAAK;QACR,wBAAwB,EAAE,IAAI;IAChC,CAAC;IAED,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,GACV,WAAW,EAAE,kBAAkB,EACjC,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,eAAe,GAAG,mBAAM,CAAC,kBAAkB;IAC/C,EAA0H,AAA1H,wHAA0H;IAC1H,GAAG,CAAC,WAAW,GAAG,kBAAkB;IACpC,EAAE,EAAE,gBAAgB,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC;QACjE,WAAW,GAAG,UAAU,CAAC,WAAW;QACpC,EAAuE,AAAvE,qEAAuE;cAChE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,KAAK,WAAW,KAAK,UAAU,CAAC,UAAU,GACjF,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW;QAElD,EAAoH,AAApH,kHAAoH;QACpH,EAAE,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,KAAK,WAAW,KAAK,UAAU,CAAC,UAAU,IAC9E,WAAW,GAAG,UAAU,CAAC,WAAW;QAEtC,EAAuF,AAAvF,qFAAuF;QACvF,gBAAgB,CAAC,eAAe,CAAC,CAAC;YAAA,WAAW;QAAA,CAAC;IAChD,CAAC;IAED,EAA2J,AAA3J,yJAA2J;IAC3J,EAAE,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI,KAAM,gBAAgB,CAAC,SAAS,IAAI,WAAW,KAAK,eAAe,CAAC,OAAO,EAChH,gBAAgB,CAAC,aAAa,CAAC,WAAW;IAE5C,eAAe,CAAC,OAAO,GAAG,WAAW;IAErC,MAAM,CAAC,KAAK;AACd,CAAC","sources":["packages/@react-stately/tabs/src/index.ts","packages/@react-stately/tabs/src/useTabListState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTabListState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {TabListProps} from '@react-types/tabs';\nimport {useRef} from 'react';\n\n\nexport interface TabListState<T> extends SingleSelectListState<T> {}\n\n/**\n * Provides state management for a Tabs component. Tabs include a TabList which tracks\n * which tab is currently selected and displays the content associated with that Tab in a TabPanel.\n */\nexport function useTabListState<T extends object>(props: TabListProps<T>): TabListState<T> {\n let state = useSingleSelectListState<T>({\n ...props,\n suppressTextValueWarning: true\n });\n\n let {\n selectionManager,\n collection,\n selectedKey: currentSelectedKey\n } = state;\n\n let lastSelectedKey = useRef(currentSelectedKey);\n // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)\n let selectedKey = currentSelectedKey;\n if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {\n selectedKey = collection.getFirstKey();\n // loop over tabs until we find one that isn't disabled and select that\n while (state.disabledKeys.has(selectedKey) && selectedKey !== collection.getLastKey()) {\n selectedKey = collection.getKeyAfter(selectedKey);\n }\n // if this check is true, then every item is disabled, it makes more sense to default to the first key than the last\n if (state.disabledKeys.has(selectedKey) && selectedKey === collection.getLastKey()) {\n selectedKey = collection.getFirstKey();\n }\n // directly set selection because replace/toggle selection won't consider disabled keys\n selectionManager.setSelectedKeys([selectedKey]);\n }\n\n // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.\n if (selectionManager.focusedKey == null || (!selectionManager.isFocused && selectedKey !== lastSelectedKey.current)) {\n selectionManager.setFocusedKey(selectedKey);\n }\n lastSelectedKey.current = selectedKey;\n\n return state;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -20,7 +20,14 @@ function $76f919a04c5a7d14$export$4ba071daf4e486(props) {
20
20
  let selectedKey = currentSelectedKey;
21
21
  if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
22
22
  selectedKey = collection.getFirstKey();
23
- selectionManager.replaceSelection(selectedKey);
23
+ // loop over tabs until we find one that isn't disabled and select that
24
+ while(state.disabledKeys.has(selectedKey) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
25
+ // if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
26
+ if (state.disabledKeys.has(selectedKey) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
27
+ // directly set selection because replace/toggle selection won't consider disabled keys
28
+ selectionManager.setSelectedKeys([
29
+ selectedKey
30
+ ]);
24
31
  }
25
32
  // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.
26
33
  if (selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;SCuBgB,uCAAe,CAAmB,KAAsB,EAAmB,CAAC;IAC1F,GAAG,CAAC,KAAK,GAAG,+BAAwB,CAAI,CAAC;WACpC,KAAK;QACR,wBAAwB,EAAE,IAAI;IAChC,CAAC;IAED,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,GACV,WAAW,EAAE,kBAAkB,EACjC,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,eAAe,GAAG,aAAM,CAAC,kBAAkB;IAC/C,EAA0H,AAA1H,wHAA0H;IAC1H,GAAG,CAAC,WAAW,GAAG,kBAAkB;IACpC,EAAE,EAAE,gBAAgB,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC;QACjE,WAAW,GAAG,UAAU,CAAC,WAAW;QACpC,gBAAgB,CAAC,gBAAgB,CAAC,WAAW;IAC/C,CAAC;IAED,EAA2J,AAA3J,yJAA2J;IAC3J,EAAE,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI,KAAM,gBAAgB,CAAC,SAAS,IAAI,WAAW,KAAK,eAAe,CAAC,OAAO,EAChH,gBAAgB,CAAC,aAAa,CAAC,WAAW;IAE5C,eAAe,CAAC,OAAO,GAAG,WAAW;IAErC,MAAM,CAAC,KAAK;AACd,CAAC","sources":["packages/@react-stately/tabs/src/index.ts","packages/@react-stately/tabs/src/useTabListState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTabListState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {TabListProps} from '@react-types/tabs';\nimport {useRef} from 'react';\n\n\nexport interface TabListState<T> extends SingleSelectListState<T> {}\n\n/**\n * Provides state management for a Tabs component. Tabs include a TabList which tracks\n * which tab is currently selected and displays the content associated with that Tab in a TabPanel.\n */\nexport function useTabListState<T extends object>(props: TabListProps<T>): TabListState<T> {\n let state = useSingleSelectListState<T>({\n ...props,\n suppressTextValueWarning: true\n });\n\n let {\n selectionManager,\n collection,\n selectedKey: currentSelectedKey\n } = state;\n\n let lastSelectedKey = useRef(currentSelectedKey);\n // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)\n let selectedKey = currentSelectedKey;\n if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {\n selectedKey = collection.getFirstKey();\n selectionManager.replaceSelection(selectedKey);\n }\n\n // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.\n if (selectionManager.focusedKey == null || (!selectionManager.isFocused && selectedKey !== lastSelectedKey.current)) {\n selectionManager.setFocusedKey(selectedKey);\n }\n lastSelectedKey.current = selectedKey;\n\n return state;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;;;SCuBgB,uCAAe,CAAmB,KAAsB,EAAmB,CAAC;IAC1F,GAAG,CAAC,KAAK,GAAG,+BAAwB,CAAI,CAAC;WACpC,KAAK;QACR,wBAAwB,EAAE,IAAI;IAChC,CAAC;IAED,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,GACV,WAAW,EAAE,kBAAkB,EACjC,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,eAAe,GAAG,aAAM,CAAC,kBAAkB;IAC/C,EAA0H,AAA1H,wHAA0H;IAC1H,GAAG,CAAC,WAAW,GAAG,kBAAkB;IACpC,EAAE,EAAE,gBAAgB,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC;QACjE,WAAW,GAAG,UAAU,CAAC,WAAW;QACpC,EAAuE,AAAvE,qEAAuE;cAChE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,KAAK,WAAW,KAAK,UAAU,CAAC,UAAU,GACjF,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW;QAElD,EAAoH,AAApH,kHAAoH;QACpH,EAAE,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,KAAK,WAAW,KAAK,UAAU,CAAC,UAAU,IAC9E,WAAW,GAAG,UAAU,CAAC,WAAW;QAEtC,EAAuF,AAAvF,qFAAuF;QACvF,gBAAgB,CAAC,eAAe,CAAC,CAAC;YAAA,WAAW;QAAA,CAAC;IAChD,CAAC;IAED,EAA2J,AAA3J,yJAA2J;IAC3J,EAAE,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI,KAAM,gBAAgB,CAAC,SAAS,IAAI,WAAW,KAAK,eAAe,CAAC,OAAO,EAChH,gBAAgB,CAAC,aAAa,CAAC,WAAW;IAE5C,eAAe,CAAC,OAAO,GAAG,WAAW;IAErC,MAAM,CAAC,KAAK;AACd,CAAC","sources":["packages/@react-stately/tabs/src/index.ts","packages/@react-stately/tabs/src/useTabListState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTabListState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {TabListProps} from '@react-types/tabs';\nimport {useRef} from 'react';\n\n\nexport interface TabListState<T> extends SingleSelectListState<T> {}\n\n/**\n * Provides state management for a Tabs component. Tabs include a TabList which tracks\n * which tab is currently selected and displays the content associated with that Tab in a TabPanel.\n */\nexport function useTabListState<T extends object>(props: TabListProps<T>): TabListState<T> {\n let state = useSingleSelectListState<T>({\n ...props,\n suppressTextValueWarning: true\n });\n\n let {\n selectionManager,\n collection,\n selectedKey: currentSelectedKey\n } = state;\n\n let lastSelectedKey = useRef(currentSelectedKey);\n // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)\n let selectedKey = currentSelectedKey;\n if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {\n selectedKey = collection.getFirstKey();\n // loop over tabs until we find one that isn't disabled and select that\n while (state.disabledKeys.has(selectedKey) && selectedKey !== collection.getLastKey()) {\n selectedKey = collection.getKeyAfter(selectedKey);\n }\n // if this check is true, then every item is disabled, it makes more sense to default to the first key than the last\n if (state.disabledKeys.has(selectedKey) && selectedKey === collection.getLastKey()) {\n selectedKey = collection.getFirstKey();\n }\n // directly set selection because replace/toggle selection won't consider disabled keys\n selectionManager.setSelectedKeys([selectedKey]);\n }\n\n // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.\n if (selectionManager.focusedKey == null || (!selectionManager.isFocused && selectedKey !== lastSelectedKey.current)) {\n selectionManager.setFocusedKey(selectedKey);\n }\n lastSelectedKey.current = selectedKey;\n\n return state;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAiBA,8BAA8B,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC;CAAG;AAEpE;;;GAGG;AACH,gCAAgC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CA2BzF","sources":["packages/@react-stately/tabs/src/packages/@react-stately/tabs/src/useTabListState.ts","packages/@react-stately/tabs/src/packages/@react-stately/tabs/src/index.ts","packages/@react-stately/tabs/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTabListState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAiBA,8BAA8B,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC;CAAG;AAEpE;;;GAGG;AACH,gCAAgC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAoCzF","sources":["packages/@react-stately/tabs/src/packages/@react-stately/tabs/src/useTabListState.ts","packages/@react-stately/tabs/src/packages/@react-stately/tabs/src/index.ts","packages/@react-stately/tabs/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useTabListState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/tabs",
3
- "version": "3.0.5",
3
+ "version": "3.1.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/list": "^3.4.5",
22
- "@react-stately/utils": "^3.4.1",
23
- "@react-types/tabs": "^3.0.5"
21
+ "@react-stately/list": "^3.5.0",
22
+ "@react-stately/utils": "^3.5.0",
23
+ "@react-types/tabs": "^3.1.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "react": "^16.8.0 || ^17.0.0-rc.1"
26
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "6a503b715e0dbbf92038cd7f08b1bcdde4c78e82"
31
+ "gitHead": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
32
32
  }
@@ -38,7 +38,16 @@ export function useTabListState<T extends object>(props: TabListProps<T>): TabLi
38
38
  let selectedKey = currentSelectedKey;
39
39
  if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
40
40
  selectedKey = collection.getFirstKey();
41
- selectionManager.replaceSelection(selectedKey);
41
+ // loop over tabs until we find one that isn't disabled and select that
42
+ while (state.disabledKeys.has(selectedKey) && selectedKey !== collection.getLastKey()) {
43
+ selectedKey = collection.getKeyAfter(selectedKey);
44
+ }
45
+ // if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
46
+ if (state.disabledKeys.has(selectedKey) && selectedKey === collection.getLastKey()) {
47
+ selectedKey = collection.getFirstKey();
48
+ }
49
+ // directly set selection because replace/toggle selection won't consider disabled keys
50
+ selectionManager.setSelectedKeys([selectedKey]);
42
51
  }
43
52
 
44
53
  // If the tablist doesn't have focus and the selected key changes or if there isn't a focused key yet, change focused key to the selected key if it exists.