@react-stately/tabs 3.1.0 → 3.2.1

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
@@ -1,28 +1,11 @@
1
1
  var $7iSyh$reactstatelylist = require("@react-stately/list");
2
2
  var $7iSyh$react = require("react");
3
3
 
4
- function $parcel$exportWildcard(dest, source) {
5
- Object.keys(source).forEach(function(key) {
6
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
7
- return;
8
- }
9
-
10
- Object.defineProperty(dest, key, {
11
- enumerable: true,
12
- get: function get() {
13
- return source[key];
14
- }
15
- });
16
- });
17
-
18
- return dest;
19
- }
20
4
  function $parcel$export(e, n, v, s) {
21
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
6
  }
23
- var $817f925d289daf81$exports = {};
24
7
 
25
- $parcel$export($817f925d289daf81$exports, "useTabListState", () => $817f925d289daf81$export$4ba071daf4e486);
8
+ $parcel$export(module.exports, "useTabListState", () => $817f925d289daf81$export$4ba071daf4e486);
26
9
 
27
10
 
28
11
  function $817f925d289daf81$export$4ba071daf4e486(props) {
@@ -48,11 +31,13 @@ function $817f925d289daf81$export$4ba071daf4e486(props) {
48
31
  // 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.
49
32
  if (selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
50
33
  lastSelectedKey.current = selectedKey;
51
- return state;
34
+ return {
35
+ ...state,
36
+ isDisabled: props.isDisabled || false
37
+ };
52
38
  }
53
39
 
54
40
 
55
- $parcel$exportWildcard(module.exports, $817f925d289daf81$exports);
56
41
 
57
42
 
58
43
  //# sourceMappingURL=main.js.map
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,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"}
1
+ {"mappings":";;;;;;;;;;SC0BgB,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,CAAC;WACH,KAAK;QACR,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;IACvC,CAAC;AACH,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 {useTabListState} from './useTabListState';\n\nexport type {TabListProps} from '@react-types/tabs';\nexport type {TabListState} 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 /** Whether the tab list is disabled. */\n isDisabled: boolean\n}\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 {\n ...state,\n isDisabled: props.isDisabled || false\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,12 +1,6 @@
1
1
  import {useSingleSelectListState as $ijHKZ$useSingleSelectListState} from "@react-stately/list";
2
2
  import {useRef as $ijHKZ$useRef} from "react";
3
3
 
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
- var $76f919a04c5a7d14$exports = {};
8
-
9
- $parcel$export($76f919a04c5a7d14$exports, "useTabListState", () => $76f919a04c5a7d14$export$4ba071daf4e486);
10
4
 
11
5
 
12
6
  function $76f919a04c5a7d14$export$4ba071daf4e486(props) {
@@ -32,7 +26,10 @@ function $76f919a04c5a7d14$export$4ba071daf4e486(props) {
32
26
  // 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.
33
27
  if (selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
34
28
  lastSelectedKey.current = selectedKey;
35
- return state;
29
+ return {
30
+ ...state,
31
+ isDisabled: props.isDisabled || false
32
+ };
36
33
  }
37
34
 
38
35
 
@@ -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,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
+ {"mappings":";;;;;SC0BgB,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,CAAC;WACH,KAAK;QACR,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;IACvC,CAAC;AACH,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 {useTabListState} from './useTabListState';\n\nexport type {TabListProps} from '@react-types/tabs';\nexport type {TabListState} 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 /** Whether the tab list is disabled. */\n isDisabled: boolean\n}\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 {\n ...state,\n isDisabled: props.isDisabled || false\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { SingleSelectListState } from "@react-stately/list";
2
2
  import { TabListProps } from "@react-types/tabs";
3
3
  export interface TabListState<T> extends SingleSelectListState<T> {
4
+ /** Whether the tab list is disabled. */
5
+ isDisabled: boolean;
4
6
  }
5
7
  /**
6
8
  * Provides state management for a Tabs component. Tabs include a TabList which tracks
7
9
  * which tab is currently selected and displays the content associated with that Tab in a TabPanel.
8
10
  */
9
11
  export function useTabListState<T extends object>(props: TabListProps<T>): TabListState<T>;
12
+ export type { TabListProps } from '@react-types/tabs';
10
13
 
11
14
  //# sourceMappingURL=types.d.ts.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,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"}
1
+ {"mappings":";;AAiBA,8BAA8B,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC;IAC/D,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;GAGG;AACH,gCAAgC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAuCzF;ACnDD,YAAY,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC","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 {useTabListState} from './useTabListState';\n\nexport type {TabListProps} from '@react-types/tabs';\nexport type {TabListState} 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.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,9 +18,9 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/list": "^3.5.0",
22
- "@react-stately/utils": "^3.5.0",
23
- "@react-types/tabs": "^3.1.0"
21
+ "@react-stately/list": "^3.5.3",
22
+ "@react-stately/utils": "^3.5.1",
23
+ "@react-types/tabs": "^3.1.3"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
31
+ "gitHead": "b03ef51e6317547dd0a840f151e59d039b1e1fd3"
32
32
  }
package/src/index.ts CHANGED
@@ -10,4 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export * from './useTabListState';
13
+ export {useTabListState} from './useTabListState';
14
+
15
+ export type {TabListProps} from '@react-types/tabs';
16
+ export type {TabListState} from './useTabListState';
@@ -15,7 +15,10 @@ import {TabListProps} from '@react-types/tabs';
15
15
  import {useRef} from 'react';
16
16
 
17
17
 
18
- export interface TabListState<T> extends SingleSelectListState<T> {}
18
+ export interface TabListState<T> extends SingleSelectListState<T> {
19
+ /** Whether the tab list is disabled. */
20
+ isDisabled: boolean
21
+ }
19
22
 
20
23
  /**
21
24
  * Provides state management for a Tabs component. Tabs include a TabList which tracks
@@ -56,5 +59,8 @@ export function useTabListState<T extends object>(props: TabListProps<T>): TabLi
56
59
  }
57
60
  lastSelectedKey.current = selectedKey;
58
61
 
59
- return state;
62
+ return {
63
+ ...state,
64
+ isDisabled: props.isDisabled || false
65
+ };
60
66
  }