@react-stately/tabs 3.2.4 → 3.3.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.
Files changed (2) hide show
  1. package/dist/import.mjs +59 -0
  2. package/package.json +10 -5
@@ -0,0 +1,59 @@
1
+ import {useSingleSelectListState as $ijHKZ$useSingleSelectListState} from "@react-stately/list";
2
+ import {useRef as $ijHKZ$useRef} from "react";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+ function $76f919a04c5a7d14$export$4ba071daf4e486(props) {
27
+ let state = (0, $ijHKZ$useSingleSelectListState)({
28
+ ...props,
29
+ suppressTextValueWarning: true
30
+ });
31
+ let { selectionManager: selectionManager , collection: collection , selectedKey: currentSelectedKey } = state;
32
+ let lastSelectedKey = (0, $ijHKZ$useRef)(currentSelectedKey);
33
+ // Ensure a tab is always selected (in case no selected key was specified or if selected item was deleted from collection)
34
+ let selectedKey = currentSelectedKey;
35
+ if (selectionManager.isEmpty || !collection.getItem(selectedKey)) {
36
+ selectedKey = collection.getFirstKey();
37
+ // loop over tabs until we find one that isn't disabled and select that
38
+ while(state.disabledKeys.has(selectedKey) && selectedKey !== collection.getLastKey())selectedKey = collection.getKeyAfter(selectedKey);
39
+ // if this check is true, then every item is disabled, it makes more sense to default to the first key than the last
40
+ if (state.disabledKeys.has(selectedKey) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
41
+ // directly set selection because replace/toggle selection won't consider disabled keys
42
+ selectionManager.setSelectedKeys([
43
+ selectedKey
44
+ ]);
45
+ }
46
+ // 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.
47
+ if (selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
48
+ lastSelectedKey.current = selectedKey;
49
+ return {
50
+ ...state,
51
+ isDisabled: props.isDisabled || false
52
+ };
53
+ }
54
+
55
+
56
+
57
+
58
+ export {$76f919a04c5a7d14$export$4ba071daf4e486 as useTabListState};
59
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-stately/tabs",
3
- "version": "3.2.4",
3
+ "version": "3.3.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,9 +22,9 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-stately/list": "^3.6.1",
21
- "@react-stately/utils": "^3.5.2",
22
- "@react-types/tabs": "^3.1.5",
25
+ "@react-stately/list": "^3.7.0",
26
+ "@react-stately/utils": "^3.6.0",
27
+ "@react-types/tabs": "^3.2.0",
23
28
  "@swc/helpers": "^0.4.14"
24
29
  },
25
30
  "peerDependencies": {
@@ -28,5 +33,5 @@
28
33
  "publishConfig": {
29
34
  "access": "public"
30
35
  },
31
- "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
36
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
32
37
  }